Skip to content

feat(devtools): make architectural cohesion executable #429

Closed

Description

@Sinity

Parent

Part of #401. Companion to the seven structural-cohesion topology refactors (#403, #413, #414, #419, #420, #424, #425, #426) and the architecture docs refresh (#427).

Problem

The topology refactors share a hidden weakness: every one of them carries acceptance criteria of the form "subpackage layout is obvious," "no compatibility re-exports survive," "future contributor can place a module deterministically." These criteria are observational — they only become true after the change, can only be checked by human review, and silently rot as the tree drifts.

The same proof kernel and obligation routing that turned behavioral claims into CI-checkable evidence (polylogue/proof/, devtools affected-obligations) can do the same for structural claims. We just need to encode the layout as a first-class subject and write the runners.

Target shape

Treat the realized package tree as a verifiable artifact:

  1. A single source of truth for placement: docs/plans/topology-target.yaml lists every polylogue/**/*.py with its current path, target path under the proposed layout, owning issue, and cross-cut tags (read/write, runtime/model, async/sync, surface family).

  2. Two new devtools commands that read the YAML and check the realized tree:

    • devtools verify-topology — orphans (file not declared), conflicts (claimed twice), kernel-rule violations, compatibility-shim TTLs.
    • devtools verify-cluster-cohesion — for each declared subpackage, builds the import graph using stdlib ast, flags cross-cluster imports that bypass __init__.py, detects cycles between clusters, emits a per-cluster cohesion grade. Catches bad cuts before the move.
  3. Tests that fail today, pass post-refactor: tests/unit/scenarios/test_topology_invariants.py (or similar) encodes target-state invariants as @pytest.mark.xfail(strict=True) until the refactor lands. Each topology PR drops one xfail. Concrete done-detector lives in test code.

  4. Topology obligation family in polylogue/proof/catalog.py: topology.kernel_rule_holds, topology.cluster_cohesion_holds, topology.no_orphan_modules. Wires the YAML check into devtools affected-obligations so changes to polylogue/lib/query_runtime.py name the topology obligations they affect.

  5. Generated drift dashboard: docs/topology-status.md rendered by devtools render-all from the YAML + the realized tree. Lists current placement matrix, % migrated per cluster, outstanding orphans/conflicts. Becomes a living view of refactor progress, sibling to chore: track post-renewal consolidation and architectural cohesion #401's issue-to-capability matrix.

Why this matters

  • Issue acceptance becomes one line: every topology issue replaces its observational criterion with devtools verify-topology exits 0 against the cells I own. "Done" is testable.
  • Cross-issue conflicts surface immediately: if refactor: rationalize product ownership and package boundary #414 and refactor: rationalize package-root layout and consolidate facade surface #426 both claim sync_product_queries.py, the YAML diff catches it the moment both PRs touch the same row.
  • Bad cuts caught before code movement: the cluster-cohesion check answers "would lib/query/ actually be cohesive?" without anyone moving a file.
  • Drift becomes auditable: post-merge, any commit that adds a file at polylogue/ root violating the kernel rule, or imports across cluster boundaries through internals, fails CI. The cohesion holds without continuous human attention.
  • Pattern is general: the same machinery makes any architectural claim testable — public-API declarations, layering rules, naming conventions, file-size budgets. This issue establishes the pattern; future work reuses it.

Scope

Phase 1 — projection + lint (this issue, single PR if practical)

Phase 2 — proof obligation family (follow-up)

  • Add topology.* obligation family to polylogue/proof/catalog.py.
  • Register topology runners that reuse the verify-topology and verify-cluster-cohesion logic.
  • Wire devtools affected-obligations so polylogue/**/*.py paths route to topology obligations.
  • Update docs/verification-catalog.md.

Phase 3 — drift dashboard (follow-up)

  • Add devtools render-topology-status that emits docs/topology-status.md.
  • Wire into devtools render-all.
  • Acceptance: rendered doc is checked-in and updates automatically as the refactors progress.

Acceptance criteria

Phase 1:

Phase 2: topology.* obligations are in the verification catalog and route via devtools affected-obligations.

Phase 3: docs/topology-status.md is rendered, checked, and updated by devtools render-all.

Verification

devtools verify-topology is itself a runnable demonstration. The artifact validates itself.

Related

Status (2026-04-26)

Five of six target deliverables shipped:

  • ✅ docs/plans/topology-target.yaml — 640 cells declared
  • ✅ devtools verify-topology — runs in verify --quick
  • ✅ devtools verify-cluster-cohesion — runs, reports cycles
  • ✅ tests/unit/architecture/test_topology_invariants.py — 13 xfails
  • ✅ docs/topology-status.md — drift dashboard rendered by devtools render-topology-status
  • ❌ Topology obligation family in polylogue/proof/catalog.py — topology.kernel_rule_holds, topology.cluster_cohesion_holds, topology.no_orphan_modules not yet defined; structural failures still surface as raw lint output rather than routed obligations

The remaining work blocks #427 (architecture docs refresh) and #433 (layering rules), both of which expect structural claims to be first-class obligations. Closing #429 is gated on landing item 4.

Suggested dashboard improvement

docs/topology-status.md per-issue table reports Cells / At target / Pending / Conflicts. Adding a TBD column would surface unowned-cell coverage at the per-issue level — currently 39 TBD rows are visible only in the global summary, which hides the #420/#431-style "no cells declared" gap.

Cross-reference: holistic assurance umbrella

Filed 2026-04-27. This issue is part of the holistic assurance coverage map (#506) which restructures verifiability work around four tracks (stop lying / coverage map / routing-proof-pack / product confidence) and introduces an Oracle primitive (#507), declarative coverage manifests (#508 assurance-domains, #509 oracle-quality), and operator-facing proof packs (#510).

Read in conjunction with #506 to see how this issue fits into the broader confidence model.

Activity

  1. added
    type:feat
    type:tracking
    theme:verifiability
    phase:architecture
    area:devtools
    on Apr 26, 2026
  2. 9 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:devtoolsphase:architecturetheme:verifiabilitytype:feattype:tracking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions