Skip to main content

compact.compaction_report

compact.compaction_report(spec)

The sediment of the spec: what could be removed, merged or has to be re-examined.

Compaction is a filter of the checks, not a second check: it returns exactly the findings of run_checks whose ID starts with COMPACT, in their order. They are an allowed subpackage or edge that nothing uses (COMPACT01, COMPACT02), a known cycle that is gone (COMPACT03), a depends_on entry the module does not import (COMPACT04), an evaluation no intent item names (COMPACT05), an active decision nobody cites (COMPACT06) and a consumer that no longer references its unit (COMPACT07).

Parameters

Name Type Description Default
spec RegenSpec The loaded spec. required

Returns

Name Type Description
list[Finding] list[Finding]: Warnings only. An empty list means nothing to compact.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from babregen import compaction_report, load_spec, make_sample_repo

with TemporaryDirectory() as tmp:
    root = make_sample_repo(Path(tmp) / "demo")
    print(compaction_report(load_spec(root)))
    (root / "src/samplepkg/app/main.py").write_text("print(3)\n")
    for finding in compaction_report(load_spec(root)):
        print(finding.format())
[]
regen/architecture.toml:12: warning COMPACT02 allowed edge app -> core is unused
regen/units/core.calc.toml:16: warning COMPACT07 consumer src/samplepkg/app/main.py no longer references the unit