Repository navigation
feat(devtools): Census every durable rewrite at statement grain - #5377
Conversation
Closes the blocking evidence gap that two prior polylogue-6kur AC4 audits both named in their own words: the durable-UPDATE census was grep-literal, so nobody could read AC4 as a proof of absence. WHAT THE GREP COULD NOT SEE The previous census matched `UPDATE <table>` against a generated durable table list. It therefore could not see `INSERT OR REPLACE`, `ON CONFLICT ... DO UPDATE`, interpolated table names, or a correction expressed as delete-then-reinsert. This replaces it with a statement-grain AST census. Measured at head: 138 durable rewrite sites and 33 caller-supplied-SQL helpers across source (84), audit (28), user (22) and 4 whose table does not resolve statically. By kind: 81 update, 36 delete, 17 upsert_do_update, 4 insert_or_replace. The last two kinds -- 21 sites -- are exactly the shapes the grep was structurally blind to. WHY IT IS NOT SUBSUMED BY AN EXISTING CENSUS layering's writer-module census is FILE grain: it proves which modules execute DML, so new DML added inside an already-listed module is invisible to it, and 26 of these sites live in modules it already lists. rebuild-routes censuses who can REACH a rebuild entrypoint; a direct UPDATE against a durable table reaches no rebuild entrypoint at all. ENFORCEABLE, NOT A DOCUMENT The campaign already refused to commit a 459-entry list because it would rot with no gate. So the deliverable is a check whose OUTPUT is the enumeration, carried by the existing `layering` gate -- no new gate name, the same choice #5352 made by putting its check inside `atlas`. WHAT THE RATCHET ASSERTS TODAY, STATED PRECISELY Every one of the 138 sites is pinned as `unclassified`, which means the census SAW the site -- not that the site is legitimate. The enforced property is that a NEW durable rewrite cannot appear undeclared. Adjudicating the existing 138 against the classification vocabulary (lifecycle_transition, guarded_producer_refinement, deliberate_redaction, two_phase_recovery, finite_actuator, declared_retention, row_supersession) is follow-up work, and until it happens this is NOT evidence that no masking backfill exists. Declaring `masking_backfill` fails the gate by design. ANTI-VACUITY, BOTH DIRECTIONS EXECUTED: * Add a new undeclared `UPDATE raw_sessions` to source_write.py -> `durable_write_undeclared` naming the exact site. Reverted. * Declare one existing site `masking_backfill` -> `durable_write_masks_a_producer` quoting "an after-the-fact correction of a value a producer got wrong". Reverted. * The clean tree reports 0 violations, so the check is not a blanket prohibition. VERIFICATION: devtools verify --quick exit 0, all gates including layering. devtools render all --check exit 0, zero "out of sync". Both new devtools modules measure schema-closure `out`, so the derived identity does not move and this can land during a rebuild. RESIDUAL, named rather than papered over: this closes G1 (the statement-grain denominator). G2 -- an exhaustive census of archive-wide derived corrective sweeps -- and G3 -- a systematic search for read-path masks -- are NOT closed. The one real backfill found at head was located only because it was in the named _repair_* family, so a _reconcile_*/_normalize_*/_converge_* twin would still be invisible, and the one read-path mask found was found incidentally. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (17)
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0d80b1548
ℹ️ 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".
…tutions polylogue-6kur AC4 reads "current writer defects have owning producer fixes and cannot be masked by backfills". Three passes closed the masking half for named routes and each left the same two gaps open in its own words. G2: no exhaustive census of archive-wide derived corrective sweeps existed. The one real sweep at head was found only because it happened to sit in the named `_repair_*` family -- daemon/lineage_startup.py ran `repair_stale_prefix_branch_points` unscoped, archive-wide, on every daemon start, and #5372 deleted it. A `_reconcile_*` / `_normalize_*` / `_converge_*` twin would have been invisible to that search, and naming more prefixes is the same grep with a longer list. G3: no systematic search for read-path masks was done. The one that was found was found incidentally, and turned out to be not merely redundant but wrong. Both gaps have the same cause: the existing writer-module censuses are file-grain and answer *who executes DML*. Neither question is about that. A corrective sweep is a derived-tier rewrite whose subject set is archive state rather than what a write touched; a read-path substitution is a read supplying a value for a stored field it found absent. This census is structural -- it reads the AST, not routine names -- so a differently-named twin cannot hide from it. Wired into `devtools gate layering` beside the writer-module censuses. `sql_statement_text.py` is split out because statement-grain subject extraction is shared with the durable-write census from #5377. The initial census pins 27 sites: 21 `unclassified` (the honest floor -- pinned by the census, adjudication is follow-up work), plus 2 `bounded_key_publication`, 2 `producer_scoped_transaction`, 1 `presentation_projection` and 1 `declared_retention`. Pinning at `unclassified` rather than asserting a justification keeps the gate green on today's tree without claiming any of the 21 is benign; adjudicating them is filed separately. Verification (exit codes read directly, not through a filter): devtools test tests/unit/devtools/test_derived_sweep_census.py -> PASSED exit=0, receipt .cache/verify/runs/20260922T010837Z-focused-test-229181-7185cd94/run.json devtools gate layering -> passed, violations 0, baselined 215 Closure: devtools/ and tests/ are outside the derived-schema closure, so the derived schema identity does not move and this carries no landing-order constraint relative to a rebuild. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…tutions polylogue-6kur AC4 reads "current writer defects have owning producer fixes and cannot be masked by backfills". Three passes closed the masking half for named routes and each left the same two gaps open in its own words. G2: no exhaustive census of archive-wide derived corrective sweeps existed. The one real sweep at head was found only because it happened to sit in the named `_repair_*` family -- daemon/lineage_startup.py ran `repair_stale_prefix_branch_points` unscoped, archive-wide, on every daemon start, and #5372 deleted it. A `_reconcile_*` / `_normalize_*` / `_converge_*` twin would have been invisible to that search, and naming more prefixes is the same grep with a longer list. G3: no systematic search for read-path masks was done. The one that was found was found incidentally, and turned out to be not merely redundant but wrong. Both gaps have the same cause: the existing writer-module censuses are file-grain and answer *who executes DML*. Neither question is about that. A corrective sweep is a derived-tier rewrite whose subject set is archive state rather than what a write touched; a read-path substitution is a read supplying a value for a stored field it found absent. This census is structural -- it reads the AST, not routine names -- so a differently-named twin cannot hide from it. Wired into `devtools gate layering` beside the writer-module censuses. `sql_statement_text.py` is split out because statement-grain subject extraction is shared with the durable-write census from #5377. The initial census pins 27 sites: 21 `unclassified` (the honest floor -- pinned by the census, adjudication is follow-up work), plus 2 `bounded_key_publication`, 2 `producer_scoped_transaction`, 1 `presentation_projection` and 1 `declared_retention`. Pinning at `unclassified` rather than asserting a justification keeps the gate green on today's tree without claiming any of the 21 is benign; adjudicating them is filed separately. Verification (exit codes read directly, not through a filter): devtools test tests/unit/devtools/test_derived_sweep_census.py -> PASSED exit=0, receipt .cache/verify/runs/20260922T010837Z-focused-test-229181-7185cd94/run.json devtools gate layering -> passed, violations 0, baselined 215 Closure: devtools/ and tests/ are outside the derived-schema closure, so the derived schema identity does not move and this carries no landing-order constraint relative to a rebuild. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…tutions (#5380) ## Summary Closes `polylogue-6kur` AC4's last two gaps (G2, G3) with a structural census wired into `devtools gate layering`. ## Problem AC4 reads *"current writer defects have owning producer fixes and cannot be masked by backfills"*. Three successive passes closed the masking half for named routes, and each left the same two gaps open in its own words: **G2** — no exhaustive census of archive-wide derived corrective sweeps existed. The one real sweep at head was found only because it happened to sit in the named `_repair_*` family: `daemon/lineage_startup.py` ran `repair_stale_prefix_branch_points` unscoped, archive-wide, on every daemon start, and #5372 deleted it. A `_reconcile_*` / `_normalize_*` / `_converge_*` twin would have been invisible to that search, and naming more prefixes is the same grep with a longer list. **G3** — no systematic search for read-path masks was done. The one that was found was found incidentally, and turned out to be not merely redundant but wrong. Both gaps have one cause: the existing writer-module censuses are file-grain and answer *who executes DML*. Neither question is about that. ## Solution - A **corrective sweep** is a derived-tier rewrite whose subject set is archive state rather than what a write touched. - A **read-path substitution** is a read supplying a value for a stored field it found absent. The census reads the AST, not routine names, so a differently-named twin cannot hide from it. `sql_statement_text.py` is split out because statement-grain subject extraction is shared with the durable-write census from #5377. The initial census pins **27 sites**: 21 `unclassified` — the honest floor, *pinned by the census, adjudication is follow-up work* — plus 2 `bounded_key_publication`, 2 `producer_scoped_transaction`, 1 `presentation_projection`, 1 `declared_retention`. Pinning at `unclassified` rather than asserting a justification keeps the gate green on today's tree **without claiming any of the 21 is benign**; adjudicating them is filed separately. ## Verification Exit codes read directly, not through a filter. ``` devtools test tests/unit/devtools/test_derived_sweep_census.py -> PASSED exit=0 receipt .cache/verify/runs/20260922T010837Z-focused-test-229181-7185cd94/run.json devtools gate layering -> passed, violations 0, baselined 215 ``` ## Schema identity `devtools/` and `tests/` are outside the derived-schema closure, so the identity does not move and this carries **no landing-order constraint** relative to a rebuild. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
… DDL (#5387) ## Summary `polylogue-j264r` AC3: *"excision_policy_projections or its chosen existing-owner replacement is in canonical DDL; ordinary writers do not create an unregistered durable shape."* This is the first real numbered migration on a durable tier since the format floor was reset. ## Problem The write-time `CREATE TABLE IF NOT EXISTS excision_policy_projections` sat inside `publish_source_generation` (`source_items.py:334`), the table was absent from canonical `SOURCE_DDL`, and the reader compensated with a `sqlite_schema` existence probe — the symptom, not the cause. ## The migration regime is usable as documented — I checked rather than assuming `ARCHIVE_FORMAT_FLOOR_VERSION = 1`, and `migrations/{source,user,audit}/` each held only `__init__.py`, so there was no numbered migration to copy. But the regime is complete: `DURABLE_MIGRATION_ADOPTION_FLOORS` is the floor for all three tiers, `docs/internals.md:135` states *"the first numbered slot on any durable tier is 002"*, `validate_durable_migration_sidecars()` requires a checked-in `NNN.train.json` above the floor, and `assert_archive_format_lineage()` already treats the marker's `tier_versions` as a **lower** bound. Nothing was invented. **Classification: additive-durable.** ## What landed - `excision_policy_projections` into `SOURCE_DDL`; write-time `CREATE` deleted; reader's existence probe deleted. - `SOURCE_TIER_VERSION = 2` (user/audit stay at 1). - `migrations/source/002_excision_policy_projections.sql`, `-- migration-safety: additive-no-backup`, body verbatim from the write path. - Frozen sidecar `002.train.json` via `declare_durable_change_train` — slot 2, `1 → 2`, `sql_sha256 b6b6c081…`, one rider carrying two materially distinct production consumers (the writer and the reader). - A probe adapter for `:read_excision_policy_projection` — without it the rider's reader hits *"no durable probe adapter"* at prove time. - The upsert became visible to `gate layering` once the table was durable; declared `unclassified` with a reason. ## Both directions proven on synthetic archives - **Fresh**: bootstraps at `user_version 2` with the table from canonical DDL; an ordinary policy-bearing write changes **zero** `sqlite_schema` rows; read-back matches. - **Existing v1 that already grew the table via the write path**: refused typed at open — *"schema version 1 is older than the current source tier version 2; run an explicit durable-tier migration with a verified backup manifest"* — then `1 → 2 applied (2,)`, the pre-existing row survives **byte-identical**, reopens at 2. - **Existing v1 without the table**: the same migration creates it. - **Parity**: the adopted table's `sqlite_schema` text equals the canonical fresh DDL after normalization. The live archive (`source.db` at `user_version 30`) is pre-floor, outside this format, does **not** contain the table, and is untouched. ## Anti-vacuity executed — and the obvious test would have been vacuous `test_writer_creates_no_durable_shape` installs a `sqlite3` authorizer denying every `CREATE` verb for the duration of one ordinary `publish_source_generation`. Restoring the write-time `CREATE`: ``` E sqlite3.DatabaseError: not authorized polylogue/storage/sqlite/archive_tiers/source_items.py:334: DatabaseError {'passed': 3, 'failed': 1} ``` Executed twice — before and after the rebase — and reverted both times. **A before/after `sqlite_schema` comparison would have stayed green under that mutation**, because `CREATE TABLE IF NOT EXISTS` is a runtime no-op once canonical DDL owns the table. The authorizer fires at prepare time, which is why it is the test. ## Verification ``` devtools verify --quick exit 0, 25 gates (schema-manifest proves the v1->v2 bump ships a contiguous added migration; layering proves the new durable write is declared) devtools render all --check exit 0, grep -c 'out of sync' = 0 devtools test <17 selections> exit 1 -- entirely inherited red ``` Inherited red measured, not assumed: the same 17-file selection at base `a2df1fc5d` gives 295 passed / 57 failed; this branch gives 303 passed / 54 failed. **New failures: 0. Fixed: 3.** ## Schema identity All five edited production files are closure **IN**; membership unchanged, `gate schema-closure` passed with no `--update`. INDEX `d098303c… → 7fe8a6c2…`, OPS unchanged. **Must land before a fresh rebuild starts.** ## Residuals filed rather than absorbed Two root causes of the inherited red were diagnosed here and filed as their own beads: - **`polylogue-klxla`** — 39 `test_durable_change_train` failures: the module wasn't updated when the floor was reset to 1. `_install_synthetic_migration` writes `002_durable_items.sql` with no sidecar, and other tests still use pre-reset literals (`reset_source_fixture_to_version(source, 31)`). - **`polylogue-1or21`** — 9 `test_layering_gates` failures: `verify_layering.py:1015` falls through to `violation['import']` for any family without a branch, and the `durable_write_*` family from #5377 has none. `gate layering` is green only because it renders on a finding — so that census is armed and unable to report. Only AC3 is addressed; `j264r` stays open on its other five criteria and 26 blockers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added durable source-tier support for recording and reading excision policy projections. * Added migration support for the new projection data, including preservation of existing records. * Added a dedicated source-tier schema version and updated migration tracking. * **Bug Fixes** * Reads now distinguish an unbound policy projection from a missing database structure. * Source-generation publishing now relies on the canonical schema rather than creating tables during writes. * **Documentation** * Updated schema and migration guidance for source, user, and audit tiers. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
`_format_violation` fell through to `violation['file']` / `violation['import']` for any rule family without a branch. The `durable_write_*` and `caller_supplied_sql_*` families from #5377 report declaration rows keyed on a census key, not import edges, and some of their shapes carry no `file` at all (a missing declaration; a stale helper entry). Rendering one raised KeyError and took the whole plaintext report down with it, so an armed census could not report a finding and 9 tests in tests/unit/devtools/test_layering_gates.py were red at master. One branch now covers every declaration-census family, the import fall-through only fires when the violation actually carries an import edge, and the terminal fall-through names the missing renderer and dumps the payload -- a future family without a branch is loud in the report instead of crashing it or reading as if it were understood. `_write_ratchet_fixture` now seeds empty census declarations. Its package executes no DML, so an empty declaration is the truthful one; without it three ratchet tests failed on an unrelated missing declaration rather than on the import property they are about. Verification: devtools test tests/unit/devtools/test_layering_gates.py -> 42 passed Reverting _format_violation alone: 18 failed, including `KeyError: 'file'` and `KeyError: 'import'` at verify_layering.py:1016. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…rer total (#5393) ## Summary `polylogue-1or21` plus the 159 sites both censuses pinned at `unclassified`. Durable-write census **138 → 134 adjudicated + 7 honestly unclassified**; derived-sweep census **21 → 0 unclassified**. The 9 red `test_layering_gates.py` tests are green (42/42). **Three real findings surfaced; none was labelled to make it go away.** ## The renderer could not report its own census `verify_layering.py` fell through to `violation['file']` / `violation['import']` for any rule family without a branch, and the `durable_write_*` family from #5377 had none. `gate layering` was green only because it renders on a finding — the census was **armed and unable to speak**. Anti-vacuity executed: restoring the base renderer gives `KeyError: 'file'` and `KeyError: 'import'` at `verify_layering.py:1016`, 18 failed / 42. Both directions pinned — one test asserts `imports polylogue.storage (disallow)` still prints (so a generic dump fails), another parametrizes 10 census shapes asserting none lands on `<no renderer for rule family>` (so merely making the fall-through total also fails). ## F1 — an analysis-tier materializer rewrites durable `source.db` behind the producers `analysis/claude_workflow_materializer.py:286-386`. For **every** `CLAUDE_CODE_SESSION` raw row it re-derives `artifact_kind`, `support_status`, `classification_reason`, `parse_as_session`, `schema_eligible`, `link_group_key` from the OriginSpec taxonomy via `ON CONFLICT(artifact_id) DO UPDATE`, and **DELETEs durable `raw_artifacts` rows whose content evidence disagrees with the rule**. Its own docstring says the quiet part: *"the same source-tier invariant is **repaired** here for daemon/direct raw writers"*, and an inline comment records a prior incident where *"the durable table ended up reflecting whichever pass ran last."* **No permitted classification fits** — not guarded (outside the producer), not a declared state advance, nothing re-acquired, not retention, not operator destruction. It is left `unclassified` with that reasoning rather than stretched into a member. `masking_backfill` is forbidden and was not used as a resting place. ## F3 — a schema qualifier hid three durable `user.db` rewrites from the census, now fixed `_REWRITE_RE` bound `table` to the ATTACH alias, so `UPDATE user_tier.assertions` resolved to a table named `user_tier`, which no tier declares. Three durable rewrites in `storage/derived/feedback/__init__.py` — one upsert and two `SET status='deleted'` — were dropped by the census that exists to enumerate them. Fixed; exactly 3 new entries appeared and all were adjudicated. **That is why the total is 141, not 138.** Residual noted: those three bypass `upsert_assertion`, the declared write chokepoint. Benign today because `CORRECTION` is not in `ASSERTION_CLAIM_KINDS` — worth a design note if that changes. ## F2 / F4 — recorded, not fixed here - `excision_policy_projections` is invisible to the census because it is created by a runtime `CREATE TABLE IF NOT EXISTS` in a function body, so `durable_table_tiers()` returns None and its upsert is dropped before classification. That upsert retro-rewrites what an already-published generation claims it excluded — exactly what `j264r`'s design forbids. Sequencing note: #5387 moved the DDL, so the census will now see it and will need a verdict. - Neither vocabulary has a member for **a censused statement that provably cannot rewrite a durable row** — five entries sit at the floor for that reason alone, including `UPDATE assertions SET updated_at_ms = updated_at_ms WHERE 0`, which exists only to force a RESERVED lock. ## A reproduction that did NOT hold `daemon/status.py::build_daemon_status::overall_status` was named as a likely finding. It does not reproduce: the only substitution is **fail-closed** — a collected `HealthSeverity.OK` is *escalated* when its snapshot is unavailable/timed-out/degraded, with a named alert. It can never report clean for a collector that did not complete. ## Verification ``` devtools test test_layering_gates.py (base) FAILED 9/42, KeyError devtools test test_layering_gates.py (branch) PASSED 42/42 devtools gate layering exit 0, violations 0 devtools verify --quick exit 0, 25/25 devtools render all --check exit 0, 'out of sync' 0 devtools schema closure (6 files) all 'out' — no identity movement ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
## Summary Fixes the 15 confirmed Codex P1 findings tracked in polylogue-5gj4u, all in devtools: the xdist worker cap, the durable-write census, the mypy cache seed, the schema-manifest gate, and verification receipts. The previous owner's uncommitted lane state was carried onto current master; this PR finishes the census work, which had left `devtools gate layering` at 158 violations. ## Problem Each row is a Codex review thread confirmed against master 64a9bd0 by triage run `r3-devtools`. The reproductions are in the bead and in each linked thread. ## Solution | Finding | Thread | Disposition | Regression test | |---|---|---|---| | 04.F054 Cap explicit xdist worker requests | [#4540](#4540 (comment)) | Fixed: `resize_worker_argument` reads every `-n`/`--numprocesses` before `--`, resolves `auto`/`logical` through xdist's own hook, writes the capped count into every occurrence, and keeps `--pdb` at 0 | `tests/unit/devtools/test_corpus_worker_memory_bound.py`, `tests/unit/devtools/test_run_tests.py` | | 04.F021 Preserve distinct statement identities | [#5377](#5377 (comment)) | Fixed: a site key carries its occurrence, numbered in source order; alternative texts of one call count once, and statements inside one script count separately. The declaration gains a row for each separate statement (15 rows) | `tests/unit/devtools/test_durable_write_census_regressions.py` | | 04.F022 Track in-memory connections by lexical scope | [#5503](#5503 (comment)) | Fixed: a memory binding exempts only its own scope's single, unconditional binding, and only for statements after it | same file | | 04.F023 Reject unresolved dynamic-helper call targets | [#5503](#5503 (comment)) | Fixed: a missing, computed, or partly unknown table argument becomes an explicit `?` target. A conditional with no readable branch stays "not a string" instead of a hole, so the caller-supplied-SQL helper census keeps seeing it | same file | | 04.F024 Scan runtime DDL in every writer module | [#5503](#5503 (comment)) | Fixed: runtime DDL is observed across `polylogue/storage/**` and in any module that writes a canonical archive table. Private stores that never name an archive table (parser spill databases, the browser-capture registry) stay outside archive state; the delegation scratch graph is declared `disposable_scratch`, which any module may now declare with a reason | same file | | 04.F025 Enumerate every table an executescript creates | [#5503](#5503 (comment)) | Fixed: every `CREATE` in a statement text is classified | same file | | 04.F026 Verify foreign-key cleanup data flow | [#5503](#5503 (comment)) | Fixed: each dynamic write in a cleanup helper must take its identifier and connection from the FK metadata loop (or from the catalog loop plus `PRAGMA foreign_key_list` on the same table and connection) | same file | | 04.F029 Isolate incremental mypy state | [#4807](#4807 (comment)) | Fixed: the gate passes mypy its configured `files` as absolute paths rooted at this checkout, so a sibling's cache entry never matches by path and mypy re-hashes the source | `tests/unit/devtools/test_mypy_daemon_lifetime.py` | | 04.F099 Refuse to compare against HEAD | [#4671](#4671 (comment)) | Fixed: `_merge_base` never falls back to HEAD. On the default branch it uses the first parent; with no comparison history it refuses. The GHA lint job fetches full history, and the CircleCI quick gate fetches master | `tests/unit/devtools/test_verify_schema_manifest.py` | | 04.F100 Validate mandatory train sidecars | [#4671](#4671 (comment)) | Fixed: the evolution gate runs the runtime's own `durable_migration_claims` admission per durable tier; shipped sidecars are immutable like their SQL | same file | | 04.F071 Declare the full verification phase plan | [#4111](#4111 (comment)) | Fixed: the complete plan is built and persisted as `workload_spec` before admission; a refusal or interruption withholds steps from execution, not from the plan. The `finalization` placeholder is removed | `tests/unit/devtools/test_verify.py` | | 04.F072 Do not attribute dirty runs to HEAD | [#4111](#4111 (comment)) | Fixed: a dirty tree is `worktree-sha256:<content>`, an unidentified tree is `None`, and a tree that moved during the run has no build id | same file | | 04.F074 Preserve the workload receipt in AgentCTL output | [#4111](#4111 (comment)) | Fixed: the operation result carries the same `workload_receipt` persisted in run.json | same file | | 04.F075 Record configured pytest concurrency | [#4111](#4111 (comment)) | Fixed: `concurrency` is the widest planned fan-out (gate pool or capped xdist width) | same file | | 04.F098 Re-read the receipt after the owner exits | [#5299](#5299 (comment)) | Fixed: after proving the owner dead, the reconciler re-reads run.json and acts only on a receipt still `running` under the same run id | `tests/unit/devtools/test_verify_runs.py` | No derived-identity closure member changes (devtools, tests, CI, and `docs/plans/durable-write-census.yaml` only). ## Verification All runs through AgentCTL declared operations at head `23f57e45e0` (rebased on master `5d56c3a26f`): - `agentctl job start --workspace /realm/worktrees/polylogue-5gj4u polylogue verify_quick` (job 3393): `verify: PASSED exit=0`. Pre-push quick verify: `verify: PASSED exit=0`. - `agentctl job start --workspace … polylogue pytest_focused -- -n 4 <60 affected test files>` (job 3392): 1156 passed, 14 failed. All 14 are inherited or environment-dependent: - 11 fail identically on master `5d56c3a26f` in a detached worktree (`pytest_focused -- <ids> --on-default-branch`, job 3391): `test_daemon_resilience::test_concurrent_access_safety`, `test_web_reader::test_archive_filter_kwargs_cover_every_storage_lowerable_spec_field`, three in `test_cli_acceptance`, `test_pytest_suite_cost_plugin::test_post_gc_rss_is_read_before_heap_census_allocations`, `test_verification_evidence_lane::test_reconciled_abandoned_run_joins_the_durable_lane`, `test_verification_result::test_projection_uses_the_finalized_step_and_aggregate_counts`, `test_verification_terminal_receipts::test_queued_interruption_keeps_start_time_worktree_provenance`, `test_verify::test_zero_exit_without_a_report_is_a_failed_pytest_step`, `test_retention_probe::test_worker_output_is_qualified_and_retention_ranking_is_separate`. - 3 `test_retention_probe` cases fail only inside the mixed `-n 4` run. The file alone passes them on this branch (job 3398) and on master (job 3397), with the same single inherited failure. - `devtools gate layering`: `gate_passed` (0 semantic violations; 158 before this PR's census work). - Every census, worker-cap, mypy, schema-manifest, and receipt regression named in the table passed in job 3392. ## Self-review Checklists re-read: `docs/review/codex-review-guide.md`, `devtools/AGENTS.md` review rules, and the orchestrate worker contract. Three passes; findings from passes 1 and 2 were fixed here, and pass 3 found nothing new. **Pass 1 findings (fixed):** (a) The census WIP left the declaration unchanged: `devtools gate layering` reported 158 violations. (b) Scanning runtime DDL in every module treated about 60 private spill tables (parser scratch databases, the browser-capture registry, schema journals) as archive state. (c) Occurrences were numbered in `ast.walk` order, so nesting an unrelated statement renumbered sites and could swap their declarations. (d) The `IfExp` change turned a conditional with no string branch into a hole, which hid the `_canonical_schema_inventory_for_ddl` caller-supplied-SQL helper. (e) `_dynamic_table_targets` kept an unused `values`. (f) `ast.AST.lineno` typing. **Pass 2 findings (fixed):** (g) Per-call dedupe collapsed two rewrites inside one `executescript` (a red regression test). (h) The regression module sat outside the scanned layer. 1. ✓ **Siblings and owners.** Census runtime DDL now has one scope rule, `_is_archive_storage_module` or `_writes_archive_table`, used by both `census_package` and `verify_layering._package_pass` through `observe_runtime_ddl` (the `reads_runtime_ddl` pre-filter is deleted from both). The worker-width parser `_worker_requests` is the single reader for the slot; `run_tests` still expands clustered flags first (`test_an_explicit_automatic_width_starts_pytest_at_the_capped_count`). 2. ✓ **The fix itself.** A schema-manifest refusal is a typed `RuntimeError`, which `main()` turns into FAIL/exit 1. `durable_migration_claims` errors become violations, not tracebacks. 3. ✓ **Memory and limits.** No new caps. The worker cap applies the existing memory bound to widths xdist would otherwise resolve after it. 4. ✓ **Cost per unit.** `_writes_archive_table` is one extra pass over each module's calls; the census cost stays linear in module size. 5. ✓ **Interruption.** An interrupted verify run records `status=interrupted` with the declared plan and only the steps it finished. 6. ✓ **Ordering and races.** F098: the reconciler re-reads after the liveness check and acts only on a receipt still `running` under the same run id. 7. ✓ **Failure classification.** A missing schema comparison base is refused rather than compared against itself; a shallow clone says so. 8. ✓ **Silent outcomes.** An unresolved dynamic-helper target is an explicit `?` target that fails the gate rather than being skipped. 9. N/A **Cleanup on failure.** The mypy targets response file is written under the checkout lock and removed after the run; nothing else here acquires resources. 10. ✓ **Identity and keys.** Site keys include a source-order occurrence (`test_occurrences_follow_source_order_across_nesting`). Workload build identity is the commit only for a clean tree, otherwise the content digest. 11. ✓ **Lossless transforms.** `resize_worker_argument` rewrites only width values and keeps every other argument in place. 12. ✓ **Degenerate inputs.** `-n 0` stays no xdist; `-n auto --pdb` becomes 0; `-n64` after `--` is a path, not a width. 13. ✓ **Consumers.** `WriteSite.key` and declaration keys change together (`load_declaration` numbers rows the same way); `reads_runtime_ddl` has no remaining caller (grep 0); `iter_site_payloads` publishes `occurrence`. CI configs fetch the comparison history the gate now requires. 14. ✓ **Tests and stubs.** The `_Run` double in `test_verify_gate_independence.py` gained `declare_workload`/`recorded_git_dirty`; `test_verifier_common_finalizer_adds_receipt_on_early_failure` was removed with the fallback it tested. 15. N/A **Trust boundaries.** No credentials or private data are involved. Generic list: 1. ✓ Each finding has a regression test on the gate's own entry points (`census_package`/`collect_violations`, `resize_worker_argument`, `devtools.verify._main` helpers, `verify_schema_manifest.main`, the real mypy binary for F029). 2. ✓ Sibling search: `grep -rn "reads_runtime_ddl\|_is_archive_tier_runtime_module" devtools tests` finds 0 matches. 3. ✓ The HEAD^ fallback and its test are removed; so are the `finalization` placeholder and the `workload_receipt=None` fallback. 4. ✓ Refusals are typed gate failures with named rules. 5. ✓ Each census regression names its anti-vacuity condition in its docstring. 6. ✓ Fixtures are synthetic: temporary repos and modules only. ## Residuals - The census cannot prove which connection a statement runs on. A module outside `polylogue/storage/` that writes no canonical archive table, yet creates and rewrites a table on an archive connection it was handed, is still unseen. The declared scope is the storage layer plus archive writers. - The mypy gate absolutizes only `files` targets; a config using `packages`/`modules` keeps mypy's stat-trust behaviour (Polylogue uses `files`). - An xdist width injected through configuration (`-o addopts=-n64`, `-c other.ini`) is still invisible to the resizer. - The CircleCI fetch step's first hosted run on this PR is its proof. - The 11 inherited failures above are not fixed here: they fail identically on master and sit outside this PR's scope. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
feat(devtools): Census every durable rewrite at statement grain
Closes the blocking evidence gap that two prior polylogue-6kur AC4 audits both
named in their own words: the durable-UPDATE census was grep-literal, so nobody
could read AC4 as a proof of absence.
WHAT THE GREP COULD NOT SEE
The previous census matched
UPDATE <table>against a generated durable tablelist. It therefore could not see
INSERT OR REPLACE,ON CONFLICT ... DO UPDATE, interpolated table names, or a correction expressed asdelete-then-reinsert. This replaces it with a statement-grain AST census.
Measured at head: 138 durable rewrite sites and 33 caller-supplied-SQL helpers
across source (84), audit (28), user (22) and 4 whose table does not resolve
statically. By kind: 81 update, 36 delete, 17 upsert_do_update, 4
insert_or_replace. The last two kinds -- 21 sites -- are exactly the shapes the
grep was structurally blind to.
WHY IT IS NOT SUBSUMED BY AN EXISTING CENSUS
layering's writer-module census is FILE grain: it proves which modules execute
DML, so new DML added inside an already-listed module is invisible to it, and 26
of these sites live in modules it already lists. rebuild-routes censuses who can
REACH a rebuild entrypoint; a direct UPDATE against a durable table reaches no
rebuild entrypoint at all.
ENFORCEABLE, NOT A DOCUMENT
The campaign already refused to commit a 459-entry list because it would rot
with no gate. So the deliverable is a check whose OUTPUT is the enumeration,
carried by the existing
layeringgate -- no new gate name, the same choice#5352 made by putting its check inside
atlas.WHAT THE RATCHET ASSERTS TODAY, STATED PRECISELY
Every one of the 138 sites is pinned as
unclassified, which means the censusSAW the site -- not that the site is legitimate. The enforced property is that a
NEW durable rewrite cannot appear undeclared. Adjudicating the existing 138
against the classification vocabulary (lifecycle_transition,
guarded_producer_refinement, deliberate_redaction, two_phase_recovery,
finite_actuator, declared_retention, row_supersession) is follow-up work, and
until it happens this is NOT evidence that no masking backfill exists. Declaring
masking_backfillfails the gate by design.ANTI-VACUITY, BOTH DIRECTIONS EXECUTED:
UPDATE raw_sessionsto source_write.py ->durable_write_undeclarednaming the exact site. Reverted.masking_backfill->durable_write_masks_a_producerquoting "an after-the-fact correction of a value a producer got wrong". Reverted.
VERIFICATION: devtools verify --quick exit 0, all gates including layering.
devtools render all --check exit 0, zero "out of sync". Both new devtools
modules measure schema-closure
out, so the derived identity does not move andthis can land during a rebuild.
RESIDUAL, named rather than papered over: this closes G1 (the statement-grain
denominator). G2 -- an exhaustive census of archive-wide derived corrective
sweeps -- and G3 -- a systematic search for read-path masks -- are NOT closed.
The one real backfill found at head was located only because it was in the named
repair* family, so a reconcile/normalize/converge* twin would still be
invisible, and the one read-path mask found was found incidentally.
Co-Authored-By: Claude Opus 5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy