Skip to content

feat(devtools): Gate the routes that reach a derived-tier rebuild - #5329

Merged
Sinity merged 1 commit into
masterfrom
fix/sbebh-rebuild-path-gate
Sep 21, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/sbebh-rebuild-path-gate

Conversation

@Sinity

@Sinity Sinity commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Summary

devtools gate rebuild-routes — a rebuild-entrypoint caller census over an AST
function-grain call graph of polylogue/, declared in
docs/plans/rebuild-route-census.yaml and registered in the quick set. It reports
every direct caller of a declared rebuild entrypoint and every entry root of the
upward closure, and requires each to carry a route classification plus a reason.

Problem

polylogue-b5l AC5 requires that a derived tier is rebuilt only by ordinary
daemon convergence, and cited devtools gate layering as its check. That
citation was false and the criterion had no enforcing check at head. Measured:
an orchestration-only second rebuild route left gate layering green at count 0;
it only reddens for a new uncensused file bearing its own raw DML.

It answers the substantive question, not just the enforcement one

No second production build path exists at head (5404968) — and neither does
a first one. Closure is 17 functions over 5 entrypoints, and
closure ∩ forward-reach(make_default_convergence_stages) is empty.

Per caller:

  • pipeline/services/indexing.py rebuild_index — only caller is
    IndexService.rebuild_index, which is re-exported from polylogue.pipeline but
    constructed by no production caller, only tests/unit/pipeline/test_indexing.py. Unreached.
  • operations/mutation_actuators.py InsightsRebuildActuator.apply — nothing
    under polylogue/ constructs it
    . The maintenance.insights.rebuild operation
    is served by execute_insights_rebuild_operation → SessionInsightMaintenance.converge_part
    → SessionProfileConvergenceOwner, which never touches
    rebuild_session_insights_sync. Unreached.
  • storage/derived/session/derivation.py publish_session_profile — zero callers;
    operations/session_profile_convergence.py imports SessionProfileDerivation
    from the same module, not this function. Unreached.
  • demo/seed.py — reached from CLI demo seed|receipts|tour, and newly found,
    not in the starting inventory
    , from operations/daemon_mutations.maintenance_demo_augment
    and daemon/http.py POST /api/demo/augment, both over the daemon's own archive root.

rebuild_archive_session_insights is also unreached — its docstring still claims
polylogue.api and storage.raw_convergence call it; at head neither does.

Verification

  • devtools test tests/unit/devtools/test_verify_rebuild_routes.py — 13 passed
  • devtools verify --quick — exit 0, gate rebuild-routes ... ok (8.7s) among 24 green gates
  • devtools render all --check — exit 0, grep 'out of sync' = 0
  • devtools schema closure — not applicable; the commit touches devtools/,
    docs/plans/ and tests/ only, no file under polylogue/

Anti-vacuity executed, not argued. Added an orchestration-only
maintenance/second_rebuild_route.py (grep -ci 'execute|insert|delete|update'
= 0) awaiting rebuild_index:

  • gate layering --json → count 0, gate_passed true, exit 0 — reproducing the measured hole
  • gate rebuild-routes → count 1, rule rebuild_route_undeclared, diagnosis
    gate_semantic_violation, exit 1

Probe removed, gate returns to count 0. A second probe with three hops and no
entrypoint named anywhere in the module also reddened it.

Design

  • Not a narrow per-file test — the census is repo-wide over every .py under
    polylogue/, with synthetic package trees plus one live-checkout assertion.
  • AST-only, following verify_layering.py:250's precedent: grimp drops the 85
    namespace-package modules, so an import-graph census would report every parser
    as reaching nothing. A test seeds a probe in a directory with no __init__.py
    and requires it be caught.
  • Re-exports are chased and function-local imports followed — mutation_actuators.py
    imports its rebuild inside apply().
  • A declared entrypoint resolving to no definition is a hard finding, so a
    rename cannot silently empty the census.
  • route: daemon_convergence must be structurally provable from the declared
    stage seeds. The forward walk is an under-approximation, so being inside it
    proves reachability while being outside proves nothing — the token is therefore
    refused rather than trusted. No entry claims it today.

