Repository navigation
Description
Parent
Part of #401. Companion to #429 (executable topology) and #432 (cross-cut manifest). Generalizes the cycle-detection signal from #430/#431.
Problem
devtools verify-cluster-cohesion (per #429) flags cycles between proposed clusters, which surfaces violations like #430 (pipeline → cli) and #431 (cli/commands ↔ cli). But cycle-detection is symmetric: it can't distinguish "surface imports substrate" (allowed) from "substrate imports surface" (forbidden). The architecture doc has a directed layering rule — substrate → products → surfaces is allowed; the reverse is not — but no lint enforces it.
Without an explicit layering manifest, every new cycle-violation needs a human to read it and decide which direction is "wrong." That decision should be encoded once and checked on every commit.
Target
Declare allowed inter-package edges as a YAML graph and lint imports against it.
# docs/plans/layering-rules.yaml
layers:
substrate:
packages: [lib, sources, pipeline, storage, schemas]
products:
packages: [products]
may_import: [substrate]
surfaces:
packages: [cli, mcp, site, rendering, ui, browser_capture, api]
may_import: [substrate, products]
verification:
packages: [proof, scenarios, showcase, devtools]
may_import: [substrate, products, surfaces] # verification reads everything
exceptions:
- from: pipeline
to: cli
reason: "tracked by #430; remove after pipeline → lib/embeddings/ move"
until: "#430"
- from: cli/commands
to: cli
reason: "tracked by #431; remove after shared-helper subpackage lands"
until: "#431"devtools verify-layering walks every polylogue/**/*.py, builds the import graph, and asserts each edge is allowed by the rules. Exceptions are tracked with the issue that's removing them; when the issue closes, the exception's lint run fails until the exception is removed.
Why this is higher-leverage than ad-hoc cycle hunting
- Direction-aware: a cycle isn't always wrong; a layering violation always is.
- Forward-looking: catches future violations on the first commit, not after a refactor.
- Documented invariant:
docs/architecture.mdsays "substrate → surfaces"; the YAML makes that statement executable. - Drives smaller refactors: each tracked exception (with
until: #NNN) becomes a small focused PR. Layering rules turnverify-layeringinto a TODO list that depletes as exceptions close.
Scope
Phase 1 — manifest + lint (this issue)
- Author
docs/plans/layering-rules.yamlwith the layer hierarchy and current exceptions (start by enumerating real violations fromverify-cluster-cohesionoutput). - Build
devtools/verify_layering.py(~120 LOC) that loads the YAML, walks imports, and reports forbidden edges + stale exceptions. - Wire into
devtools verify --quick. - Document the layer hierarchy in
docs/architecture.mdper docs(architecture): refresh placement rules and document cross-cuts #427.
Phase 2 — cross-cut tags (overlap with #432)
The same YAML can carry the cross-cut axis (api: sync|async, layer: read|write) for #432's cross-cut manifest. Decide whether to merge into one file (docs/plans/architecture-rules.yaml) or keep separate (layering-rules.yaml + cross-cuts.yaml).
Phase 3 — proof obligation
Register architecture.layering_holds, architecture.no_stale_exceptions as proof obligations under #432's umbrella so layering becomes first-class evidence.
Acceptance criteria
Phase 1:
docs/plans/layering-rules.yamlexists with the documented hierarchy.devtools verify-layeringexits 0 against the realized tree (with current exceptions accepted as tracked).- Each tracked exception names an issue (
until: #NNN); closed-issue exceptions fail the lint. docs/architecture.mddocuments the hierarchy.
Phase 2:
- Cross-cut tags from feat(devtools): evidence-driven structural specification — cross-cut manifest, witness, dashboard #432 land in the same YAML or a sibling, decided during this work.
Phase 3:
- Layering obligations appear in the verification catalog and route via
devtools affected-obligations.
Pattern reuse
The shape — declarative YAML + lint + tracked exceptions with sunset issues — is the same shape as #429 (topology projection) and #432 (cross-cut manifest). This issue applies the pattern to the directional dimension that those don't capture.
Combined, the three issues give Polylogue four kinds of evidence-driven structural specification:
- Placement (feat(devtools): make architectural cohesion executable #429): every file is at a known target path.
- Cohesion (feat(devtools): make architectural cohesion executable #429 cluster check): proposed subpackages don't have cross-cluster cycles.
- Layering (this issue): inter-package imports respect a directed hierarchy.
- Cross-cut (feat(devtools): evidence-driven structural specification — cross-cut manifest, witness, dashboard #432): modules respect axis tags (read/write, async/sync, etc.).
Related
- feat(devtools): make architectural cohesion executable #429 — executable topology (placement + cohesion).
- feat(devtools): evidence-driven structural specification — cross-cut manifest, witness, dashboard #432 — cross-cut manifest + drift dashboard (feat(devtools): evidence-driven structural specification — cross-cut manifest, witness, dashboard #432 may absorb this issue's Phase 2/3).
- fix(pipeline): pipeline imports cli/ — invert dependency #430 — concrete layering exception (pipeline → cli).
- refactor(cli): factor shared helpers so cli/commands/ has a cohesive boundary #431 — concrete layering exception (cli/commands → cli).
- docs(architecture): refresh placement rules and document cross-cuts #427 — architecture docs refresh; layering hierarchy is documented there.
- chore: track post-renewal consolidation and architectural cohesion #401 — post-renewal consolidation umbrella.
Sequencing
Blocked by #429 item 4 (topology obligation family in polylogue/proof/catalog.py). Without obligations, layering violations surface as raw lint output and cannot be routed through devtools affected-obligations — which defeats the point of declaring layering as first-class evidence.
Order of operations:
- feat(devtools): make architectural cohesion executable #429 item 4 lands —
topology.kernel_rule_holdsetc. exist as obligations. - feat(devtools): evidence-driven structural specification — cross-cut manifest, witness, dashboard #432 lands — cross-cut tag coverage reaches the threshold needed for layering rules to reference cross-cut metadata (sync vs async, surface family) when the package alone is ambiguous.
- This issue lands —
docs/plans/layering-rules.yamlplusdevtools verify-layering-rulesplus alayering.no_inverted_edgesobligation family.
Until #429 item 4 closes, this issue is phase-3 work and should not be picked up.
Acceptance (executable)
devtools verify-layering-rules # 0 inverted edges
devtools affected-obligations <changed-files> # layering obligations route correctly
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): verify-cross-cuts lint (Phase 1 of #432) (#457)
feat(devtools): make architectural cohesion executable (Phase 1 of #429…
feat(devtools): verify-cross-cuts lint (Phase 1 of #432) (#457)
feat(devtools): inter-package layering rules and refreshed placement …