Skip to content

test(storage): Reason the durable-train and backup fixtures in the current regime - #5418

Merged
Sinity merged 4 commits into
masterfrom
work/corpus-clusters
Sep 22, 2026
Merged

Sinity merged 4 commits into
masterfrom
work/corpus-clusters

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

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:

claim measured
klxla: 39 (note: 42) failures 25 — the 13 unbound-sidecar tests are already fixed at head
jgesp: test_maintenance_verify_archive_cli.py 0 — already green
jgesp: test_schema_operator_workflow.py 0 — already green
jgesp: test_backup_verification_read_amplification.py 0 — already green
jgesp: test_backup.py 28 20
"the floor is 1 and the first numbered slot is 002" partly stale — SOURCE_TIER_VERSION and USER_TIER_VERSION are both 2; only audit sits at the floor

For 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,) vs ro 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 new tests/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:

  • The sidecar family (14 tests) — _install_synthetic_migration wrote 002_durable_items.sql with no 002.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.
  • Two marker/skew tests — skewed audit, whose target is now the floor, so a marker grants it nothing either way and the assertion passed for the wrong reason. Now skews 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 = 1 is the current audit version, so the fixture produced no skew at all.
  • test_backup_refuses_source_schema_without_hook_evidence — dropped raw_hook_events.native_id, which no longer appears in BLOB_OWNERS, so nothing refused. Now drops the declared carrier blob_hash.
  • _create_user_v3 → 5 CLI tests — no version 3 exists; every route refused with user schema skew first. 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_audit was green and wrong — 31 is above every version this lineage can hold, so assert_archive_format_lineage skipped 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_intent replayed 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_receipt is 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:

withhold the train sidecar        -> DurableChangeTrainApplyError: missing durable migration train sidecar (×2)
_requires_migration_backup stubbed-> DID NOT RAISE MigrationError (×7)
missing durable tier tolerated    -> DID NOT RAISE RuntimeError
find_durable_migration_collisions -> assert True is False
backup version ordering dropped   -> DID NOT RAISE SchemaSkewError (×3)
raw_hook_events out of BLOB_OWNERS-> DID NOT RAISE RuntimeError   [opposite direction held]
historical prefix payload emptied -> where 0 = len([])            [opposite direction held]

One test was REFUTED and rebuilt. Removing the audit version check from restore admission left test_adopted_audit_restore_rejects_version_skew green — exit 0, 2 passed. Cause: the staged audit tier is WAL and _audit_live_metadata reads it immutable=1, so the PRAGMA user_version stamp stayed in the WAL and the refusal fired on the receipt-vs-file leg instead. The fixture was rebuilt with a checkpoint plus an immutable=1 reader asserting the skew is observable; re-run → DID NOT RAISE MigrationError. Landed as its own commit so the refutation is on the record.

Verification

command exit evidence
devtools test × 4 target files (rebased head) 0 306 passed / 306
same selection, detached at base 1 50 failed / 294 passed / 344
devtools verify --quick 0 25/25 gates
devtools render all --check 0 grep -c 'out of sync' = 0
devtools schema closure × 6 changed files 0 all out

Inherited-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

  1. Two public functions share the name reconcile_durable_change_trains_on_startup. operations/durable_change_train.py:1914 is the real one the daemon imports; bootstrap.py:1016 returns () 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.
  2. Ordinary archive opens no longer prove APPLIED-train continuity. initialize_active_archive_root is 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.
  3. _fresh_durable_bootstrap_versions is 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, and jgesp'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

  • Tests
    • Added reusable durable archive fixture helpers to improve checkpointing, marker management, and schema fingerprint validation.
    • Updated maintenance, backup, and migration tests to reflect the current archive format floor and one-step migration behavior.
    • Expanded coverage for migration refusals, backup validation, schema mismatches, recovery scenarios, and transaction-safety checks.
    • Removed obsolete tests and fixture logic for retired historical schema versions and migration paths.

Sinity and others added 4 commits September 22, 2026 16:19
…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
@Sinity
Sinity force-pushed the work/corpus-clusters branch from 30894c8 to ecf16e2 Compare September 22, 2026 14:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 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-22T14:39:28.271415Z ecf16e2 PR opened
🔒 Security Review ✅ Completed 2026-09-22T14:33:41.293914Z ecf16e2 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 22, 2026 14:27
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 47d654af-489c-4669-9e25-f6552584d23a

📥 Commits

Reviewing files that changed from the base of the PR and between b9f0dba and ecf16e2.

📒 Files selected for processing (6)
  • tests/infra/durable_schema_reset.py
  • tests/infra/durable_tier_fixtures.py
  • tests/unit/cli/test_archive_maintenance_cli.py
  • tests/unit/daemon/test_backup.py
  • tests/unit/storage/test_blob_gc_durable_intent.py
  • tests/unit/storage/test_durable_change_train.py
 ________________________
< Code review is my jam. >
 ------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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 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: 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".

@Sinity
Sinity merged commit 8ade0d5 into master Sep 22, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the work/corpus-clusters branch September 22, 2026 14:39
@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 bf68918):

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