Skip to content

feat(devtools): topology drift dashboard - #455

Merged
Sinity merged 3 commits into
masterfrom
feature/feat/topology-status-dashboard
Apr 26, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/feat/topology-status-dashboard

Conversation

@Sinity

@Sinity Sinity commented Apr 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Phase 3 of #429. Renders docs/topology-status.md from the topology projection (docs/plans/topology-target.yaml) plus the realized polylogue/ tree. The dashboard is checked-in markdown so structural-cohesion progress is visible to anyone reading docs, not just to those who run lints locally.

Problem

After Phase 1 of #429 landed (devtools verify-topology lint, plus xfail tests), structural drift was checkable only via local commands. Outsiders looking at the architecture-cohesion track had no single artifact telling them "of the seven topology refactors, here's how far each has gotten."

Solution

devtools render-topology-status builds a per-issue dashboard table:

| Issue | Title | Cells | At target | Pending | Conflicts |
| --- | --- | --: | --: | --: | --: |
| #403 | rationalize source and test module structure | 16 | 0 | 16 | 0 |
| #414 | rationalize product ownership and package boundary | 8 | 0 | 8 | 0 |
| #424 | group lib by domain cluster | 57 | 0 | 57 | 8 |
| #425 | group storage by ownership domain | 63 | 0 | 63 | 4 |
| #426 | rationalize package-root layout and consolidate facade surface | 15 | 0 | 15 | 0 |

Plus summary counts (stable / kernel / primitives / TBD) and the explicit TBD list.

Wired into devtools render-all as a generated surface — drift fails render-all --check. Each refactor PR updates the dashboard automatically as cells move.

Verification

$ devtools render-topology-status
$ devtools render-all --check
render-all: check topology-status
  ... sync OK

$ devtools verify --quick
verify: all checks passed (incl. all 8 lints)

Coordinates with

Pattern complete for #429:

  1. Phase 1 (PR feat(devtools): make architectural cohesion executable (Phase 1 of #429) #438): projection + lints + xfail tests.
  2. Phase 2: topology obligation family in polylogue/proof/catalog.py (still pending).
  3. Phase 3 (this PR): drift dashboard.

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added devtools render-topology-status CLI command to generate topology status dashboard.
    • Topology status dashboard displays per-issue migration progress, cell counts, target status, and conflict detection.
    • Dashboard automatically renders from target configuration and project codebase.
  • Tests

    • Resolved previously failing topology status documentation test.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Apr 26, 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 55 minutes and 19 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 19 seconds.

⌛ 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: 3262a0fc-bca8-4c20-914d-f35d8b2cb599

📥 Commits

Reviewing files that changed from the base of the PR and between 507f783 and 6828c33.

📒 Files selected for processing (6)
  • devtools/command_catalog.py
  • devtools/generated_surfaces.py
  • devtools/render_topology_status.py
  • docs/devtools.md
  • docs/topology-status.md
  • tests/unit/architecture/test_topology_invariants.py
📝 Walkthrough

Walkthrough

This PR introduces a new render-topology-status devtools CLI command and generated surface that reads the topology projection YAML and inspects the realized Python tree to generate a markdown dashboard (docs/topology-status.md) summarizing per-issue migration progress with cell counts and a drift table.

Changes

Cohort / File(s) Summary
CLI Registration
devtools/command_catalog.py, devtools/generated_surfaces.py
Registers the new render-topology-status command in the command catalog and adds it as a generated surface that invokes the command and renders the topology status markdown output.
Core Implementation
devtools/render_topology_status.py
Introduces a new module with functions to read the topology projection YAML, traverse realized Python files, compute per-issue migration metrics (Stable/Kernel/Primitives/TBD cells, conflicts), render a markdown dashboard, and support --check mode for validation.
Documentation and Output
docs/devtools.md, docs/topology-status.md
Adds command documentation and generates the initial topology status dashboard with per-issue tables, aggregated summary counts, and TBD cell listings.
Test Updates
tests/unit/architecture/test_topology_invariants.py
Removes the xfail marker from test_topology_status_doc_rendered, marking the drift dashboard rendering as now passing.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as DevTools CLI
    participant Cmd as render-topology-status
    participant TopologyFile as topology-target.yaml
    participant FileSystem as Realized Tree<br/>(polylogue/*.py)
    participant Renderer as Dashboard Renderer
    participant Output as topology-status.md

    CLI->>Cmd: invoke with --check flag
    Cmd->>TopologyFile: read topology projection
    TopologyFile-->>Cmd: YAML structure with issues & targets
    Cmd->>FileSystem: scan realized Python files
    FileSystem-->>Cmd: set of realized file paths
    Cmd->>Renderer: process rows with topology data
    Renderer->>Renderer: compute per-issue metrics<br/>(cells, conflicts, pending)
    Renderer-->>Cmd: rendered markdown body
    Cmd->>Output: write dashboard with markers
    Output-->>Cmd: write complete
    alt --check mode
        Cmd->>Output: compare existing vs rendered
        alt mismatch or missing header
            Cmd-->>CLI: return error code
        else content matches
            Cmd-->>CLI: return success
        end
    else normal mode
        Cmd-->>CLI: return success
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

type:feat, area:cli, area:docs, area:qa

Poem

🐰 A rabbit hops through topology's maze,
Rendering dashboards in purple haze,
Mapping what's stable, what's pending, what's lost,
Counting the cells and computing the cost! 📊✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: introducing a topology drift dashboard for devtools, which is the core objective of this PR.
Description check ✅ Passed The description comprehensively follows the template with all required sections filled: Summary, Problem, Solution, and Verification. It includes concrete examples and context.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/topology-status-dashboard

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 added a commit that referenced this pull request Apr 26, 2026
…ns (#456)

## Summary

Fixes a projection-rule defect surfaced by the topology-status dashboard
(PR #455). The rule was emitting `__init__.py` for any module whose name
equaled the subpackage prefix exactly, which caused multiple modules to
claim the same destination — 12 false-conflict rows in the dashboard.

## Problem

`build_topology_projection.py:lib_target()` and `storage_target()` use a
strip-prefix-then-stem rule. When the stem strips empty (e.g. module
`session_payload` matches prefix `session_payload`), the rule defaulted
to `__init__.py`. Two such modules in the same cluster collide:

- `lib/session/__init__.py` claimed by `session_payload`,
`session_summaries`, `session_profile`
- `storage/runtime/__init__.py` claimed by `store_runtime` (the
catch-all prefix)

`devtools verify-topology` reports `conflicts: 12` and the dashboard
shows them in its conflicts column.

## Solution

New resolver:

```python
def _resolve_target(name: str, sub: str, prefix: str) -> str:
    stem = name[len(prefix):]
    if not stem:
        # Module name == prefix; preserve full name to avoid colliding at __init__.py.
        return f"polylogue/{sub}{name}"
    if not stem.endswith(".py"):
        stem = stem + ".py"
    stem = stem.lstrip("_")
    if not stem or stem == ".py":
        return f"polylogue/{sub}{name}"
    return f"polylogue/{sub}{stem}"
```

After regen: `verify-topology --json` reports `conflicts: 0`. Dashboard
column will read 0 once this and #455 are both merged.

## Verification

```
$ devtools build-topology-projection
$ devtools verify-topology --json | jq '.counts'
{"orphans": 0, "missing": 0, "conflicts": 0, "kernel_rule": 0, "tbd": 39}

$ devtools verify --quick
verify: all checks passed (incl. all 8 lints)
```

## Related

- #429 — projection lint pattern.
- #455 — topology drift dashboard (sibling PR; conflicts column will
read 0 after both merge).
- #424 / #425 — refactors that consume the projection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sinity and others added 3 commits April 26, 2026 14:51
Phase 3 of #429.

- devtools/render_topology_status.py: renders docs/topology-status.md
  from docs/plans/topology-target.yaml plus the realized polylogue/ tree.
- Wired into devtools render-all so drift fails the generated-surface
  check.
- docs/topology-status.md: checked-in dashboard with per-issue migration
  progress (cells, at-target, pending, conflicts), summary counts
  (stable / kernel / primitives / TBD), and the explicit TBD list.

The dashboard makes structural-cohesion progress visible in the
maintainer-facing docs without requiring anyone to run a lint locally.
Each refactor PR (#403 / #413 / #414 / #420 / #424 / #425 / #426)
updates this dashboard automatically as cells move.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The dashboard now exists (rendered by render_topology_status.py in this
PR), so the xfail flips to UNEXPECTED PASS in CI strict mode. Convert to
a regular assert as the pattern dictates: each topology refactor's
xfail flips to a normal test in the same PR that lands the refactor.
@Sinity
Sinity force-pushed the feature/feat/topology-status-dashboard branch from 507f783 to 6828c33 Compare April 26, 2026 12:55

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@devtools/render_topology_status.py`:
- Line 105: The Markdown line in the parts.append call that builds the summary
uses `**Realized polylogue/**/*.py**: ...` which produces broken bold runs;
update the string in the parts.append that references realized_targets so the
glob is not inside the bold markers—e.g., move the bolding to just the label and
wrap or escape the glob (use backticks around polylogue/**/*.py or escape the
inner asterisks) so the entire label renders correctly while still including
{len(realized_targets)}.
- Around line 147-160: When running the --check branch (args.check) the current
code uses existing.split(GENERATED_BEGIN, 1)[-1].split(GENERATED_END, 1)[0]
which silently falls back to the whole file if either GENERATED_BEGIN or
GENERATED_END is missing; update the args.check logic to first verify both
GENERATED_BEGIN and GENERATED_END are present in existing (e.g., using "if
GENERATED_BEGIN not in existing or GENERATED_END not in existing"), print a
clear error like "header markers missing" to stderr and return non-zero, and
only then extract existing_body and compare it to body so the failure mode is
actionable (refer to the existing variables args.check, existing,
GENERATED_BEGIN, GENERATED_END, and existing_body).
- Around line 37-68: Replace the duplicated hard-coded membership checks with
the existing NON_OWNER_TAGS constant inside render_dashboard and ensure no rows
are dropped silently by adding an unclassified list (e.g., unclassified:
list[dict[str, object]] = []) and appending any row that doesn't match
NON_OWNER_TAGS, target == "TBD", or owner.startswith("#"); then either include
the unclassified count in the dashboard output or assert that unclassified is
empty before finishing (update references to stable_count, kernel_count,
primitive_count, tbd, and by_owner accordingly).
- Around line 87-93: The current pending/at_target use cell["path"] and
misclassifies deletions and already-at-destination rows; change logic to derive
both from the realized set by checking the cell's target membership in
realized_targets: compute target_str = str(cell.get("target") or "") for each
cell, let at_target = sum(1 for cell in cells if target_str in realized_targets
and target_str) and pending = total - at_target (or explicitly sum of targets
not in realized_targets), replacing the existing pending/at_target lines
(referenced symbols: pending, at_target, realized_targets, cells, total). Also
change conflicts to count distinct duplicated targets by using a set
comprehension (referenced symbols: targets, conflicts) e.g. conflicts = len({t
for t in targets if t and targets.count(t) > 1}).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d09aef0f-963e-4ca1-a9ba-b59a5dc46cf6

📥 Commits

Reviewing files that changed from the base of the PR and between 8fdcb10 and 507f783.

📒 Files selected for processing (6)
  • devtools/command_catalog.py
  • devtools/generated_surfaces.py
  • devtools/render_topology_status.py
  • docs/devtools.md
  • docs/topology-status.md
  • tests/unit/architecture/test_topology_invariants.py

Comment on lines +37 to +68
NON_OWNER_TAGS = {"stable", "kernel", "lib-root", "storage-root"}


def realized_paths() -> set[str]:
return {p.relative_to(ROOT).as_posix() for p in ROOT.glob("polylogue/**/*.py") if "__pycache__" not in p.parts}


def render_dashboard(rows: Iterable[dict[str, object]], realized: set[str]) -> str:
"""Build the dashboard markdown body."""
by_owner: dict[str, list[dict[str, object]]] = defaultdict(list)
tbd: list[dict[str, object]] = []
stable_count = 0
kernel_count = 0
primitive_count = 0

for row in rows:
owner = str(row.get("owner") or "")
target = str(row.get("target") or "")
if owner == "stable":
stable_count += 1
continue
if owner == "kernel":
kernel_count += 1
continue
if owner in {"lib-root", "storage-root"}:
primitive_count += 1
continue
if target == "TBD":
tbd.append(row)
continue
if owner.startswith("#"):
by_owner[owner].append(row)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Dead constant and silently-dropped rows.

Two small hygiene items in the classification loop:

  • NON_OWNER_TAGS = {"stable", "kernel", "lib-root", "storage-root"} (L37) is unused; the loop hard-codes the same membership at L55–63. Either route the checks through the constant or drop it.
  • Any row whose owner is neither in the non-owner tags, nor an issue tag (startswith("#")), nor target == "TBD" is silently discarded. It contributes to none of the per-issue rows, none of the bucket counters, and the Total declared line — so the totals can quietly diverge from the YAML row count without any signal. Consider a final else: unclassified.append(row) branch and either surface the count or assert it's empty.
♻️ Sketch
-NON_OWNER_TAGS = {"stable", "kernel", "lib-root", "storage-root"}
+PRIMITIVE_TAGS = {"lib-root", "storage-root"}
@@
-        if owner == "stable":
+        if owner == "stable":
             stable_count += 1
             continue
         if owner == "kernel":
             kernel_count += 1
             continue
-        if owner in {"lib-root", "storage-root"}:
+        if owner in PRIMITIVE_TAGS:
             primitive_count += 1
             continue
         if target == "TBD":
             tbd.append(row)
             continue
         if owner.startswith("#"):
             by_owner[owner].append(row)
+            continue
+        # Surface anything the projection schema didn't anticipate.
+        unclassified.append(row)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
NON_OWNER_TAGS = {"stable", "kernel", "lib-root", "storage-root"}
def realized_paths() -> set[str]:
return {p.relative_to(ROOT).as_posix() for p in ROOT.glob("polylogue/**/*.py") if "__pycache__" not in p.parts}
def render_dashboard(rows: Iterable[dict[str, object]], realized: set[str]) -> str:
"""Build the dashboard markdown body."""
by_owner: dict[str, list[dict[str, object]]] = defaultdict(list)
tbd: list[dict[str, object]] = []
stable_count = 0
kernel_count = 0
primitive_count = 0
for row in rows:
owner = str(row.get("owner") or "")
target = str(row.get("target") or "")
if owner == "stable":
stable_count += 1
continue
if owner == "kernel":
kernel_count += 1
continue
if owner in {"lib-root", "storage-root"}:
primitive_count += 1
continue
if target == "TBD":
tbd.append(row)
continue
if owner.startswith("#"):
by_owner[owner].append(row)
PRIMITIVE_TAGS = {"lib-root", "storage-root"}
def realized_paths() -> set[str]:
return {p.relative_to(ROOT).as_posix() for p in ROOT.glob("polylogue/**/*.py") if "__pycache__" not in p.parts}
def render_dashboard(rows: Iterable[dict[str, object]], realized: set[str]) -> str:
"""Build the dashboard markdown body."""
by_owner: dict[str, list[dict[str, object]]] = defaultdict(list)
tbd: list[dict[str, object]] = []
stable_count = 0
kernel_count = 0
primitive_count = 0
for row in rows:
owner = str(row.get("owner") or "")
target = str(row.get("target") or "")
if owner == "stable":
stable_count += 1
continue
if owner == "kernel":
kernel_count += 1
continue
if owner in PRIMITIVE_TAGS:
primitive_count += 1
continue
if target == "TBD":
tbd.append(row)
continue
if owner.startswith("#"):
by_owner[owner].append(row)
continue
# Surface anything the projection schema didn't anticipate.
unclassified.append(row)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@devtools/render_topology_status.py` around lines 37 - 68, Replace the
duplicated hard-coded membership checks with the existing NON_OWNER_TAGS
constant inside render_dashboard and ensure no rows are dropped silently by
adding an unclassified list (e.g., unclassified: list[dict[str, object]] = [])
and appending any row that doesn't match NON_OWNER_TAGS, target == "TBD", or
owner.startswith("#"); then either include the unclassified count in the
dashboard output or assert that unclassified is empty before finishing (update
references to stable_count, kernel_count, primitive_count, tbd, and by_owner
accordingly).

Comment on lines +87 to +93
pending = sum(1 for cell in cells if str(cell.get("path")) in realized_targets)
at_target = total - pending
title = ISSUE_TITLES.get(owner, "—")
# Conflicts: rows whose target collides with another row's target.
targets = [str(cell.get("target") or "") for cell in cells]
conflicts = len([t for t in targets if targets.count(t) > 1 and t])
parts.append(f"| {owner} | {title} | {total} | {at_target} | {pending} | {conflicts} |")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

At target / Pending semantics are computed from path, not target.

pending counts cells whose current path is still on disk, and at_target is then derived as total - pending. Two failure modes:

  • A file deleted from the realized tree (no path, no target) is counted as at_target even though no migration occurred.
  • A row where path == target (already at destination, but still owned by an issue) is counted as pending.

For an informational dashboard this is mostly cosmetic, but it can mask real progress and overstate completion late in a migration. Consider deriving both counts directly from the realized set:

🩹 Suggested logic
-        total = len(cells)
-        pending = sum(1 for cell in cells if str(cell.get("path")) in realized_targets)
-        at_target = total - pending
+        total = len(cells)
+        at_target = sum(
+            1 for cell in cells
+            if str(cell.get("target") or "") in realized_targets
+        )
+        pending = sum(
+            1 for cell in cells
+            if str(cell.get("path")) in realized_targets
+            and str(cell.get("path")) != str(cell.get("target") or "")
+        )

Also nit on L92: conflicts = len([t for t in targets if targets.count(t) > 1 and t]) counts cells participating in a conflict (e.g. 3 rows colliding on one target → conflicts = 3), not the number of distinct duplicated targets. If the column is meant to be "how many distinct target collisions exist", swap to len({t for t in targets if t and targets.count(t) > 1}).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@devtools/render_topology_status.py` around lines 87 - 93, The current
pending/at_target use cell["path"] and misclassifies deletions and
already-at-destination rows; change logic to derive both from the realized set
by checking the cell's target membership in realized_targets: compute target_str
= str(cell.get("target") or "") for each cell, let at_target = sum(1 for cell in
cells if target_str in realized_targets and target_str) and pending = total -
at_target (or explicitly sum of targets not in realized_targets), replacing the
existing pending/at_target lines (referenced symbols: pending, at_target,
realized_targets, cells, total). Also change conflicts to count distinct
duplicated targets by using a set comprehension (referenced symbols: targets,
conflicts) e.g. conflicts = len({t for t in targets if t and targets.count(t) >
1}).

parts.append(
f"- **Total declared**: {sum(len(v) for v in by_owner.values()) + stable_count + kernel_count + primitive_count + len(tbd)}"
)
parts.append(f"- **Realized polylogue/**/*.py**: {len(realized_targets)} files declared")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Broken Markdown bold run in the summary line.

**Realized polylogue/**/*.py**: … contains four ** runs on one line. Most renderers parse this as <strong>Realized polylogue/</strong>/*.py**: …, leaving the trailing ** as literal asterisks and dropping the intended bolding of the whole label. You can see the artifact in the generated docs/topology-status.md L27. Escape the inner asterisks (or move them outside the bold span).

🩹 Proposed fix
-    parts.append(f"- **Realized polylogue/**/*.py**: {len(realized_targets)} files declared")
+    parts.append(f"- **Realized `polylogue/**/*.py`**: {len(realized_targets)} files declared")

Backticks contain the glob and prevent the ** runs from being interpreted as bold delimiters; the test regex \b\d+\s+files declared still matches.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
parts.append(f"- **Realized polylogue/**/*.py**: {len(realized_targets)} files declared")
parts.append(f"- **Realized `polylogue/**/*.py`**: {len(realized_targets)} files declared")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@devtools/render_topology_status.py` at line 105, The Markdown line in the
parts.append call that builds the summary uses `**Realized polylogue/**/*.py**:
...` which produces broken bold runs; update the string in the parts.append that
references realized_targets so the glob is not inside the bold markers—e.g.,
move the bolding to just the label and wrap or escape the glob (use backticks
around polylogue/**/*.py or escape the inner asterisks) so the entire label
renders correctly while still including {len(realized_targets)}.

Comment on lines +147 to +160
if args.check:
if not args.output.exists():
print(f"render-topology-status: {args.output} missing", file=sys.stderr)
return 1
existing = args.output.read_text(encoding="utf-8")
expected_header = "# Topology status\n\n"
if expected_header not in existing:
print(f"render-topology-status: {args.output} header missing", file=sys.stderr)
return 1
existing_body = existing.split(GENERATED_BEGIN, 1)[-1].split(GENERATED_END, 1)[0].strip("\n")
if existing_body != body.strip("\n"):
print(f"render-topology-status: {args.output} out of sync", file=sys.stderr)
return 1
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

--check silently degrades when generated markers are missing.

existing.split(GENERATED_BEGIN, 1)[-1].split(GENERATED_END, 1)[0] falls back to the entire file when either marker is absent (split returns a single-element list and [-1] / [0] happily index it). The user then sees the generic "out of sync" message even though the real cause is a malformed/hand-edited file with no markers. Worth an explicit guard so the failure mode is actionable.

🩹 Proposed guard
-        existing_body = existing.split(GENERATED_BEGIN, 1)[-1].split(GENERATED_END, 1)[0].strip("\n")
-        if existing_body != body.strip("\n"):
+        if GENERATED_BEGIN not in existing or GENERATED_END not in existing:
+            print(
+                f"render-topology-status: {args.output} missing generated markers",
+                file=sys.stderr,
+            )
+            return 1
+        existing_body = existing.split(GENERATED_BEGIN, 1)[1].split(GENERATED_END, 1)[0].strip("\n")
+        if existing_body != body.strip("\n"):
             print(f"render-topology-status: {args.output} out of sync", file=sys.stderr)
             return 1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if args.check:
if not args.output.exists():
print(f"render-topology-status: {args.output} missing", file=sys.stderr)
return 1
existing = args.output.read_text(encoding="utf-8")
expected_header = "# Topology status\n\n"
if expected_header not in existing:
print(f"render-topology-status: {args.output} header missing", file=sys.stderr)
return 1
existing_body = existing.split(GENERATED_BEGIN, 1)[-1].split(GENERATED_END, 1)[0].strip("\n")
if existing_body != body.strip("\n"):
print(f"render-topology-status: {args.output} out of sync", file=sys.stderr)
return 1
return 0
if args.check:
if not args.output.exists():
print(f"render-topology-status: {args.output} missing", file=sys.stderr)
return 1
existing = args.output.read_text(encoding="utf-8")
expected_header = "# Topology status\n\n"
if expected_header not in existing:
print(f"render-topology-status: {args.output} header missing", file=sys.stderr)
return 1
if GENERATED_BEGIN not in existing or GENERATED_END not in existing:
print(
f"render-topology-status: {args.output} missing generated markers",
file=sys.stderr,
)
return 1
existing_body = existing.split(GENERATED_BEGIN, 1)[1].split(GENERATED_END, 1)[0].strip("\n")
if existing_body != body.strip("\n"):
print(f"render-topology-status: {args.output} out of sync", file=sys.stderr)
return 1
return 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@devtools/render_topology_status.py` around lines 147 - 160, When running the
--check branch (args.check) the current code uses
existing.split(GENERATED_BEGIN, 1)[-1].split(GENERATED_END, 1)[0] which silently
falls back to the whole file if either GENERATED_BEGIN or GENERATED_END is
missing; update the args.check logic to first verify both GENERATED_BEGIN and
GENERATED_END are present in existing (e.g., using "if GENERATED_BEGIN not in
existing or GENERATED_END not in existing"), print a clear error like "header
markers missing" to stderr and return non-zero, and only then extract
existing_body and compare it to body so the failure mode is actionable (refer to
the existing variables args.check, existing, GENERATED_BEGIN, GENERATED_END, and
existing_body).

@Sinity
Sinity merged commit da7b8f5 into master Apr 26, 2026
13 checks passed
@Sinity
Sinity deleted the feature/feat/topology-status-dashboard branch April 26, 2026 13:15
@Sinity

Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

🤖 Post-hoc audit note: this PR received bot review feedback verified against current HEAD as part of #544. 4 finding(s) confirmed still present → tracked in #550.

@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da7b8f5c82

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/render_topology_status.py Resolved
Comment thread devtools/render_topology_status.py Resolved

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

Adds a generated “topology drift” dashboard to make architectural-cohesion progress visible in-repo, and wires it into the existing devtools render-all generated-surface checks.

Changes:

  • Introduces devtools render-topology-status to render docs/topology-status.md from docs/plans/topology-target.yaml + the realized polylogue/ tree.
  • Registers the new dashboard in the generated-surfaces pipeline (render-all) and exposes it in the devtools command catalog/docs.
  • Updates the topology invariant test to stop xfail and assert the dashboard doc exists.

Reviewed changes

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

Show a summary per file
File Description
devtools/render_topology_status.py New renderer for the topology status dashboard markdown.
devtools/generated_surfaces.py Adds topology-status to the generated surfaces registry so render-all --check enforces drift.
devtools/command_catalog.py Adds the render-topology-status command spec to the devtools command registry.
docs/topology-status.md New checked-in generated dashboard output.
docs/devtools.md Documents the new generated-surface command.
tests/unit/architecture/test_topology_invariants.py Converts the Phase 3 dashboard check from xfail to a passing assertion.

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

Comment on lines +87 to +88
pending = sum(1 for cell in cells if str(cell.get("path")) in realized_targets)
at_target = total - pending

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

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

pending/at_target are computed from whether the declared path exists in the realized tree, but verify-topology requires declared paths to match realized paths, so this will always mark every cell as pending (even after a cell is migrated). Migration progress should be derived from the projection fields (e.g., path == target means “at target”) or by checking target in realized explicitly.

Suggested change
pending = sum(1 for cell in cells if str(cell.get("path")) in realized_targets)
at_target = total - pending
at_target = sum(
1
for cell in cells
if (
str(cell.get("path") or "") == str(cell.get("target") or "")
or str(cell.get("target") or "") in realized_targets
)
)
pending = total - at_target

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +93
# Conflicts: rows whose target collides with another row's target.
targets = [str(cell.get("target") or "") for cell in cells]
conflicts = len([t for t in targets if targets.count(t) > 1 and t])
parts.append(f"| {owner} | {title} | {total} | {at_target} | {pending} | {conflicts} |")

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

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

Conflict counting is currently scoped to targets within a single issue (cells) and uses targets.count(...) in a way that misses collisions between issues (the main kind you want to detect in the projection). Consider computing a global Counter of all non-TBD targets across the whole projection, then for each issue count how many of its cells have a target with global count > 1.

Copilot uses AI. Check for mistakes.
"#426": "rationalize package-root layout and consolidate facade surface",
}

NON_OWNER_TAGS = {"stable", "kernel", "lib-root", "storage-root"}

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

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

NON_OWNER_TAGS is defined but not used. If it’s not part of an intended near-term follow-up, removing it would keep the module’s intent clearer.

Copilot uses AI. Check for mistakes.
@Sinity
Sinity requested a review from Copilot May 1, 2026 00:44
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 01:05
Sinity added a commit that referenced this pull request May 7, 2026
…ns (#456)

## Summary

Fixes a projection-rule defect surfaced by the topology-status dashboard
(PR #455). The rule was emitting `__init__.py` for any module whose name
equaled the subpackage prefix exactly, which caused multiple modules to
claim the same destination — 12 false-conflict rows in the dashboard.

## Problem

`build_topology_projection.py:lib_target()` and `storage_target()` use a
strip-prefix-then-stem rule. When the stem strips empty (e.g. module
`session_payload` matches prefix `session_payload`), the rule defaulted
to `__init__.py`. Two such modules in the same cluster collide:

- `lib/session/__init__.py` claimed by `session_payload`,
`session_summaries`, `session_profile`
- `storage/runtime/__init__.py` claimed by `store_runtime` (the
catch-all prefix)

`devtools verify-topology` reports `conflicts: 12` and the dashboard
shows them in its conflicts column.

## Solution

New resolver:

```python
def _resolve_target(name: str, sub: str, prefix: str) -> str:
    stem = name[len(prefix):]
    if not stem:
        # Module name == prefix; preserve full name to avoid colliding at __init__.py.
        return f"polylogue/{sub}{name}"
    if not stem.endswith(".py"):
        stem = stem + ".py"
    stem = stem.lstrip("_")
    if not stem or stem == ".py":
        return f"polylogue/{sub}{name}"
    return f"polylogue/{sub}{stem}"
```

After regen: `verify-topology --json` reports `conflicts: 0`. Dashboard
column will read 0 once this and #455 are both merged.

## Verification

```
$ devtools build-topology-projection
$ devtools verify-topology --json | jq '.counts'
{"orphans": 0, "missing": 0, "conflicts": 0, "kernel_rule": 0, "tbd": 39}

$ devtools verify --quick
verify: all checks passed (incl. all 8 lints)
```

## Related

- #429 — projection lint pattern.
- #455 — topology drift dashboard (sibling PR; conflicts column will
read 0 after both merge).
- #424 / #425 — refactors that consume the projection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Phase 3 of #429. Renders `docs/topology-status.md` from the topology
projection (`docs/plans/topology-target.yaml`) plus the realized
`polylogue/` tree. The dashboard is checked-in markdown so
structural-cohesion progress is visible to anyone reading docs, not just
to those who run lints locally.

## Problem

After Phase 1 of #429 landed (`devtools verify-topology` lint, plus
xfail tests), structural drift was checkable only via local commands.
Outsiders looking at the architecture-cohesion track had no single
artifact telling them "of the seven topology refactors, here's how far
each has gotten."

## Solution

`devtools render-topology-status` builds a per-issue dashboard table:

```
| Issue | Title | Cells | At target | Pending | Conflicts |
| --- | --- | --: | --: | --: | --: |
| #403 | rationalize source and test module structure | 16 | 0 | 16 | 0 |
| #414 | rationalize product ownership and package boundary | 8 | 0 | 8 | 0 |
| #424 | group lib by domain cluster | 57 | 0 | 57 | 8 |
| #425 | group storage by ownership domain | 63 | 0 | 63 | 4 |
| #426 | rationalize package-root layout and consolidate facade surface | 15 | 0 | 15 | 0 |
```

Plus summary counts (stable / kernel / primitives / TBD) and the
explicit TBD list.

Wired into `devtools render-all` as a generated surface — drift fails
`render-all --check`. Each refactor PR updates the dashboard
automatically as cells move.

## Verification

```
$ devtools render-topology-status
$ devtools render-all --check
render-all: check topology-status
  ... sync OK

$ devtools verify --quick
verify: all checks passed (incl. all 8 lints)
```

## Coordinates with

Pattern complete for #429:

1. **Phase 1** (PR #438): projection + lints + xfail tests.
2. **Phase 2**: topology obligation family in
`polylogue/proof/catalog.py` (still pending).
3. **Phase 3** (this PR): drift dashboard.

## Related

- #429 — pattern source.
- #432 — evidence-driven structural specification (Phase 2 substrate).
- #401 — post-renewal consolidation umbrella.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added `devtools render-topology-status` CLI command to generate
topology status dashboard.
* Topology status dashboard displays per-issue migration progress, cell
counts, target status, and conflict detection.
* Dashboard automatically renders from target configuration and project
codebase.

* **Tests**
  * Resolved previously failing topology status documentation test.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

Only the rows listed above are dispositioned. Held findings remain open.

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.

2 participants