Repository navigation
test(storage): Reason the durable-train and backup fixtures in the current regime - #5418
Conversation
…egime The archive format floor was reset to 1, the v36/v37 legacy climb was removed, and #5275 moved startup reconciliation off the archive bootstrap path for any archive carrying a `.polylogue-format.json`. 25 tests in tests/unit/storage/test_durable_change_train.py still described the regime before all three, and were inherited red at 74e1aa3. Fixture, not contract: - `_install_synthetic_migration` shipped `002_durable_items.sql` with no `002.train.json`. Slot 002 sits above the floor, so production discovery correctly refused it before any behaviour under test ran. The fixture now writes the frozen sidecar production requires, and declares the synthetic tier's canonical DDL so the post-sidecar fresh-DDL parity proof has something to compare against. `canonical_base` lets a test that needs the real tier -- the source hook-event writer probe does -- layer its slot on the shipped DDL instead. - The sequential-replay and hook-probe fixtures bootstrap a real archive at the adoption floor rather than authoring a two-table source.db: both now pass through routes that admit an archive by its format marker. - The unrelated-archive copy in the sequential test checkpoints the WAL first. Without it the copy carried the *previous* slot and the identity refusal under test fired for a version mismatch instead. Regime literals re-expressed against the live declarations: - slots 27/28 -> the first two slots this lineage can own; - source 008/009 collision -> synthetic claims on one slot, since both shipped files were deleted by the reset; - historical inventory projection -> the floor and the source tier's own numbered slot, asserting `excision_policy_projections` disappears at the floor and is present at the target; - the version-skew marker tests skew `source` (target 2) rather than `audit`, whose target is now the floor itself, so the marker granted it nothing either way and the assertion passed for the wrong reason. Refusals that moved rather than disappeared, retargeted at the route that still owns them (`operations.durable_change_train.reconcile_durable_change_ trains_on_startup`, which is what the daemon calls): - APPLIED-train continuity under a lost/replaced durable file; - interrupted mid-apply train reconciliation; - the adopted-audit receipt integrity check, its stale-replacement refusal, and its seeded-head resume. `test_missing_durable_tier_is_never_recreated` now asserts the archive format marker's refusal, which is strictly earlier than the durable-train one it replaced and still leaves `user.db` untouched. `test_migration_sql_cannot_escape_the_transaction` drives `_execute_migration_sql` directly: an `additive-no-backup` file carrying `COMMIT` is refused at discovery now, so the transaction-control guard is only reachable for a backup-requiring slot. The new `test_additive_claim_refusal_precedes_writes` pins that earlier refusal and proves the durable file is byte-identical afterwards. `test_adopted_audit_restore_rejects_version_skew` replaces the legacy-audit- schema case: with the audit floor at 1, `PRAGMA user_version = 1` is the current version, so the fixture produced no skew at all. It now skews by one slot and carries the staged image's real digest, so the copy guard cannot stand in for the admission. The sequential test's inventory-count assertion is scoped to the source tier: a six-tier archive adds corroboration inventories from a different mechanism, and a global total would have made the assertion about that. Verification: devtools test tests/unit/storage/test_durable_change_train.py -> 100 passed (exit 0), from 25 failed at the base SHA. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…egime 26 tests across the backup, maintenance-CLI and blob-GC modules still built durable fixtures the way they were built before the archive format floor was reset to 1. They were inherited red at 74e1aa3. Only part of that was the version regime. Two distinct causes: **WAL visibility, not versions (11 tests).** Durable tiers run in WAL mode, and the backup evidence readers open a tier with `immutable=1` -- correct for the checkpointed copy production hands them (`_copy_referenced_blobs` is called with `backup_root / "source.db"`), and blind to a `-wal` by construction. A fixture that seeded the *live* tier and then read it as backup evidence measured an empty database: `_source_recoverability_proofs` returned no proofs, `PRAGMA user_version` read the pre-stamp value, and a dropped column was still there. These are red for a different reason than the bead names, and no production defect is behind them. `tests/infra/ durable_tier_fixtures.py::seed_durable_tier` makes the write-then-read-as- evidence pattern honest and leaves no sidecar behind. **Regime literals with no producer left.** - `_create_user_v3` hand-wrote a `user_version = 3` user tier. This lineage has no version 3, so every route refused it with `user schema skew` before the migration under test ran. It is replaced by a tier one numbered slot below the runtime target, with the pre-slot-002 `assertions.status` shape *derived from the live canonical DDL* rather than transcribed, so a canonical change cannot silently leave the fixture describing a schema nothing ships. - `test_backup_verify_then_migrate_tier_cli_applies_user_migration_with_ receipt` described a legacy climb to an adoption floor of 10, a v11 train refusing the pre-climb manifest, and a second migrate applying 11..N. The user tier owns exactly one numbered slot, reached in one step. The staleness leg has no producer left and is not re-expressed; the surviving property -- verified backup admits the slot, tier lands at target, the rebuilt column is NOT NULL -- is. - `test_backup_evidence_opens_any_durable_tier_below_the_expected_version` required `expected - 1` to be readable and `0` to be refused. With the audit tier at the floor those are the same value. The readable window is now derived from `ARCHIVE_VERSION_BY_TIER`. - The v21 and v30 source fixtures stamped versions this lineage cannot hold, which the evidence reader refuses outright. Both retain the *catalog* shape that still selects a live production branch (a non-authoritative capability projection; a source without generation tables) and drop the dead integer. - `test_backup_refuses_source_schema_without_hook_evidence` dropped `raw_hook_events.native_id`, which no longer appears in `BLOB_OWNERS`, so nothing refused. It now drops the declared carrier column, `blob_hash`, and is paired against the fallback case that removes the same column under a foreign stamp -- so a blanket refusal cannot pass either. - Fixtures that deliberately edit a durable tier's schema now restate the archive format marker that fingerprints it, instead of tripping `has a historical version-N schema` before the behaviour under test. - The artifact-inventory assertion predated #5275: a backup carries this archive's own format marker and bootstrap receipt as lineage authority. **Deleted.** `test_v33_source_migrates_additively_to_exact_gc_member_intent` replayed source migrations 034 and 035 from a hand-built v33 tier. Both files were deleted by the floor reset and the tables they added are created by fresh DDL, so there is no chain to replay and nothing that can regress what it covered. Unguarded as a result: nothing -- the invariant was "slots 034 and 035 are additive and row-preserving", and those slots no longer exist. Its incidental `gc_generation_members` column assertion is now owned by canonical DDL and the derived schema identity, and the surrounding module still exercises the member-intent outcomes behaviourally. `tests/infra/durable_schema_reset.py` loses both hand-maintained registries it carried for the deleted chain -- the tables introduced at slots 18-29 and the pre-v46 `raw_authority_blockers` shape. Re-creating either would have made a fixture staged at the floor describe a schema this lineage never had. Its one caller, `test_runtime_bootstrap_refuses_source_v31_archive_missing_ audit`, was green *and* wrong: 31 is above every version this lineage can hold, so the lineage check skipped its fingerprint comparison and the test never described a real archive. It is rebuilt at the floor through the production bootstrap route. Verification: devtools test tests/unit/storage/test_durable_change_train.py \ tests/unit/daemon/test_backup.py \ tests/unit/cli/test_archive_maintenance_cli.py \ tests/unit/storage/test_blob_gc_durable_intent.py \ tests/unit/cli/test_maintenance_verify_archive_cli.py \ tests/integration/test_schema_operator_workflow.py \ tests/integration/test_backup_verification_read_amplification.py -> 344 passed (exit 0), from 50 failed at the base SHA. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…efutation
`test_adopted_audit_restore_rejects_version_skew` was green under its own
anti-vacuity mutation. Removing the
`backup_version != ARCHIVE_VERSION_BY_TIER[AUDIT]` leg from the restore
admission left it passing, so it did not pin the leg it named.
Cause: the staged audit tier is in WAL mode and `_audit_live_metadata` reads
it with `immutable=1`. The fixture's `PRAGMA user_version` stamp stayed in
the WAL, the reader still saw the current version, and the refusal fired on
the receipt-vs-file leg instead. The fixture now checkpoints the staged tier
and asserts, through an `immutable=1` reader, that the skew is actually
observable before the admission runs.
Executed after the rebuild:
# ``backup_version != ARCHIVE_VERSION_BY_TIER[ArchiveTier.AUDIT]`` removed
FAIL test_adopted_audit_restore_rejects_version_skew
E Failed: DID NOT RAISE MigrationError
PASS test_adopted_audit_restore_rejects_wrong_archive_application_id
The companion application-id case stays green, so a blanket refusal cannot
pass either.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…f reading it back `gate mypy` refuses `migration_runner.ARCHIVE_DDL_BY_TIER`: the name is a re-import there, not an explicit export. The hook-event probe test needs the DDL `_install_synthetic_migration` just declared, so the fixture returns it rather than having the caller read it back off the patched module or restate the composition. Verification: devtools verify --quick -> 25/25 gates ok (exit 0). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
30894c8 to
ecf16e2
Compare
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. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ecf16e2a51
ℹ️ 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".
|
Closing out open Codex review threads on this PR (evidence checked against master at bf68918):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
The durable-change-train and backup test clusters still reasoned in the pre-reset version regime. Same selection, base vs branch: 50 failed → 344 passed, exit 0.
These are the inherited reds every lane has been working around today — five separate lanes reported them as base-attributable noise in their own verification.
Both bead premises were partly wrong
Measured at head before changing anything:
klxla: 39 (note: 42) failuresjgesp:test_maintenance_verify_archive_cli.pyjgesp:test_schema_operator_workflow.pyjgesp:test_backup_verification_read_amplification.pyjgesp:test_backup.py28SOURCE_TIER_VERSIONandUSER_TIER_VERSIONare both 2; onlyauditsits at the floorFor 11 tests the bead's cause was wrong
They were not failing on versions. Durable tiers run in WAL, and the evidence readers open
immutable=1, which cannot see a-wal. The fixtures seeded the live tier and then read it as backup evidence, so they measured an empty database.Proved with a probe on a freshly bootstrapped archive:
immutable rows: (0,)vsro rows: (1,).No production defect. Production calls
_copy_referenced_blobs(source_db=backup_root / "source.db")— the already-checkpointed copy, never the live tier. Fixed with a newtests/infra/durable_tier_fixtures.py::seed_durable_tier.What was rewritten, and why each was reachable-but-vacuous
Every rewrite replaced an assertion that passed or failed for a reason unrelated to its subject:
_install_synthetic_migrationwrote002_durable_items.sqlwith no002.train.json. Slot 002 is above the floor, so discovery refused before the behaviour ran.test_source_008_009_collision— read migration files off disk that the reset deleted. The property (one slot, two owners, named collision) is regime-free, so it moved to synthetic claims on slot 002.test_historical_source_inventory_removes_only_future_schema_objects— targeted_NEXT_SOURCE_SLOT, which is the runtime target, making the projection a no-op.source, with a precondition assert that the tier sits above its floor.test_adopted_audit_restore_rejects_an_authenticated_legacy_audit_schema—PRAGMA user_version = 1is the current audit version, so the fixture produced no skew at all.test_backup_refuses_source_schema_without_hook_evidence— droppedraw_hook_events.native_id, which no longer appears inBLOB_OWNERS, so nothing refused. Now drops the declared carrierblob_hash._create_user_v3→ 5 CLI tests — no version 3 exists; every route refused withuser schema skewfirst. Replaced by a tier one slot below target whose pre-002 shape is derived from live canonical DDL, with a self-assert if that spelling changes.Out of brief, found and fixed:
test_runtime_bootstrap_refuses_source_v31_archive_missing_auditwas green and wrong — 31 is above every version this lineage can hold, soassert_archive_format_lineageskipped its fingerprint comparison entirely.Also removed two hand-maintained registries in
tests/infra/durable_schema_reset.py(271 → 122 lines) that could only re-create objects no shipped migration introduces — they would have made a floor-staged fixture describe a schema this lineage never had.One deletion, with the unguarded invariant named
test_v33_source_migrates_additively_to_exact_gc_member_intentreplayed source migrations 034/035 from a hand-built v33 tier. Both files are deleted and those tables are fresh DDL. Its invariant was "slots 034/035 are additive and row-preserving", and those slots do not exist, so nothing is left unguarded. Its incidental column assertion is owned by canonical DDL plus the derived schema identity.One leg of
test_backup_verify_then_migrate_tier_cli_applies_user_migration_with_receiptis likewise not re-expressed: it described a v11 train refusing a stale manifest, and the staleness leg has no producer left now the user tier reaches its one slot in one step.Anti-vacuity: 17 mutations executed, and one test refuted
Every mutation was applied to the named production file, run, and reverted. A sample:
One test was REFUTED and rebuilt. Removing the audit version check from restore admission left
test_adopted_audit_restore_rejects_version_skewgreen — exit 0, 2 passed. Cause: the staged audit tier is WAL and_audit_live_metadatareads itimmutable=1, so thePRAGMA user_versionstamp stayed in the WAL and the refusal fired on the receipt-vs-file leg instead. The fixture was rebuilt with a checkpoint plus animmutable=1reader asserting the skew is observable; re-run →DID NOT RAISE MigrationError. Landed as its own commit so the refutation is on the record.Verification
devtools test× 4 target files (rebased head)devtools verify --quickdevtools render all --checkgrep -c 'out of sync'= 0devtools schema closure× 6 changed filesoutInherited-red set diff, programmatic on translated nodeids:
NEW = 0,FIXED = 50.Zero production files changed — the whole diff is under
tests/. Derived identity measured at base and head and identical (index 5274c9cc…,ops 86866235…), so this carries no rebuild-boundary constraint.Production findings — reported, not changed
reconcile_durable_change_trains_on_startup.operations/durable_change_train.py:1914is the real one the daemon imports;bootstrap.py:1016returns()for any format-marked archive — i.e. every current-lineage archive. Production is correct, but three rewritten tests initially went green through the no-op before the lane caught it; they now import the daemon's route. Renaming a public export is broader than this lane.initialize_active_archive_rootis called from read paths, and chore: Fresh schema floor: retire historical chains without confusing o… #5275 removed reconciliation from it for marked archives. Defensible under single-writer-daemon, and it is what the rewritten test now asserts — but a content/inode replacement of a durable file under an APPLIED train is opened by a CLI read path and refused only at the next daemon start._fresh_durable_bootstrap_versionsis called three times in a single startup reconcile pass, each re-corroborating every above-floor tier with a fresh schema inventory (measured: 6 schema inventories, 4 canonical, for a one-tier no-op). Bounded, not a leak, but avoidable work on every daemon start.Neither bead is closed here:
klxla's criteria are met, andjgesp's are met for the four files that were actually red — three files it names were already green.🤖 Generated with Claude Code
https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
Summary by CodeRabbit