Skip to content

symfonic.devtools.archgate.suite

suite

The permanent architecture + DRY gate: one command, one verdict.

Three checkers already existed and each had its own entry point, which is the same as having none: a rule nobody runs is a document. This composes them โ€” T1.2.4's architecture rules, T4.2.1's optional-import rules, and T4.4.1's DRY invariants โ€” into a single blocking result, and declares, in :data:ENFORCED_FAMILIES, which rule name answers which REQ-S4.4 clause.

run_gate

run_gate(config: ArchgateConfig, today: date | None = None, strict_hygiene: bool = False) -> GateResult

Run every composed checker against the repository the config names.

Source code in src/symfonic/devtools/archgate/suite.py
def run_gate(
    config: ArchgateConfig,
    today: dt.date | None = None,
    strict_hygiene: bool = False,
) -> GateResult:
    """Run every composed checker against the repository the config names."""
    archcheck_config = load_config(config.archcheck_config_path)
    archcheck_result = run_all(archcheck_config, today=today)
    modules = archcheck_result.modules or scan_source_tree(config.src_root)

    integration_map = load_map(config.integration_map_path)
    integrations = tuple(integration_violations(modules, integration_map))

    facts = collect_facts(modules)
    raw_dry = check_single_source(modules, config.single_source_rules)
    raw_dry += check_single_definition(facts, config.single_definition_rules)
    raw_dry += check_forbidden_globals(facts, config.sanctioned_global_modules)

    dry_entries = load_registry(config.registry_path)
    active, suppressed = apply_exceptions(raw_dry, dry_entries, today=today)
    active.extend(expired_entries(dry_entries, today=today))
    active.sort(key=lambda violation: (violation.rule, violation.modules))

    coverage, coverage_suppressed = apply_exceptions(
        check_export_coverage(modules, archcheck_config), dry_entries, today=today
    )
    suppressed.extend(coverage_suppressed)

    # RCH-1: a capability/service package no composition root imports.
    # Registry-suppressible like every other rule, so the eleven the refactor
    # left unreached are debt with an expiry rather than an invisible default.
    reachability, reachability_suppressed = apply_exceptions(
        check_reachability(modules), dry_entries, today=today
    )
    suppressed.extend(reachability_suppressed)

    all_entries = (*archcheck_result.exceptions, *dry_entries)
    all_suppressed = (*archcheck_result.suppressed, *suppressed)
    expiry = build_expiry_report(
        all_entries,
        all_suppressed,
        today=today,
        horizon_days=config.expiry_horizon_days,
    )

    rule_ids = tuple(
        rule.id
        for rule in (*config.single_source_rules, *config.single_definition_rules)
    ) + ("GLB-1",)

    return GateResult(
        config=config,
        archcheck=archcheck_result,
        integration_violations=integrations,
        integration_adapters=integration_map.entries,
        dry_violations=tuple(active),
        export_coverage_violations=tuple(coverage),
        reachability_violations=tuple(reachability),
        dry_suppressed=tuple(suppressed),
        dry_exceptions=dry_entries,
        dry_rule_ids=rule_ids,
        expiry=expiry,
        hygiene_violations=tuple(check_registry_hygiene(all_entries)),
        strict_hygiene=strict_hygiene,
    )