Repository navigation
refactor(ingest): require carried Codex evidence and bound recovery plans - #4339
Conversation
… migration Dropping a durable-tier table without a SOURCE_SCHEMA_VERSION bump or numbered migration makes two physical schemas both claim v38, and strands the disposition row polylogue-20eld owns for this object. The reader/writer retirement stands; the physical drop belongs to the disposition PURGE group. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA
|
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08be7f0930
ℹ️ 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".
…lans (#4339) ## Summary Two lanes assembled into one branch and verified together. | lane | change | | --- | --- | | polylogue-ofry | require Codex sidecar evidence to be carried by acquisition instead of rediscovered from disk | | polylogue-39pdi | bound typed recovery plans for interrupted audit-gated mutations | ## Problem Ingest resolved a Codex record's sidecar by discovering it from disk during the batch and persisting the result into `history_sidecars`. That made the process-pool worker depend on ambient filesystem state at ingest time, so a live edit to a sidecar file could change what a replay produced. ## Solution `_resolve_codex_sidecar_snapshots` now requires the evidence to be present on the acquired record and marks a missing optional snapshot as an empty bundle, which stops the worker treating absence as permission for an ambient read while keeping the normal assembly fallback deterministic. `history_sidecars` consequently has no reader or writer. That is consistent with the disposition already recorded for it — the table is listed in `_PURGE_TABLES` in `schema_disposition.py`, and this lane does not change that classification. Dropping the table itself is a durable-tier change needing its own numbered migration and is not attempted here. ## Verification `devtools verify --quick` → exit 0. `devtools test` over the five changed test files that exist on this branch → `98 collected, exit 0`. `tests/unit/pipeline/test_ingest_batch_codex_sidecar_snapshot.py` is deleted and replaced by `test_ingest_batch_codex_title_evidence.py`. The six deleted cases exercised disk discovery, snapshot persistence, ambient-edit replay stability and transient-discovery handling — behaviours this change removes by design. The two new cases assert the replacement contract: acquisition-carried evidence is used, and missing evidence is not rediscovered. ## Residual risk Docstrings in `sources/assembly.py`, `sources/assembly_codex.py` and `pipeline/services/ingest_worker.py` still describe the resolver as discovering from disk; the function they name exists but no longer behaves that way. Non-codex passthrough and replay stability lose their dedicated tests without direct replacements, being properties of the removed mechanism rather than the new one. `polylogue-cuxz` was dropped from this batch — see below. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA --------- Co-authored-by: Claude Fable 5 <[email protected]>
## Summary #4339 removed the ledger entry that resolved `blob_refs.ref_type='sidecar'`, but nothing removed the relation it describes. `history_sidecars` is still a live source-tier table and the `blob_refs` CHECK still admits `sidecar`, so the writer remains entitled to create rows that the readers could no longer resolve. This restores the owner and the legacy carrier, and couples the two declarations so they cannot drift apart again. ## Problem Ten storage tests were red on master. Both consequences are real, and they point in opposite directions: - `validated_blob_ref_liveness_joins()` no longer resolved `sidecar`, so any archive holding such a row returned `BlobLiveness(state=BLOCKED, blockers=('unknown blob_refs ref_type(s): sidecar',))`. That fails closed — no over-deletion — but GC stalls on data the writer was entitled to write. - `referenced_blob_hashes` omitted sidecar-owned hashes on a legacy archive carrying `history_sidecars.blob_hash`, making those blobs GC-eligible. That one is a data-loss risk on a real archive, and it matters directly to the reindex campaign. Retiring the ref_type from the DDL CHECK instead would have stranded any archive already holding sidecar rows — the wrong direction while the table still exists. ## Solution - `storage/blob_liveness.py` — restored `BlobOwner("source", "history_sidecars", ref_type="sidecar", referent_column="sidecar_id")` - `storage/blob_integrity.py` — `history_sidecars` back in `_LEGACY_DIRECT_BLOB_CARRIERS`, guarded by the existing `_column_exists(conn, table, "blob_hash")` check, so it is inert on the current schema (which uses `content_hash`) and protective on older ones - new `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` — nothing previously coupled the `blob_refs` CHECK vocabulary to the liveness join map, and they live in different files. That gap is what allowed the drift. No test was deleted or weakened; all nine failures were production defects. The `sessions_unenriched` assertion was vacuous — `_enrich_parsed_sessions` returns `False` on both paths, so it could not fail. Its real subject, that a worker never consults the ambient source tree, was still worth protecting, so it now asserts via a call recorder that `discover_sidecars` is never invoked. That is strictly stronger than the previous monkeypatched raise. ## Verification `devtools test` over the three bead-named files plus the ingest-worker file: **84 passed**, was 9 failed / 69 passed. Widened to every `BLOB_OWNERS` / `blob_gc` / `archive_verification` consumer — GC, excision, retention, migrations, maintenance, CLI, daemon — **265 passed**, and **118 passed** in a further run. `devtools verify --quick`: all 18 gates ok, zero `out of sync`. Anti-vacuity, verified by mutation rather than asserted: | Mutation | Red test | |---|---| | Delete the sidecar `BlobOwner` | `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` | | Drop `history_sidecars` from `_LEGACY_DIRECT_BLOB_CARRIERS` | `test_source_capabilities_conserve_mixed_legacy_and_typed_references` | | Reintroduce on-demand `discover_sidecars` in the worker | `test_missing_snapshot_does_not_attempt_on_demand_enrichment` | The first mutation is exactly #4339's edit, so the new guard would have caught the original regression. ## Residual risk `devtools verify` (selected/affected) did not run: it exits 2 with `native_testmon_graph_unavailable` because the lane worktree has no testmon graph. That is the documented refusal, not a failure of this change; the targeted runs above are the compensating evidence and prove their selected scope only. The failure total measured here (9 failed / 69 passed) differs from the 10 / 93 recorded on the bead. Same failure signature and same root cause, measured at a different master point. Filed polylogue-mmf7c separately: `sessions_unenriched` is dead production surface, not just a dead assertion — it feeds a batch summary counter that can never be nonzero, so it reads as positive evidence of no degradation. Left out of scope because removing it touches `ingest_batch`. Closes polylogue-p9txi. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…nd replay (#4382) ## Summary No production route populated `sidecar_snapshot` for a Codex record, so Codex assembly always received `{}` and fell back to the content-heuristic first-prompt title. Ingest and replay now resolve acquired `codex_thread_title` hook events from `source.db` at the point the title ladder needs them. ## Problem `read_codex_thread_title_hook_events` existed and was exported with zero callers. The precedence branch that consumes `hook_event_titles` was unreachable in production and covered only by unit tests that injected the key by hand — which is exactly why the regression went unnoticed. The live archive holds **3,057** acquired `codex_thread_title` hook events across 3,057 distinct sessions, feeding nothing. This is invisible today only because the current index generation predates the title ladder. The exposure is forward-looking: the next reindex — the active campaign — produces heuristic titles where polylogue-foee measured 86.5% resolvable from these events. ## Solution An interim route rather than the generation-bound `TitleEvidenceBundle`, chosen on a measurement. `sidecar_snapshot` is pickled per `ProcessPoolExecutor` submit, and **6,353 of 9,155** Codex `raw_sessions` rows have a NULL `native_id`, so the map cannot be scoped per record — carrying it would cost roughly 2.3 GB of serialization on the very reindex this protects. Both routes instead read `source.db` directly: an indexed point lookup on `idx_raw_hook_events_session`. That is durable archive evidence rather than an ambient source file, so #4339's no-rediscovery invariant holds — `test_ingest_does_not_rediscover_missing_acquisition_evidence` still passes, and a live `history.jsonl` beside the rollout is still ignored. Resolution happens at ladder step 3b either way; only the transport differs. A future bundle replaces two call sites and deletes nothing. - `sources/assembly_codex.py` — `thread_ids` filter on the existing reader; new `resolve_codex_hook_event_titles(archive_root, thread_ids)` - `pipeline/services/ingest_worker.py` — merges into the bundle; an explicitly supplied `hook_event_titles` stays authoritative - `sources/revision_backfill.py` — takes the source connection the replay path already holds, replacing the hardcoded empty `sidecar_data` ## Verification | Command | Result | |---|---| | `devtools test tests/unit/pipeline/test_codex_hook_event_title_production_route.py` | 2 passed | | `devtools test` over assembly, both ingest-worker assembly suites, live state ingest, revision backfill, title census | 204 passed | | `devtools test` over ingest_batch, fts_repair, parsing_service | 114 passed | | `devtools verify --quick` | all gates ok, zero `out of sync` | Anti-vacuity, proven by mutation rather than asserted. Each consumer was broken independently (`if True: return sidecar_data` in the worker; `if False and ...` in replay) and both tests failed with `assert 'opening prompt that must not become the title' == 'Curated thread title from state db'` — the bead's stated failure condition. Neither test injects `hook_event_titles`: the ingest test asserts `record.sidecar_snapshot is None` and the evidence is produced by the real writer over a real `state_5.sqlite` snapshot. ## Residual risk `devtools verify` (selected/affected) could not run — exit 2, `native_testmon_graph_unavailable`, because the lane worktree has no testmon graph. Focused `devtools test` over every file touching the changed code is the compensating evidence and proves that scope only. The live-scan path (`source_walk`/`emitter`) still has no hook-event carrier. It reads `state_5.sqlite` live at ladder step 3, so hook events are gap-fill there rather than the only producer — a real but much smaller gap than the reindex exposure, and deliberately out of scope. Filed polylogue-1e994 for the generation-bound bundle, carrying the measurement that should decide whether it is worth building at all. Closes polylogue-zco96. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…lans (#4339) ## Summary Two lanes assembled into one branch and verified together. | lane | change | | --- | --- | | polylogue-ofry | require Codex sidecar evidence to be carried by acquisition instead of rediscovered from disk | | polylogue-39pdi | bound typed recovery plans for interrupted audit-gated mutations | ## Problem Ingest resolved a Codex record's sidecar by discovering it from disk during the batch and persisting the result into `history_sidecars`. That made the process-pool worker depend on ambient filesystem state at ingest time, so a live edit to a sidecar file could change what a replay produced. ## Solution `_resolve_codex_sidecar_snapshots` now requires the evidence to be present on the acquired record and marks a missing optional snapshot as an empty bundle, which stops the worker treating absence as permission for an ambient read while keeping the normal assembly fallback deterministic. `history_sidecars` consequently has no reader or writer. That is consistent with the disposition already recorded for it — the table is listed in `_PURGE_TABLES` in `schema_disposition.py`, and this lane does not change that classification. Dropping the table itself is a durable-tier change needing its own numbered migration and is not attempted here. ## Verification `devtools verify --quick` → exit 0. `devtools test` over the five changed test files that exist on this branch → `98 collected, exit 0`. `tests/unit/pipeline/test_ingest_batch_codex_sidecar_snapshot.py` is deleted and replaced by `test_ingest_batch_codex_title_evidence.py`. The six deleted cases exercised disk discovery, snapshot persistence, ambient-edit replay stability and transient-discovery handling — behaviours this change removes by design. The two new cases assert the replacement contract: acquisition-carried evidence is used, and missing evidence is not rediscovered. ## Residual risk Docstrings in `sources/assembly.py`, `sources/assembly_codex.py` and `pipeline/services/ingest_worker.py` still describe the resolver as discovering from disk; the function they name exists but no longer behaves that way. Non-codex passthrough and replay stability lose their dedicated tests without direct replacements, being properties of the removed mechanism rather than the new one. `polylogue-cuxz` was dropped from this batch — see below. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA --------- Co-authored-by: Claude Fable 5 <[email protected]>
## Summary #4339 removed the ledger entry that resolved `blob_refs.ref_type='sidecar'`, but nothing removed the relation it describes. `history_sidecars` is still a live source-tier table and the `blob_refs` CHECK still admits `sidecar`, so the writer remains entitled to create rows that the readers could no longer resolve. This restores the owner and the legacy carrier, and couples the two declarations so they cannot drift apart again. ## Problem Ten storage tests were red on master. Both consequences are real, and they point in opposite directions: - `validated_blob_ref_liveness_joins()` no longer resolved `sidecar`, so any archive holding such a row returned `BlobLiveness(state=BLOCKED, blockers=('unknown blob_refs ref_type(s): sidecar',))`. That fails closed — no over-deletion — but GC stalls on data the writer was entitled to write. - `referenced_blob_hashes` omitted sidecar-owned hashes on a legacy archive carrying `history_sidecars.blob_hash`, making those blobs GC-eligible. That one is a data-loss risk on a real archive, and it matters directly to the reindex campaign. Retiring the ref_type from the DDL CHECK instead would have stranded any archive already holding sidecar rows — the wrong direction while the table still exists. ## Solution - `storage/blob_liveness.py` — restored `BlobOwner("source", "history_sidecars", ref_type="sidecar", referent_column="sidecar_id")` - `storage/blob_integrity.py` — `history_sidecars` back in `_LEGACY_DIRECT_BLOB_CARRIERS`, guarded by the existing `_column_exists(conn, table, "blob_hash")` check, so it is inert on the current schema (which uses `content_hash`) and protective on older ones - new `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` — nothing previously coupled the `blob_refs` CHECK vocabulary to the liveness join map, and they live in different files. That gap is what allowed the drift. No test was deleted or weakened; all nine failures were production defects. The `sessions_unenriched` assertion was vacuous — `_enrich_parsed_sessions` returns `False` on both paths, so it could not fail. Its real subject, that a worker never consults the ambient source tree, was still worth protecting, so it now asserts via a call recorder that `discover_sidecars` is never invoked. That is strictly stronger than the previous monkeypatched raise. ## Verification `devtools test` over the three bead-named files plus the ingest-worker file: **84 passed**, was 9 failed / 69 passed. Widened to every `BLOB_OWNERS` / `blob_gc` / `archive_verification` consumer — GC, excision, retention, migrations, maintenance, CLI, daemon — **265 passed**, and **118 passed** in a further run. `devtools verify --quick`: all 18 gates ok, zero `out of sync`. Anti-vacuity, verified by mutation rather than asserted: | Mutation | Red test | |---|---| | Delete the sidecar `BlobOwner` | `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` | | Drop `history_sidecars` from `_LEGACY_DIRECT_BLOB_CARRIERS` | `test_source_capabilities_conserve_mixed_legacy_and_typed_references` | | Reintroduce on-demand `discover_sidecars` in the worker | `test_missing_snapshot_does_not_attempt_on_demand_enrichment` | The first mutation is exactly #4339's edit, so the new guard would have caught the original regression. ## Residual risk `devtools verify` (selected/affected) did not run: it exits 2 with `native_testmon_graph_unavailable` because the lane worktree has no testmon graph. That is the documented refusal, not a failure of this change; the targeted runs above are the compensating evidence and prove their selected scope only. The failure total measured here (9 failed / 69 passed) differs from the 10 / 93 recorded on the bead. Same failure signature and same root cause, measured at a different master point. Filed polylogue-mmf7c separately: `sessions_unenriched` is dead production surface, not just a dead assertion — it feeds a batch summary counter that can never be nonzero, so it reads as positive evidence of no degradation. Left out of scope because removing it touches `ingest_batch`. Closes polylogue-p9txi. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…nd replay (#4382) ## Summary No production route populated `sidecar_snapshot` for a Codex record, so Codex assembly always received `{}` and fell back to the content-heuristic first-prompt title. Ingest and replay now resolve acquired `codex_thread_title` hook events from `source.db` at the point the title ladder needs them. ## Problem `read_codex_thread_title_hook_events` existed and was exported with zero callers. The precedence branch that consumes `hook_event_titles` was unreachable in production and covered only by unit tests that injected the key by hand — which is exactly why the regression went unnoticed. The live archive holds **3,057** acquired `codex_thread_title` hook events across 3,057 distinct sessions, feeding nothing. This is invisible today only because the current index generation predates the title ladder. The exposure is forward-looking: the next reindex — the active campaign — produces heuristic titles where polylogue-foee measured 86.5% resolvable from these events. ## Solution An interim route rather than the generation-bound `TitleEvidenceBundle`, chosen on a measurement. `sidecar_snapshot` is pickled per `ProcessPoolExecutor` submit, and **6,353 of 9,155** Codex `raw_sessions` rows have a NULL `native_id`, so the map cannot be scoped per record — carrying it would cost roughly 2.3 GB of serialization on the very reindex this protects. Both routes instead read `source.db` directly: an indexed point lookup on `idx_raw_hook_events_session`. That is durable archive evidence rather than an ambient source file, so #4339's no-rediscovery invariant holds — `test_ingest_does_not_rediscover_missing_acquisition_evidence` still passes, and a live `history.jsonl` beside the rollout is still ignored. Resolution happens at ladder step 3b either way; only the transport differs. A future bundle replaces two call sites and deletes nothing. - `sources/assembly_codex.py` — `thread_ids` filter on the existing reader; new `resolve_codex_hook_event_titles(archive_root, thread_ids)` - `pipeline/services/ingest_worker.py` — merges into the bundle; an explicitly supplied `hook_event_titles` stays authoritative - `sources/revision_backfill.py` — takes the source connection the replay path already holds, replacing the hardcoded empty `sidecar_data` ## Verification | Command | Result | |---|---| | `devtools test tests/unit/pipeline/test_codex_hook_event_title_production_route.py` | 2 passed | | `devtools test` over assembly, both ingest-worker assembly suites, live state ingest, revision backfill, title census | 204 passed | | `devtools test` over ingest_batch, fts_repair, parsing_service | 114 passed | | `devtools verify --quick` | all gates ok, zero `out of sync` | Anti-vacuity, proven by mutation rather than asserted. Each consumer was broken independently (`if True: return sidecar_data` in the worker; `if False and ...` in replay) and both tests failed with `assert 'opening prompt that must not become the title' == 'Curated thread title from state db'` — the bead's stated failure condition. Neither test injects `hook_event_titles`: the ingest test asserts `record.sidecar_snapshot is None` and the evidence is produced by the real writer over a real `state_5.sqlite` snapshot. ## Residual risk `devtools verify` (selected/affected) could not run — exit 2, `native_testmon_graph_unavailable`, because the lane worktree has no testmon graph. Focused `devtools test` over every file touching the changed code is the compensating evidence and proves that scope only. The live-scan path (`source_walk`/`emitter`) still has no hook-event carrier. It reads `state_5.sqlite` live at ladder step 3, so hook events are gap-fill there rather than the only producer — a real but much smaller gap than the reindex exposure, and deliberately out of scope. Filed polylogue-1e994 for the generation-bound bundle, carrying the measurement that should decide whether it is worth building at all. Closes polylogue-zco96. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…lans (#4339) ## Summary Two lanes assembled into one branch and verified together. | lane | change | | --- | --- | | polylogue-ofry | require Codex sidecar evidence to be carried by acquisition instead of rediscovered from disk | | polylogue-39pdi | bound typed recovery plans for interrupted audit-gated mutations | ## Problem Ingest resolved a Codex record's sidecar by discovering it from disk during the batch and persisting the result into `history_sidecars`. That made the process-pool worker depend on ambient filesystem state at ingest time, so a live edit to a sidecar file could change what a replay produced. ## Solution `_resolve_codex_sidecar_snapshots` now requires the evidence to be present on the acquired record and marks a missing optional snapshot as an empty bundle, which stops the worker treating absence as permission for an ambient read while keeping the normal assembly fallback deterministic. `history_sidecars` consequently has no reader or writer. That is consistent with the disposition already recorded for it — the table is listed in `_PURGE_TABLES` in `schema_disposition.py`, and this lane does not change that classification. Dropping the table itself is a durable-tier change needing its own numbered migration and is not attempted here. ## Verification `devtools verify --quick` → exit 0. `devtools test` over the five changed test files that exist on this branch → `98 collected, exit 0`. `tests/unit/pipeline/test_ingest_batch_codex_sidecar_snapshot.py` is deleted and replaced by `test_ingest_batch_codex_title_evidence.py`. The six deleted cases exercised disk discovery, snapshot persistence, ambient-edit replay stability and transient-discovery handling — behaviours this change removes by design. The two new cases assert the replacement contract: acquisition-carried evidence is used, and missing evidence is not rediscovered. ## Residual risk Docstrings in `sources/assembly.py`, `sources/assembly_codex.py` and `pipeline/services/ingest_worker.py` still describe the resolver as discovering from disk; the function they name exists but no longer behaves that way. Non-codex passthrough and replay stability lose their dedicated tests without direct replacements, being properties of the removed mechanism rather than the new one. `polylogue-cuxz` was dropped from this batch — see below. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA --------- Co-authored-by: Claude Fable 5 <[email protected]>
## Summary #4339 removed the ledger entry that resolved `blob_refs.ref_type='sidecar'`, but nothing removed the relation it describes. `history_sidecars` is still a live source-tier table and the `blob_refs` CHECK still admits `sidecar`, so the writer remains entitled to create rows that the readers could no longer resolve. This restores the owner and the legacy carrier, and couples the two declarations so they cannot drift apart again. ## Problem Ten storage tests were red on master. Both consequences are real, and they point in opposite directions: - `validated_blob_ref_liveness_joins()` no longer resolved `sidecar`, so any archive holding such a row returned `BlobLiveness(state=BLOCKED, blockers=('unknown blob_refs ref_type(s): sidecar',))`. That fails closed — no over-deletion — but GC stalls on data the writer was entitled to write. - `referenced_blob_hashes` omitted sidecar-owned hashes on a legacy archive carrying `history_sidecars.blob_hash`, making those blobs GC-eligible. That one is a data-loss risk on a real archive, and it matters directly to the reindex campaign. Retiring the ref_type from the DDL CHECK instead would have stranded any archive already holding sidecar rows — the wrong direction while the table still exists. ## Solution - `storage/blob_liveness.py` — restored `BlobOwner("source", "history_sidecars", ref_type="sidecar", referent_column="sidecar_id")` - `storage/blob_integrity.py` — `history_sidecars` back in `_LEGACY_DIRECT_BLOB_CARRIERS`, guarded by the existing `_column_exists(conn, table, "blob_hash")` check, so it is inert on the current schema (which uses `content_hash`) and protective on older ones - new `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` — nothing previously coupled the `blob_refs` CHECK vocabulary to the liveness join map, and they live in different files. That gap is what allowed the drift. No test was deleted or weakened; all nine failures were production defects. The `sessions_unenriched` assertion was vacuous — `_enrich_parsed_sessions` returns `False` on both paths, so it could not fail. Its real subject, that a worker never consults the ambient source tree, was still worth protecting, so it now asserts via a call recorder that `discover_sidecars` is never invoked. That is strictly stronger than the previous monkeypatched raise. ## Verification `devtools test` over the three bead-named files plus the ingest-worker file: **84 passed**, was 9 failed / 69 passed. Widened to every `BLOB_OWNERS` / `blob_gc` / `archive_verification` consumer — GC, excision, retention, migrations, maintenance, CLI, daemon — **265 passed**, and **118 passed** in a further run. `devtools verify --quick`: all 18 gates ok, zero `out of sync`. Anti-vacuity, verified by mutation rather than asserted: | Mutation | Red test | |---|---| | Delete the sidecar `BlobOwner` | `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` | | Drop `history_sidecars` from `_LEGACY_DIRECT_BLOB_CARRIERS` | `test_source_capabilities_conserve_mixed_legacy_and_typed_references` | | Reintroduce on-demand `discover_sidecars` in the worker | `test_missing_snapshot_does_not_attempt_on_demand_enrichment` | The first mutation is exactly #4339's edit, so the new guard would have caught the original regression. ## Residual risk `devtools verify` (selected/affected) did not run: it exits 2 with `native_testmon_graph_unavailable` because the lane worktree has no testmon graph. That is the documented refusal, not a failure of this change; the targeted runs above are the compensating evidence and prove their selected scope only. The failure total measured here (9 failed / 69 passed) differs from the 10 / 93 recorded on the bead. Same failure signature and same root cause, measured at a different master point. Filed polylogue-mmf7c separately: `sessions_unenriched` is dead production surface, not just a dead assertion — it feeds a batch summary counter that can never be nonzero, so it reads as positive evidence of no degradation. Left out of scope because removing it touches `ingest_batch`. Closes polylogue-p9txi. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…nd replay (#4382) ## Summary No production route populated `sidecar_snapshot` for a Codex record, so Codex assembly always received `{}` and fell back to the content-heuristic first-prompt title. Ingest and replay now resolve acquired `codex_thread_title` hook events from `source.db` at the point the title ladder needs them. ## Problem `read_codex_thread_title_hook_events` existed and was exported with zero callers. The precedence branch that consumes `hook_event_titles` was unreachable in production and covered only by unit tests that injected the key by hand — which is exactly why the regression went unnoticed. The live archive holds **3,057** acquired `codex_thread_title` hook events across 3,057 distinct sessions, feeding nothing. This is invisible today only because the current index generation predates the title ladder. The exposure is forward-looking: the next reindex — the active campaign — produces heuristic titles where polylogue-foee measured 86.5% resolvable from these events. ## Solution An interim route rather than the generation-bound `TitleEvidenceBundle`, chosen on a measurement. `sidecar_snapshot` is pickled per `ProcessPoolExecutor` submit, and **6,353 of 9,155** Codex `raw_sessions` rows have a NULL `native_id`, so the map cannot be scoped per record — carrying it would cost roughly 2.3 GB of serialization on the very reindex this protects. Both routes instead read `source.db` directly: an indexed point lookup on `idx_raw_hook_events_session`. That is durable archive evidence rather than an ambient source file, so #4339's no-rediscovery invariant holds — `test_ingest_does_not_rediscover_missing_acquisition_evidence` still passes, and a live `history.jsonl` beside the rollout is still ignored. Resolution happens at ladder step 3b either way; only the transport differs. A future bundle replaces two call sites and deletes nothing. - `sources/assembly_codex.py` — `thread_ids` filter on the existing reader; new `resolve_codex_hook_event_titles(archive_root, thread_ids)` - `pipeline/services/ingest_worker.py` — merges into the bundle; an explicitly supplied `hook_event_titles` stays authoritative - `sources/revision_backfill.py` — takes the source connection the replay path already holds, replacing the hardcoded empty `sidecar_data` ## Verification | Command | Result | |---|---| | `devtools test tests/unit/pipeline/test_codex_hook_event_title_production_route.py` | 2 passed | | `devtools test` over assembly, both ingest-worker assembly suites, live state ingest, revision backfill, title census | 204 passed | | `devtools test` over ingest_batch, fts_repair, parsing_service | 114 passed | | `devtools verify --quick` | all gates ok, zero `out of sync` | Anti-vacuity, proven by mutation rather than asserted. Each consumer was broken independently (`if True: return sidecar_data` in the worker; `if False and ...` in replay) and both tests failed with `assert 'opening prompt that must not become the title' == 'Curated thread title from state db'` — the bead's stated failure condition. Neither test injects `hook_event_titles`: the ingest test asserts `record.sidecar_snapshot is None` and the evidence is produced by the real writer over a real `state_5.sqlite` snapshot. ## Residual risk `devtools verify` (selected/affected) could not run — exit 2, `native_testmon_graph_unavailable`, because the lane worktree has no testmon graph. Focused `devtools test` over every file touching the changed code is the compensating evidence and proves that scope only. The live-scan path (`source_walk`/`emitter`) still has no hook-event carrier. It reads `state_5.sqlite` live at ladder step 3, so hook events are gap-fill there rather than the only producer — a real but much smaller gap than the reindex exposure, and deliberately out of scope. Filed polylogue-1e994 for the generation-bound bundle, carrying the measurement that should decide whether it is worth building at all. Closes polylogue-zco96. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA Co-authored-by: Claude Opus 5 (1M context) <[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. |
|
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
Two lanes assembled into one branch and verified together.
Problem
Ingest resolved a Codex record's sidecar by discovering it from disk during the batch and persisting the result into
history_sidecars. That made the process-pool worker depend on ambient filesystem state at ingest time, so a live edit to a sidecar file could change what a replay produced.Solution
_resolve_codex_sidecar_snapshotsnow requires the evidence to be present on the acquired record and marks a missing optional snapshot as an empty bundle, which stops the worker treating absence as permission for an ambient read while keeping the normal assembly fallback deterministic.history_sidecarsconsequently has no reader or writer. That is consistent with the disposition already recorded for it — the table is listed in_PURGE_TABLESinschema_disposition.py, and this lane does not change that classification. Dropping the table itself is a durable-tier change needing its own numbered migration and is not attempted here.Verification
devtools verify --quick→ exit 0.devtools testover the five changed test files that exist on this branch →98 collected, exit 0.tests/unit/pipeline/test_ingest_batch_codex_sidecar_snapshot.pyis deleted and replaced bytest_ingest_batch_codex_title_evidence.py. The six deleted cases exercised disk discovery, snapshot persistence, ambient-edit replay stability and transient-discovery handling — behaviours this change removes by design. The two new cases assert the replacement contract: acquisition-carried evidence is used, and missing evidence is not rediscovered.Residual risk
Docstrings in
sources/assembly.py,sources/assembly_codex.pyandpipeline/services/ingest_worker.pystill describe the resolver as discovering from disk; the function they name exists but no longer behaves that way. Non-codex passthrough and replay stability lose their dedicated tests without direct replacements, being properties of the removed mechanism rather than the new one.polylogue-cuxzwas dropped from this batch — see below.🤖 Generated with Claude Code
https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA