Repository navigation
fix: Carry adoption and bootstrap seals across durable tier rewrites - #5051
Conversation
Adoption is sealed against ArchiveIdentity.durable_id, the inode identity of
source.db and user.db. A released durable migration republishes the tier file,
so the inode changes and the seal can never match again: the live archive's
2026-08-15 receipt was permanently invalidated by the source-030 train applied
the next morning, and every caller of validate_audit_adoption_receipt or
_durable_chain_floor_versions -- relocation included -- has refused it since.
Durable trains already have rebind_released_durable_train_archive_identity
because their identity binding must survive a legitimate move. The adoption
receipt had no equivalent, and it is structurally immutable, so this adds the
missing route as an immutable rebind chain rooted at the receipt's own
checksum: the chain head, not the original seal, is the digest a live archive
must match.
execute_durable_change_train observes the seal before the rewrite and re-seals
after it. Only the archive the receipt was issued for can make that
observation, so the carry needs no attestation and an ordinary migration no
longer strands its own receipt. A receipt stranded before this build has no
such observation left to make -- the identity it was sealed against no longer
exists -- so maintenance migrate-tier audit --rebind-adopted-audit-identity
re-seals it under the evidence adoption itself requires, and only when the
live audit tier still authenticates against its immutable receipt.
The transplant refusal is unchanged: a receipt, with or without its chain,
carried into another archive still names the durable identity of the archive
that issued it, and the self-proving route cannot continue a seal the
recipient never held.
Verification:
devtools test tests/unit/storage/test_durable_change_train.py
tests/unit/storage/test_archive_root_relocation.py -> PASSED
devtools verify --quick -> exit 0
Reverting the chain lookup reproduces
"audit adoption receipt source/user authority mismatch" on an archive that
migrated after adoption. Derived index schema identity moves
d1883887... -> c3aee767...; ops is unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
The .bootstrap marker seals sha256(configured_root + durable_id), the same
inode identity the audit adoption receipt seals. So the first released durable
migration of any directly bootstrapped archive republishes source.db, changes
its inode, and permanently breaks _fresh_durable_bootstrap_versions -- which
every startup reconcile and every chain-floor read goes through. Found while
building the adoption regression: the synthetic archive reproduced it before
it reached the assertion it was written for.
Carry it the same way the adoption seal is carried: execute_durable_change_train
observes the marker's seal before the rewrite and re-seals it after. Only the
archive the marker belongs to can make that observation. The marker's actual
authority -- its recorded bootstrap versions -- is unchanged by the re-seal, so
the chain floor it grants is identical.
Not addressed here: archive-root relocation refuses .bootstrap archives outright
(archive_root_relocation.py:1143), so a freshly built archive that has never
migrated still cannot be relocated at all.
Verification:
devtools test tests/unit/storage/test_durable_change_train.py
tests/unit/storage/test_archive_root_relocation.py -> PASSED
devtools verify --quick -> exit 0
Anti-vacuity: removing the re-seal raises "fresh durable bootstrap marker
durable identity mismatch" from reconcile_durable_change_train_startup.
Derived index schema identity moves c3aee767... -> 97b159a5...; ops unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 37 minutes. 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 (4)
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 |
## Summary `polylogue-7lhl5` reported 33 red tests across `tests/unit/daemon` and `tests/unit/storage`. **31 of the 33 were already fixed** by PRs #5024-#5051 that landed between the bead's measurement commit (`3faacef23`) and current master — verified cluster by cluster in source, not assumed. Reproducing at head gave **5 failed / 5538 passed**, in two new clusters, both in storage. This fixes both, one of which is a real product defect. ## Problem **A durable artifact observation was misreporting supported material as unsupported.** PR #5040 made ingest refuse Hermes SQLite *page images*, because replay already refused them and admitting one would mint a second source authority for content the archive holds under its logical revision. The three failing tests still built page images and asserted `supported_parseable`, so the stale half was straightforward. Rebuilding them on the current contract exposed the real defect: `storage/artifacts/inspection.py::_hermes_state_db_schema_version` still read through `open_readonly_connection`, a plain SQLite open. A logical export is not a SQLite file, so it returned no version — and **every retained Hermes state observation resolved to `unsupported_parseable` with `resolved_package_version=None`**, silently. `looks_like_state_db_path` and `hermes_state._connect_readonly` were both moved onto `open_logical_source` by #4798. This one reader was left behind. **Second cluster: environment, not product.** Python 3.14 made `forkserver` the default start method on Linux, so the first `Process.start()` in a pytest session pays a fresh-interpreter bring-up — **measured at 4.41 s** with a temporary probe, against a `ready.wait(5)` deadline. Only whichever of the two lease tests ran first failed; inserting a throwaway `Process.start()` ahead of them made both pass untouched. The deadline is a liveness bound, not a latency assertion, so it is now a named 60 s constant with the cause recorded. The lease itself is correct and unchanged. ## Solution Read the Hermes state schema version through `open_logical_source`, the same seam its siblings already use. Tests rewritten onto the production acquisition route (`write_logical_export` + `member_export_scope`), plus two added: a page image is refused (`recognized_unparsed`/`binary_database`), and inspecting a retained WAL-mode page image leaves the blob namespace pristine. ## Verification ``` devtools test tests/unit/daemon tests/unit/storage tests/unit/sources/test_revision_backfill.py tests/unit/pipeline/test_malformed_jsonl_accounting.py tests/unit/core/test_verification.py -> 5677 passed, 0 failed (33:55) devtools verify --quick -> exit 0, 15/15 gates ``` Anti-vacuity verified by reverting, with a receipt for each: | Test | Mutation | Result | |---|---|---| | the two export tests | restore `open_readonly_connection` | red (`unsupported_parseable`) | | page-image refusal | drop the `is_declared_logical_export` gate | red | | blob-namespace | that gate **and** `sqlite_immutable=False` | red with `-wal`/`-shm`; either alone stays green | | `test_rebuild_lease_excludes_competing_process` | `LOCK_EX` -> `LOCK_SH` | red | ## Landing order `devtools schema closure polylogue/storage/artifacts/inspection.py` -> **IN**. Both identities were computed rather than inferred: the index identity **moves**, `ffced415…` -> `764f42c7…`; ops unchanged. **Must land before a from-scratch rebuild starts, never during one.** ## Residuals `devtools gate atlas` is red with **124 BLOCKs — identically at the base commit and at this tip.** Inherited doc-staleness in `docs/atlas/storage.md` against `blob_gc.py`, `blob_publication.py`, and `archive_tiers/{source,bootstrap,archive_tiers_specs}.py`. Nothing in this branch is among them, and atlas is not part of `verify --quick`, so it is a separate inherited item — one a full pre-build `devtools verify` will also surface. The full corpus was not re-run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Closes
polylogue-7prd4(P0) and fixespolylogue-ifb4l's mechanism. The indexschema identity moves
d1883887…→97b159a5…, so this must land before anyrebuild starts, never during one.
The defect
_audit_adoption_authority_digestbinds adoption toArchiveIdentity.resolve(root).durable_id— the inode identity ofsource.dband
user.db. Any operation that replaces a durable tier file strands thereceipt permanently, and unlike durable trains (which have
rebind_released_durable_train_archive_identity) there was no rebind route.The live archive is currently unrelocatable for exactly this reason:
stored
386b4f57…vs livecfb05a0f….Shape chosen: an immutable rebind chain, sealed before the rewrite
The receipt is structurally immutable (
O_EXCL+os.link), so it can never berewritten. A rebind is published as the next immutable record
audit-adoption-rebind.<n>.json, chained on the receipt's ownreceipt_sha256and on the previous digest. The chain head, not the original seal, is what a
live archive must match.
execute_durable_change_trainnow observes the seal before the migrationrewrites the tier, and re-seals after. Only the archive the receipt was issued for
can make that observation, so the carry needs no attestation — and an ordinary
released migration no longer strands its own receipt.
Rejected: binding to something that survives a rewrite
There is nothing to bind to. No archive-unique, migration-stable value exists in
source.dboruser.db: there is noarchive_instance_idmirror, the gcblob-namespace marker is post-v35 and absent on the live archive, census ids are
content-derived, and the audit-continuity genesis hash is a constant shared by
every archive.
archive_authority.archive_instance_idis the designed identitybut lives in
audit.db(circular) and is empty on the live archive.That option also could not have rescued the live receipt: the stored digest is a
one-way hash of destroyed inode identity, so a re-seal record is required either
way.
A second blocker found en route — and it would have hit the new archive
The
.bootstrapmarker sealssha256(configured_root + durable_id), so thefirst released migration of any directly bootstrapped archive permanently breaks
_fresh_durable_bootstrap_versions— which every startup reconcile andchain-floor read depends on. Reproduced, not theoretical.
That matters beyond the current archive: the fresh rebuild produces a directly
bootstrapped archive, so its first migration would have broken it the same way.
The same carry is applied.
Transplant is still refused
test_audit_adoption_refuses_a_receipt_from_a_different_archivecopies a donorarchive's
audit.dbplus its whole adoption ledger (receipt + rebind chain)into a second real archive. Validation still raises the authority mismatch, and
the self-proving route refuses to continue a seal the recipient never held.
Anti-vacuity: reverting the chain lookup reproduces exactly
audit adoption receipt source/user authority mismatch.Verification
Schema identity computed, not inferred: index
d1883887…→97b159a5…; opsunchanged. Both edited product files are IN the closure.
Residuals
The live archive is not fixed by this merge. Its receipt was stranded before
this build existed, so it has no pre-rewrite observation left. It needs one
operator-attested re-seal via the new route:
which requires a stopped daemon and sole ownership, and re-seals only when the
live audit tier still authenticates against its immutable receipt. Not run here —
that mutates the live archive. Its original adoption backup evidence has aged off
disk, so no route re-verifying that package could have helped either.
Report-only, still open: relocation refuses
.bootstraparchives outright(
archive_root_relocation.py:1143), so a freshly built archive that has nevermigrated cannot be relocated at all.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK