Repository navigation
Description
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:
-
A single source of truth for placement:
docs/plans/topology-target.yamllists everypolylogue/**/*.pywith its current path, target path under the proposed layout, owning issue, and cross-cut tags (read/write, runtime/model, async/sync, surface family). -
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 stdlibast, flags cross-cluster imports that bypass__init__.py, detects cycles between clusters, emits a per-cluster cohesion grade. Catches bad cuts before the move.
-
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. -
Topology obligation family in
polylogue/proof/catalog.py:topology.kernel_rule_holds,topology.cluster_cohesion_holds,topology.no_orphan_modules. Wires the YAML check intodevtools affected-obligationsso changes topolylogue/lib/query_runtime.pyname the topology obligations they affect. -
Generated drift dashboard:
docs/topology-status.mdrendered bydevtools render-allfrom 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-topologyexits 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)
- Build
docs/plans/topology-target.yamlcovering everypolylogue/**/*.py(~640 files). Cells driven by the seven topology issues. - Build
devtools/verify_topology.py(~200 LOC). Wired intodevtools verify --quick. - Build
devtools/verify_cluster_cohesion.py(~150 LOC). Wired intodevtools verify(full). - Add starter
tests/unit/.../test_topology_invariants.pywith xfail markers for the major refactors. - Update each of refactor: rationalize source and test module structure #403, refactor: rationalize product ownership and package boundary #414, refactor(tests): split oversized contract suites #419, refactor(schemas): group schema generation and inference modules #420, refactor(lib): group lib by domain cluster #424, refactor(storage): group storage by ownership domain #425, refactor: rationalize package-root layout and consolidate facade surface #426 to add "
devtools verify-topologyexits 0 against my YAML cells" as acceptance.
Phase 2 — proof obligation family (follow-up)
- Add
topology.*obligation family topolylogue/proof/catalog.py. - Register topology runners that reuse the verify-topology and verify-cluster-cohesion logic.
- Wire
devtools affected-obligationssopolylogue/**/*.pypaths route to topology obligations. - Update
docs/verification-catalog.md.
Phase 3 — drift dashboard (follow-up)
- Add
devtools render-topology-statusthat emitsdocs/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:
docs/plans/topology-target.yamlexists, covers everypolylogue/**/*.py, and is referenced from the seven topology issues.devtools verify-topologyexists, runs in under 5 seconds against the current tree, reports orphans/conflicts/kernel-violations/shim-TTLs, and is wired intodevtools verify --quick.devtools verify-cluster-cohesionexists, runs against the YAML, reports cross-cluster imports through internals + cycles, and is wired intodevtools verify(full).- At least one xfail test per major refactor encodes the post-state invariant.
- Each of refactor: rationalize source and test module structure #403, refactor: rationalize product ownership and package boundary #414, refactor(tests): split oversized contract suites #419, refactor(schemas): group schema generation and inference modules #420, refactor(lib): group lib by domain cluster #424, refactor(storage): group storage by ownership domain #425, refactor: rationalize package-root layout and consolidate facade surface #426 has acceptance criteria referencing the YAML and the lint commands.
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
- chore: track post-renewal consolidation and architectural cohesion #401 — post-renewal consolidation umbrella.
- refactor: rationalize source and test module structure #403, refactor: retire public audit qa showcase surfaces #413, refactor: rationalize product ownership and package boundary #414, refactor(tests): split oversized contract suites #419, refactor(schemas): group schema generation and inference modules #420, refactor(lib): group lib by domain cluster #424, refactor(storage): group storage by ownership domain #425, refactor: rationalize package-root layout and consolidate facade surface #426 — the topology refactors whose acceptance becomes machine-checked.
- docs(architecture): refresh placement rules and document cross-cuts #427 — architecture docs refresh; the YAML + dashboard are the artifacts the docs point at.
- feat(proof): add product-surface obligation families #421 — product-surface obligation families; topology obligations follow that pattern.
- test(proof): route maintained surfaces to affected obligations #397 — affected-obligation routing for non-Python surfaces; topology paths get the same treatment.
Status (2026-04-26)
Five of six target deliverables shipped:
- ✅
docs/plans/topology-target.yaml— 640 cells declared - ✅
devtools verify-topology— runs inverify --quick - ✅
devtools verify-cluster-cohesion— runs, reports cycles - ✅
tests/unit/architecture/test_topology_invariants.py— 13 xfails - ✅
docs/topology-status.md— drift dashboard rendered bydevtools render-topology-status - ❌ Topology obligation family in
polylogue/proof/catalog.py—topology.kernel_rule_holds,topology.cluster_cohesion_holds,topology.no_orphan_modulesnot 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
feat(devtools): make architectural cohesion executable (Phase 1 of #429…
feat(devtools): file-size budgets per package and module
feat(devtools): file-size budgets per package and module
feat(devtools): test-ownership manifest with import-resolution
feat(devtools): file-size budgets per package and module
feat(devtools): test-ownership manifest with import-resolution
feat(devtools): migration-completeness manifest
feat(devtools): file-size budgets per package and module (#442)
feat(devtools): test-ownership manifest with import-resolution
feat(devtools): test-ownership manifest with import-resolution (#450)
9 remaining items
chore(topology): resolve projection TBDs, conflicts, and missing rules (
feat(devtools): inter-package layering rules and refreshed placement …
feat(devtools): make architectural cohesion executable (Phase 1 of #429…
feat(devtools): file-size budgets per package and module (#442)
feat(devtools): test-ownership manifest with import-resolution (#450)
feat(devtools): migration-completeness manifest (#451)
chore: delete one orphan re-export shim (#452)
fix(devtools): topology projection avoids __init__.py target collisio…
feat(devtools): topology drift dashboard (#455)
feat(devtools): verify-cross-cuts lint (Phase 1 of #432) (#457)
fix(pipeline): invert embed dependency, pipeline imports substrate no…
chore(topology): resolve projection TBDs, conflicts, and missing rules (
feat(devtools): inter-package layering rules and refreshed placement …
feat(devtools): obligation-diff command and finalize verifiability ar…