Repository navigation
fix(backup): complete source recoverability proofs - #4455
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 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: 07a7454d96
ℹ️ 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".
(#4455) Summary Full-evidence backup recovery now proves live-append byte windows and ZIP acquisition payloads across legacy and capture-mode-independent source rows. Each missing source hash without a successful proof is recorded once in `recoverability_unproven` with a typed failure kind, and verification reconciles that exact set against the restored source and blob evidence. Problem The 74kj3 rehearsal left 6,087 source hashes unproven after 25,911 successful replay proofs. Live-append files had grown beyond their recorded payload windows, and Claude AI batch ZIP rows could be replayed despite `capture_mode` and coordinate-shape variation. One Hermes observability file remains a genuine hash mismatch and must stay fail-closed. Solution `raw_sessions` reference projection now carries revision and append-offset evidence. Backup proof production replays `[append_start_offset, append_end_offset)` with exact-length checks, preserves ZIP replay for all source-row shapes, and emits typed residual entries for every missing source hash. Verification replays each successful proof, validates proof and residual uniqueness and kinds, and rejects any residual-set mismatch or source drift. Verification - `uv run ruff format polylogue/daemon/backup.py polylogue/storage/blob_integrity.py tests/unit/daemon/test_backup.py` - `uv run devtools test tests/unit/daemon/test_backup.py tests/unit/storage/test_blob_integrity.py` passed 81 tests with 2 expected ZIP warnings. - `uv run devtools verify --quick` passed format, lint, mypy, rendering, layering, pattern, CI, JavaScript, documentation, schema, oracle, reachability, definition, timestamp, insight, promotion, and privacy checks. - Rebased onto `origin/master` at `a4891e8c6`; the read-only preserved rehearsal probe found 27,361 recoverable source hashes, including 1,095 append segments and 6,966 ZIP payloads. The Hermes residual is typed `hash_mismatch` for `~/.hermes/observability/nemo-relay/atof/events.jsonl`. Residual risk The full 74kj3 backup gate still needs to run on the operational clone. The known Hermes observability hash remains unproven and therefore continues to block verification until its recorded bytes match.
…4587) ## Summary Fixes the eleven verified Codex review findings in the sources / daemon / operations sweep. Each was re-confirmed at this branch's base before being changed; none were taken on faith from the sweep file. ## Findings and what changed | # | PR | Site | Claim | Action | | --- | --- | --- | --- | --- | | 1 | #4455 | `daemon/backup.py` `_source_recoverability_proofs` | a full-snapshot append row is hashed as a byte window | fixed: falls back to the full prefix `[0, end)` when the window does not prove the blob | | 2 | #4457 | `operations/append_acquisition_replay.py` | unbounded `handle.readline()` during replay | fixed: bounded at 1 MiB, matching live acquisition | | 3 | #4506 | `sources/live/deferred_cursor.py` | semantic frontier re-derived from current bytes with no comparison to retained evidence | fixed: recomposed frontier must reproduce the recorded **body** digest | | 4 | #4506 | `sources/origin_specs.py` | ChatGPT derives `inheritance_branch_point` from `mapping.parent`/`mapping.children` | fixed: declared structurally absent | | 5 | #4515 | `sources/live/source_selection.py` | no typed-vs-generic tiebreak, so a typed source loses ownership to a nested generic root | fixed: ownership resolved among sources that accept the path | | 6 | #4539 | `sources/live/watcher.py` | tool-outcome semantics changed without a parser-fingerprint bump | fixed: `live-batched-v2` -> `live-batched-v3` | | 7 | #4549 | `sources/live/batch.py` | legacy promotion commits durably before append planning succeeds; resynthesized cursor never returned | fixed: promotion deferred behind a successful plan; cursor handed back to the caller | | 8 | #4549 | `sources/sqlite_snapshot.py` | `sqlite_sequence` excluded, so insert-then-delete on AUTOINCREMENT yields no digest change | fixed: AUTOINCREMENT state included | | 9 | #4549 | `sources/live/batch.py` | full-head Claude authority computed from the live file | fixed: live prefix must reproduce the retained blob digest | | 10 | #4554 | `parsers/base_support.py` -> write boundary | idless model turn yields `("model_output", None)` and the write rejects the whole session | fixed at the write boundary (see note) | | 11 | #4558 | `sources/origin_specs.py` | fingerprint memo keyed on `(path, mtime, size)` | fixed: keyed by content digest | None were refuted. Master moved while this work ran; `git diff` over all eleven files across that range is empty, so every cited line still described current code. ### Finding 1: live exposure remains unconfirmed The code-level defect is real and now covered by a test. Its **live** reachability is not established: every current production caller of `admit_raw_observation` (`revision_governance.py:825,3995,4126`) passes `prior_head=None`, which never reaches the append arm that writes the full-payload-with-tail-offsets shape. This fixes the defect without claiming it was reachable in production. ### Finding 6: schema-regime classification Classified as **none of the schema-regime classes** -- it is not a schema change. There is no DDL edit and no derived-tier version bump, so no `DerivedDeltaClass` declaration in `storage/sqlite/lifecycle.py` applies; that table is keyed on index-schema version pairs. It is a *parser-semantic* change, whose declared route is the fingerprint bump itself. `base_support.py` is already inside the origin-spec parser-semantic closure (verified: `_semantic_source_paths` for a parser resolves it), so the origin-scoped fingerprint recomputed on its own with #4539. The gap was only the live watcher's hand-written literal. Bumping it marks every existing live cursor as stale, and the watcher routes those sources back through parse on its next pass -- the production convergence route. Nothing forces a rebuild by hand. **Operational consequence:** the first daemon pass after this lands re-ingests every live-watched source once. That is the intended cost of the correction, but it is a real one. ### Finding 10: fixed at the write boundary, not the parser The sweep points at `base_support.py:633-635`. The parser genuinely cannot fix this: `attachment_from_meta` takes `message_id: str | None` and there is no identity to name when it is `None`. The stored message id exists only at the write boundary, which is where the producer is now supplied -- covering both the parser-declared and role-derived paths. The fallback completes missing provenance and never overwrites parser-supplied evidence. ### Findings 3 and 9 are one fix Both derived Claude authority from bytes on disk at planning time rather than from retained evidence, so a rewrite preserving the prefix length inherited the previous observation's authority. Finding 3 (deferred cursor) compares the recomposed frontier's body digest against the recorded one; finding 9 (full-head resynthesis) requires the live prefix to hash to the retained blob. The reconstructed-chain branch already proved its prefix byte by byte and is left alone. Finding 3's check is deliberately on the **body**, not the whole frontier token: `ClaudeSemanticFrontier` is "replaceable header plus stable body", and an equality check on the token broke `test_deferred_claude_cursor_rebases_frontier_after_header_rewrite`, which protects legitimate rebasing onto a rewritten header. ## Verification Anti-vacuity was verified mechanically, not asserted: with all ten source files reverted to master and the new tests kept, every new test fails. ``` git checkout <master> -- <the ten source files> devtools test tests/unit/sources/test_reviewed_acquisition_defects.py \ tests/unit/storage/test_attachment_idless_model_turn.py \ tests/unit/sources/test_live_deferred_append_dedup.py \ tests/unit/sources/test_live_append_cursor_resynthesis.py \ tests/unit/daemon/test_backup.py -n 2 -> 15 failed, 79 passed ``` The 15 are the 13 new tests plus the 2 existing expectations this change updates. `test_backup_still_proves_a_window_shaped_append_row` **passes** on master -- it is the control proving finding 1's fix did not over-generalize into "always read the full prefix". With the fixes restored, the same selection is green: ``` devtools test tests/unit/sources/test_reviewed_acquisition_defects.py -n 2 -> 5 passed devtools test tests/unit/sources/test_live_deferred_append_dedup.py -n 2 -> 8 passed devtools test tests/unit/sources/test_live_append_cursor_resynthesis.py -n 2 -> 13 passed devtools test tests/unit/daemon/test_backup.py \ tests/unit/storage/test_attachment_idless_model_turn.py -n 2 -> 68 passed devtools verify --quick -> all 12 gates ok devtools render all --check -> exit 0, no "out of sync" ``` Collateral selection over the consumers of the changed modules (live watcher, source snapshot, source differential, catchup planning, codex state, and the four attachment suites): ``` devtools test tests/unit/sources/test_live_watcher.py \ tests/unit/sources/test_source_snapshot.py \ tests/unit/sources/test_source_differential.py \ tests/unit/sources/test_live_catchup_planning.py \ tests/unit/sources/parsers/test_codex_state.py \ tests/unit/storage/test_attachment_acquisition.py \ tests/unit/storage/test_attachment_first_class_ids.py \ tests/unit/storage/test_source_attachments.py \ tests/unit/storage/test_attachment_relink.py -n 2 -> 1 failed, 218 passed ``` After the fixture fix below, the one affected file was re-run on its own: ``` devtools test tests/unit/sources/test_live_watcher.py -n 2 -> 125 passed ``` The other eight files were green in the combined run and are untouched by that fixture change; no combined re-run was made, so the "219" total is not claimed as an observed number. The single failure was `test_parser_fingerprint_change_triggers_reingest`, caused by this branch and not inherited. It simulated a fingerprint change by monkeypatching `_PARSER_FINGERPRINT` to the *literal* `"live-batched-v3"`, which finding 6 makes the real value -- so the patch became a no-op, no change was simulated, and no reingest fired. The bump is not miswired; the fixture collided with it. The sentinel now derives from the real constant (`f"{_PARSER_FINGERPRINT}-changed"`), so the test asserts the same behaviour and cannot silently no-op on a future bump. Finding 6's own test (`test_superseded_parser_fingerprint_refuses_append_ planning`) independently proves a `live-batched-v2` cursor refuses append planning, and went red when the constant was reverted. Selected scope only: this proves the selected files, not the corpus. ## Residual risk - **Finding 6 forces a one-time live re-ingest** of every watched source on the next daemon pass. - **Finding 8 changes `sqlite_logical_revision`** for every AUTOINCREMENT database, so previously recorded identities differ once and those sources re-acquire on next observation. Self-healing, but not free. - **Finding 5 changes ownership for overlapping default roots** beyond the reported case: a `.db` under `~/.codex/sessions/` now resolves to `codex-state` rather than `codex`, because only `codex-state` accepts it. That looks correct, but it is a behaviour change the finding did not name. - **Finding 7** delays promotion until planning succeeds, not until the plan is *applied*. Closing that gap needs a larger refactor of the ingest stage. - **Finding 11** reads parser sources instead of stat-ing them. A per-process digest cache keyed on full inode identity including `st_ctime_ns` (which `os.utime` cannot restore) keeps this correct and measurably faster than before: 0.818 ms/call warm vs 1.343 ms/call for the previous stat-keyed signature, over a 449-file / 9 MB closure. - Three tests are reported red on master itself (`test_archive_tiers_api_session_costs_read_index_tier`, `test_existing_same_version_ops_database_receives_additive_call_log`, `test_record_context_delivery_requires_initialized_user_tier`). None are in files this branch touches and none were in the selections run here. --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
|
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
Full-evidence backup recovery now proves live-append byte windows and ZIP acquisition payloads across legacy and capture-mode-independent source rows. Each missing source hash without a successful proof is recorded once in
recoverability_unprovenwith a typed failure kind, and verification reconciles that exact set against the restored source and blob evidence.Problem
The 74kj3 rehearsal left 6,087 source hashes unproven after 25,911 successful replay proofs. Live-append files had grown beyond their recorded payload windows, and Claude AI batch ZIP rows could be replayed despite
capture_modeand coordinate-shape variation. One Hermes observability file remains a genuine hash mismatch and must stay fail-closed.Solution
raw_sessionsreference projection now carries revision and append-offset evidence. Backup proof production replays[append_start_offset, append_end_offset)with exact-length checks, preserves ZIP replay for all source-row shapes, and emits typed residual entries for every missing source hash. Verification replays each successful proof, validates proof and residual uniqueness and kinds, and rejects any residual-set mismatch or source drift.Verification
uv run ruff format polylogue/daemon/backup.py polylogue/storage/blob_integrity.py tests/unit/daemon/test_backup.pyuv run devtools test tests/unit/daemon/test_backup.py tests/unit/storage/test_blob_integrity.pypassed 81 tests with 2 expected ZIP warnings.uv run devtools verify --quickpassed format, lint, mypy, rendering, layering, pattern, CI, JavaScript, documentation, schema, oracle, reachability, definition, timestamp, insight, promotion, and privacy checks.origin/masterata4891e8c6; the read-only preserved rehearsal probe found 27,361 recoverable source hashes, including 1,095 append segments and 6,966 ZIP payloads. The Hermes residual is typedhash_mismatchfor~/.hermes/observability/nemo-relay/atof/events.jsonl.Residual risk
The full 74kj3 backup gate still needs to run on the operational clone. The known Hermes observability hash remains unproven and therefore continues to block verification until its recorded bytes match.