Residuals

  • Inherited bug, reproduced on a clean tree: devtools gate layering without
    --json crashes with KeyError: 'observed' at verify_layering.py:1277.
    _sqlite_degradation_findings returns entries keyed file/anchor/digest/removed
    while the plaintext printer reads entry['observed']/entry['baseline'] — a
    stale per-file-count shape. 54 baseline entries no longer reproduce, so it fires
    on every plaintext run today, masked because the gate table runs --json. Left
    unfixed to keep this commit cohesive. Filed separately.
  • daemon/http.py POST /api/demo/augment reaches apply_demo_post_ingest_augmentation
    directly rather than through the declared maintenance.demo.augment dispatcher —
    a second entry into one augmentation inside the daemon. Recorded in the census reason.
  • Five exported rebuild routes have no production caller. They are retirement
    candidates; the census pins them so none can quietly acquire one.
  • The entrypoint list is policy: the gate cannot detect that a new derived-tier
    rebuild primitive was added without being declared. That needs a signature heuristic.

Closes polylogue-sbebh.

🤖 Generated with Claude Code

https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq

polylogue-b5l AC5 requires that a derived tier is rebuilt only by
ordinary daemon convergence and cited `devtools gate layering` as its
check. Measured at 2b20817, that citation is false: an
orchestration-only rebuild route added under polylogue/maintenance/ and
awaiting pipeline.services.indexing.rebuild_index outside
DaemonConverger left the layering gate green (count 0, exit 0). Its
writer census fires on a new uncensused file executing its own DML, so
both realistic shapes of a second build path pass it.

`devtools gate rebuild-routes` censuses the other question: who can
reach a rebuild entrypoint at all. It builds a function-grain AST call
graph over polylogue/, reports every direct caller of a declared
entrypoint and every entry root of the upward closure, and requires each
to carry a route classification and a reason in
docs/plans/rebuild-route-census.yaml. A declared entrypoint that
resolves to no definition is refused, so a rename cannot empty the
census, and `route: daemon_convergence` must be structurally provable
from the declared stage seeds rather than asserted.

AST is primary because devtools/verify_layering.py documents that grimp
silently drops the 85 namespace-package modules in this checkout; an
import-graph census would report every parser as reaching nothing.

The substantive finding the census records: no rebuild entrypoint is
reachable from make_default_convergence_stages at this head. Every
declared route is demo seeding, daemon-hosted demo augmentation, or
unreached -- including IndexService.rebuild_index,
publish_session_profile, rebuild_archive_session_insights,
rebuild_session_insights_async and InsightsRebuildActuator, whose only
callers are tests.

Verification: devtools test tests/unit/devtools/test_verify_rebuild_routes.py
(13 passed, receipt 20260921T051448Z-focused-test-3817561-254c27dc);
devtools verify --quick exit 0 with `gate rebuild-routes ... ok`;
devtools render all --check exit 0, no "out of sync". Anti-vacuity was
executed, not argued: the DML-free probe module above leaves
`devtools gate layering` green (count 0, gate_passed true, exit 0) and
reddens `devtools gate rebuild-routes` (count 1,
rebuild_route_undeclared, exit 1) naming the route and its entrypoints.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2351d7ad-5194-4971-86bc-cf1955d8b5e2

📥 Commits

Reviewing files that changed from the base of the PR and between 75f5812 and ac88227.

📒 Files selected for processing (4)
  • devtools/gate.py
  • devtools/verify_rebuild_routes.py
  • docs/plans/rebuild-route-census.yaml
  • tests/unit/devtools/test_verify_rebuild_routes.py

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-21T05:26:24.913782Z ac88227 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Sinity
Sinity enabled auto-merge (squash) September 21, 2026 05:22

@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: ac88227f4b

ℹ️ 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/verify_rebuild_routes.py Resolved
Comment thread devtools/verify_rebuild_routes.py Resolved
@Sinity
Sinity merged commit 882e920 into master Sep 21, 2026
3 checks passed
@Sinity
Sinity deleted the fix/sbebh-rebuild-path-gate branch September 21, 2026 05:31
Sinity added a commit that referenced this pull request Sep 21, 2026
)

## Summary

Four live declared CLI routes were committing against the durable
`source.db`
with no daemon, and one recovery operation was unexecutable in every
daemon
state. Both directions are fixed.

## What was found at head — more than #5310 claimed

`#5310`'s "the last CLI in-process writers" is false. Beyond the
reported
`_blob_publications.py:35-41`:

- `_blob_integrity.py` runs `UPDATE raw_sessions`
  (`blob-reference-replace-from-source`) and `DELETE FROM blob_refs`
  (`blob-reference-prune-orphans`)

All three call `require_write_lease` — **which is inert outside the
daemon**,
because enforcement is only armed there. The assertion returned `None`
and the
write proceeded **beside a live daemon**.

And the inverse defect: `maintenance.blob-gc.recover` was **unexecutable
in every
daemon state**.
`PendingBlobGCGenerationAbandonActuator._require_offline_writer_ownership`
refused precisely when the daemon it requires was running. It was pinned
as a
`strict=True` xfail, which is why it never showed as red.

## Solution

Four routes moved onto declared `DaemonAuthority.WRITE` /
`DaemonFallback.NEVER`
operations: `maintenance.blob-publications.abandon`,
`maintenance.blob-refs.replace-from-source`,
`maintenance.blob-refs.prune-orphans`, plus gc-recover unblocked.

Side-fix for `5vps8` AC9: `_execute_named_mutation` dropped the
executor's
`receipt_ref`, so **every actuator behind it rendered `null` for an
audited
destructive mutation**. The envelope and `MutationResult` now carry it.

For `l65ry`: no forwarding wrappers remain and the offline-writer guard
is
**deleted, not demoted**; preview commands stay read-only dry runs;
`docs/internals.md` reconciled.

## The closure gate caught a real hazard

Putting the blob-ref actuators beside their siblings would have added
`storage/blob_integrity.py` to the derived closure — a ratchet
violation. They
live in a new `operations/maintenance_actuators.py` reached only from
the
out-of-closure handler module. **Net closure only shrinks**, by the
eight files
the offline-guard deletion released.

`operations/specs.py` and `mutation_actuators.py` are **IN** — this
moves the
derived identity and must land before a rebuild starts, never during
one.

## Verification

- `devtools verify --quick` — exit 0, all gates including
`schema-closure`, re-run
  **after rebase** onto current master
- `devtools gate rebuild-routes` — **exit 0**, count 0. The lane could
not run
#5329's new gate before rebasing and reasoned it would pass; it was run
here and
  does.
- `devtools render all --check` — exit 0, zero `out of sync`
- `devtools test`: maintenance CLI + operations declarations 172 passed
/ 6 failed;
operations + kernel + blob-gc-durable-intent 510 / 3; daemon route + MCP
envelopes 95 / 1; mutation-envelope consumers passed. **Every failure
inherited
and named** — six `test_migrate_tier_cli_*` on the documented
version-floor
cause in a file untouched here, two version-floor reds, and one recorded
verbatim
  in the known-red file.

**Four mutations executed**: reinstating the offline guard reproduces
`requires the daemon to be stopped; a daemon writer lease is active`;
reinstating
each in-process write call makes the refusal test exit 0 with the row
deleted or
the manifest written.

## Residuals

- **`5vps8` AC1 is advanced, not met.** A gate sweep found further
writers this
lane did not touch: `_blob_integrity.py:284,:429` carry docstrings
reading
"Always mutates the archive", `commands/backup.py:58` runs
`backup_archive`
in-process, and `commands/embed.py:895` opens `ops.db` writable. Do not
treat
  this landing as discharging AC1.
- **AC2/AC3 not done**: `pipeline/services/archive_ingest.py:199` is
still
  `open_existing(read_only=False)`. `polylogue import` is routed, but
`polylogue demo seed` → `seed_demo_archive` → `parse_sources_archive`
still
reaches it in-process, as does the `api/ingest.py` facade. Deleting that
engine
  is a separate cohesive bead across ~20 test files.
- **AC12 remains unsatisfiable** — no named baseline exists; no count
was manufactured.
- `ops maintenance operation-recovery --confirm` still writes `audit.db`
in-process behind `offline_maintenance_block_reason` — a deliberate
break-glass
path whose premise is a dead daemon, so routing it is a design question.
- `blob-disposition restore --active` lacks the guard `apply` has
(verified: 0 vs 2
references), but `restore_plan_members` is additive filesystem spool
restoration
  writing no SQLite — lower severity than the four routed here.
- `test_runtime_operation_catalog_covers_the_current_runtime_paths` was
**already
red at base** for three unrelated drifts, proven via `git show HEAD:`;
reconciled.

Advances polylogue-5vps8 and polylogue-l65ry.

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

https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq

---------

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

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):

  • P1 devtools/verify_rebuild_routes.py:270: Fixed on master (checked at 64a9bd0): _reference_sites now records full dotted attribute chains via _dotted_name (devtools/verify_rebuild_routes.py:275-285, 306-319), and build_call_graph resolves them through module aliases (devtools/verify_rebuild_routes.py:377-379).
  • P1 devtools/verify_rebuild_routes.py:210: Fixed on master (checked at 64a9bd0): _import_maps keeps import bindings per lexical scope (devtools/verify_rebuild_routes.py:193-243), and references resolve against their own and enclosing scopes via _visible_imports (devtools/verify_rebuild_routes.py:362-367).

Resolving every thread listed; confirmed defects are fixed under the named bead.

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.

1 participant