Skip to content

fix: Make durable schema evolution gate complete and checkout-independe… - #4671

Merged
Sinity merged 1 commit into
masterfrom
feature/packet/polylogue-v7wwt
Sep 4, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/packet/polylogue-v7wwt

Conversation

@Sinity

@Sinity Sinity commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

Complete the durable schema evolution gate and make its CI entry point active.

Problem

The gate must compare effective durable schema state, including DDL produced by runtime transformations, against the branch merge base. Version bumps require every contiguous numbered migration, while deletion or modification of an existing migration must fail independently. The previous implementation assumed origin/master, inspected only source literals, and covered only a partial durable-tier fixture.

Solution

Render the historical archive state from an available merge base, resolve that base through explicit, GitHub, local, and parent-ref fallbacks, and validate all source, user, and audit migration changes. The gate now rejects missing, skipped, duplicate, or unexpected migration slots and migration deletion or modification. Focused tests cover the reviewed failure cases and a valid multi-step chain.

Verification

  • .venv/bin/python -m devtools test tests/unit/devtools/test_verify_schema_manifest.py: 9 passed, 3 warnings in 7.74s.
  • lane verify at d923d61c: succeeded; gate schema-manifest ... ok (13.9s).
  • .venv/bin/mypy devtools/verify_schema_manifest.py tests/unit/devtools/test_verify_schema_manifest.py: Success.
  • .venv/bin/ruff check devtools/verify_schema_manifest.py tests/unit/devtools/test_verify_schema_manifest.py devtools/gate.py: All checks passed.

Residual risk

The historical state renderer requires the selected merge-base commit to be available locally. Explicit --base and parent-ref fallbacks cover valid shallow and non-origin/master checkouts; an unrelated or unavailable history fails closed.

@Sinity
Sinity enabled auto-merge (squash) September 4, 2026 13:58
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: e31085e4-78a1-4dca-a9c1-4590207701d1


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 4, 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-04T14:05:57.962032Z d923d61 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 merged commit 9df3afc into master Sep 4, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the feature/packet/polylogue-v7wwt branch September 4, 2026 14:04

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

ℹ️ 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_schema_manifest.py Resolved
Comment thread devtools/verify_schema_manifest.py Resolved
Comment thread devtools/verify_schema_manifest.py Resolved
Comment thread devtools/verify_schema_manifest.py Resolved
@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):

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

Sinity added a commit that referenced this pull request Sep 29, 2026
## 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]>
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