Skip to content

refactor(topology): classify structural gates as blocking vs advisory (#856) - #875

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/topology-gates-856
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/topology-gates-856

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

Classify each topology/layering structural check as blocking architectural boundary, advisory placement hygiene, or generated-doc freshness. Keep blocking checks limited to durable architecture contracts.

Problem

Topology/source structural checks were useful only when protecting real architectural boundaries. Without explicit classification, advisory placement output risked being counted as serious verification evidence.

Solution

Classification of each gate

Gate Classification Rationale
verify-topology orphans Blocking File exists but not declared — structural tracking gap
verify-topology missing Blocking Declared file doesn't exist — stale manifest
verify-topology conflicts Blocking Duplicate declarations — manifest consistency
verify-topology kernel_rule Blocking Root-kernel boundary violation
verify-topology TBD Advisory Unresolved placement cells (blocking only with --strict-tbd)
verify-layering Blocking Substrate-vs-surface import boundary is a real architecture contract
verify-cluster-cohesion Advisory Proposed cluster quality, not in default verify
verify-cross-cuts Advisory Tag naming consistency, not in default verify
render-topology-status Freshness Generated doc, checked via render-all --check
build-topology-projection Navigator Codebase navigator, not a check at all

blob_gc.py resolution

polylogue/storage/blob_gc.py is already resolved: owner: storage-root with concrete target polylogue/storage/blob_gc.py. Zero TBD cells in the current projection. This acceptance criterion was already satisfied by the current topology-target.yaml.

Key decisions

  • verify-topology continues to fail only on orphans/missing/conflicts/kernel_rule — not on exact placement drift. This matches the "only fail on missing/orphaned/root-kernel violations" guidance.
  • verify-layering remains blocking — the substrate-vs-surface import boundary is real.
  • Source/provider behavior concerns stay in parser/source tests; topology only tracks placement.

Verification

$ devtools verify-topology --json
{"blocking":false,"counts":{"orphans":0,"missing":0,"conflicts":0,"kernel_rule":0,"tbd":0},...}

$ devtools verify-layering --json  
{"violations":[],"count":0}

$ devtools render-all --check
# all generated surfaces in sync

$ pytest tests/unit/devtools/test_topology_gates.py tests/unit/devtools/test_topology_projection_witness.py tests/unit/devtools/test_render_topology_status.py tests/unit/devtools/test_verify_cross_cuts.py -q
32 passed

$ devtools verify --quick
# all checks passed

Closes #856.

Classify each topology/layering structural check as blocking
architectural boundary, advisory placement hygiene, or
generated-doc freshness. Keep blocking checks limited to
durable architecture contracts: orphans, missing, conflicts,
kernel-rule in verify-topology, and import-boundary violations
in verify-layering. TBD placement cells stay warning-only
(blocking only with --strict-tbd).

blob_gc.py is already resolved (owner: storage-root, concrete
target) — no longer TBD anywhere.

Add tests for the chosen blocking/advisory classification
covering all five finding classes and layering enforcement.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 10 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f4e1f17f-12e3-4826-97b8-f2088aee1db2

📥 Commits

Reviewing files that changed from the base of the PR and between 09b5e90 and 14aa035.

📒 Files selected for processing (5)
  • devtools/build_topology_projection.py
  • devtools/render_topology_status.py
  • devtools/verify_layering.py
  • devtools/verify_topology.py
  • tests/unit/devtools/test_topology_gates.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/topology-gates-856

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit 3d50e55 into master May 7, 2026
2 checks passed
Copilot AI review requested due to automatic review settings May 7, 2026 06:00
@Sinity
Sinity deleted the feature/refactor/topology-gates-856 branch May 7, 2026 06:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR formalizes the intended “gate classification” semantics for topology/layering tooling: which checks are blocking architectural contracts vs advisory hygiene vs generated-doc freshness/navigation.

Changes:

  • Document verify-topology as blocking on orphans/missing/conflicts/kernel_rule, with TBD treated as advisory unless --strict-tbd.
  • Document verify-layering as a blocking architectural boundary (import layering rules).
  • Add unit tests intended to validate blocking vs advisory behavior for topology (and partially for layering helpers).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/unit/devtools/test_topology_gates.py Adds tests around verify-topology blocking/advisory behavior and some layering helper assertions.
devtools/verify_topology.py Updates module documentation to explicitly classify blocking vs advisory findings and exit semantics.
devtools/verify_layering.py Updates module documentation to describe the layering gate as a blocking architectural boundary.
devtools/render_topology_status.py Updates module documentation to classify the rendered dashboard as a generated-doc freshness/navigation artifact.
devtools/build_topology_projection.py Updates module documentation to clarify projection output as navigation, not proof.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +7
Enforces the substrate-vs-surface import boundary: substrate packages
(storage, pipeline, sources, insights) must not import surface adapters
(cli, mcp, daemon, ui, rendering). This is a durable architecture contract,

This is a navigation/advisory artifact, not a blocking architectural gate.
The underlying structural contracts are enforced by ``verify-topology``
(orphans, missing, kernel-rule) and ``verify-layering`` (import-boundary).
tbd — projection cells still marked TBD
(blocking only with --strict-tbd)

Exits 0 if everything passes, 1 if any blocking finding.
Comment on lines +202 to +210
def test_layering_no_violations_passes(tmp_path: Path) -> None:
storage = tmp_path / "polylogue" / "storage"
storage.mkdir(parents=True, exist_ok=True)
(storage / "module.py").write_text("import os\nfrom polylogue.core import json\n", encoding="utf-8")

imports = verify_layering._collect_imports(storage, repo_root=tmp_path)
assert "polylogue.cli" not in imports.get("polylogue/storage/module.py", set())


Comment on lines +211 to +248
def test_layering_disallow_violation_detected(tmp_path: Path) -> None:
storage = tmp_path / "polylogue" / "storage"
storage.mkdir(parents=True, exist_ok=True)
(storage / "bad_importer.py").write_text("from polylogue.cli import click_app\n", encoding="utf-8")

cli = tmp_path / "polylogue" / "cli"
cli.mkdir(parents=True, exist_ok=True)
(cli / "click_app.py").write_text("", encoding="utf-8")

imports = verify_layering._collect_imports(storage, repo_root=tmp_path)
# from polylogue.cli import click_app -> module = "polylogue.cli"
assert "polylogue.cli" in imports.get("polylogue/storage/bad_importer.py", set()), "storage imports cli module"

rules: list[dict[str, Any]] = [
{
"target": "polylogue/storage",
"description": "Storage substrate.",
"disallow": {
"from": ["polylogue/cli", "polylogue/mcp", "polylogue/daemon", "polylogue/ui", "polylogue/rendering"]
},
}
]

violations: list[dict[str, object]] = []
for rule in rules:
target = str(rule["target"])
target_dir = tmp_path / target
disallow_from = list(rule.get("disallow", {}).get("from", []))
file_imports = verify_layering._collect_imports(target_dir, repo_root=tmp_path)
for file_rel, file_imports_set in file_imports.items():
for imp in file_imports_set:
if not imp.startswith("polylogue"):
continue
for disallowed in disallow_from:
if verify_layering._package_matches(str(disallowed), imp):
violations.append({"file": file_rel, "import": imp, "disallowed": disallowed})

assert len(violations) >= 1, "storage importing cli should produce violation"
Sinity added a commit that referenced this pull request May 7, 2026
Closes #856. Topology / layering gates were undifferentiated:
advisory placement output could be counted as serious
verification evidence, blurring the line between durable
architecture and bookkeeping hygiene.

- Blocking gates: `verify-topology` orphans, missing,
  conflicts, kernel_rule; `verify-layering` substrate-vs-
  surface boundary.
- Advisory gates: `verify-topology` TBD (blocking only with
  `--strict-tbd`); `verify-cluster-cohesion`;
  `verify-cross-cuts`. Not in default verify.
- Generated freshness: `render-topology-status` checked via
  `render-all --check`.
- Navigator (not a check): `build-topology-projection`.
- 13 new tests in `tests/unit/devtools/test_topology_gates.py`
  pin the classifications so future edits cannot promote an
  advisory check into a blocker silently.
- `polylogue/storage/blob_gc.py`: confirmed already resolved
  (`owner: storage-root`, target `polylogue/storage/blob_gc.py`).

Closes #856
Sinity added a commit that referenced this pull request May 7, 2026
Closes #856. Topology / layering gates were undifferentiated:
advisory placement output could be counted as serious
verification evidence, blurring the line between durable
architecture and bookkeeping hygiene.

- Blocking gates: `verify-topology` orphans, missing,
  conflicts, kernel_rule; `verify-layering` substrate-vs-
  surface boundary.
- Advisory gates: `verify-topology` TBD (blocking only with
  `--strict-tbd`); `verify-cluster-cohesion`;
  `verify-cross-cuts`. Not in default verify.
- Generated freshness: `render-topology-status` checked via
  `render-all --check`.
- Navigator (not a check): `build-topology-projection`.
- 13 new tests in `tests/unit/devtools/test_topology_gates.py`
  pin the classifications so future edits cannot promote an
  advisory check into a blocker silently.
- `polylogue/storage/blob_gc.py`: confirmed already resolved
  (`owner: storage-root`, target `polylogue/storage/blob_gc.py`).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(topology): keep structural gates at architectural boundaries

2 participants