Repository navigation
fix: make raw materialization replay auditable - #2387
Conversation
Problem Production v8 replay exposed raw_sessions rows that were acquired and parse-clean but absent from index.db. The old repair surface could not replay them as one auditable convergence state, duplicate raw fragments rewrote existing sessions, and split-tier raw-state updates did not persist to source.db. What changed Added a raw_materialization maintenance target that replays only available raw blobs and leaves missing blobs as blocked debt. Parsing can now defer per-batch FTS repair and repair once afterward. Duplicate raw sources with an existing session and at least the same message count skip instead of rewriting. Parsed raw records that produce no new materialized sessions are marked skipped, and split-tier raw-state updates write through source.db. Production evidence Replayed the production v8 archive from source evidence. Final archive state: 15,994 sessions, 5,499,362 messages, 80,654 web constructs, 2,895,128 usage events, and AI Studio materialized to 222 sessions. raw_materialization preview now reports replay 0 with 315 missing-blob rows blocked and preserved. FTS repair reports in sync with triggers present. Verification - devtools test tests/unit/storage/test_repair.py::test_raw_materialization_preview_counts_replayable_rows_without_erasing_missing_blobs tests/unit/storage/test_repair.py::test_raw_materialization_defers_batch_fts_then_repairs_once tests/unit/storage/test_raw.py::TestRawSessionStorage::test_repository_update_raw_state_uses_source_tier tests/unit/pipeline/test_ingest_batch.py::test_write_session_skips_shorter_duplicate_raw_source tests/unit/pipeline/test_ingest_batch.py::test_write_session_skips_equal_count_duplicate_raw_source tests/unit/pipeline/test_ingest_batch.py::test_persist_batch_raw_state_updates_uses_one_typed_update_per_raw tests/unit/pipeline/test_ingest_batch.py::test_persist_batch_raw_state_updates_marks_skipped_raw_before_success tests/unit/pipeline/test_ingest_batch.py::test_persist_batch_raw_state_updates_preserves_validation_only_failure_without_quarantine tests/unit/pipeline/test_parsing_service.py::TestParsingServiceStreaming tests/unit/storage/test_archive_tiers_ddl.py::test_archive_tiers_database_bootstrap_leaves_current_tier_unchanged tests/unit/maintenance/test_idempotency.py::test_supported_targets_cover_ac_required_set tests/unit/core/test_maintenance_targets.py - devtools verify --quick Ref #2308
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (18)
📝 WalkthroughWalkthroughAdds a new ChangesRaw Materialization Repair Flow
Sequence Diagram(s)sequenceDiagram
participant Repair as repair_raw_materialization
participant BlobStore
participant Parse as ParsingService.parse_from_raw
participant Ingest as process_ingest_batch
participant Repo as SessionRepository.update_raw_state
participant FTS as repair_dangling_fts
Repair->>BlobStore: exists(blob_hash)
Repair->>Parse: replay raw_ids
Parse->>Ingest: repair_message_fts
Ingest->>Repo: persist raw validation state
Repair->>FTS: repair dangling rows
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
✨ 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: 7d550d1320
ℹ️ 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".
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Make raw acquisition, parsed duplicate handling, index materialization, and FTS freshness converge as one auditable maintenance path. This adds a
raw_materializationrepair target, fixes duplicate raw replay behavior, and routes split-tier raw-state updates tosource.db.Problem
Production v8 replay exposed raw evidence rows that were acquired and parse-clean but absent from
index.db.sessions. The old behavior could replay duplicate ChatGPT export fragments forever, force-rewrite already-materialized sessions, and report stale raw-materialization debt even after replay. Split archive raw-state updates also went through the index backend instead of the source tier.Solution
raw_materializationmaintenance target that replays available raw blobs and leaves missing blobs as blocked evidence.SessionRepository.update_raw_statethroughsource.dbwhen using split archive tiers.Verification
devtools test tests/unit/storage/test_repair.py::test_raw_materialization_preview_counts_replayable_rows_without_erasing_missing_blobs tests/unit/storage/test_repair.py::test_raw_materialization_defers_batch_fts_then_repairs_once tests/unit/storage/test_raw.py::TestRawSessionStorage::test_repository_update_raw_state_uses_source_tier tests/unit/pipeline/test_ingest_batch.py::test_write_session_skips_shorter_duplicate_raw_source tests/unit/pipeline/test_ingest_batch.py::test_write_session_skips_equal_count_duplicate_raw_source tests/unit/pipeline/test_ingest_batch.py::test_persist_batch_raw_state_updates_uses_one_typed_update_per_raw tests/unit/pipeline/test_ingest_batch.py::test_persist_batch_raw_state_updates_marks_skipped_raw_before_success tests/unit/pipeline/test_ingest_batch.py::test_persist_batch_raw_state_updates_preserves_validation_only_failure_without_quarantine tests/unit/pipeline/test_parsing_service.py::TestParsingServiceStreaming tests/unit/storage/test_archive_tiers_ddl.py::test_archive_tiers_database_bootstrap_leaves_current_tier_unchanged tests/unit/maintenance/test_idempotency.py::test_supported_targets_cover_ac_required_set tests/unit/core/test_maintenance_targets.py— 19 passed.devtools verify --quick— passed locally and in pre-push hook.raw_materializationpreview now reportsreplay 0with315missing-blob rows blocked and preserved;dangling_ftsreports in sync; diagnostics report ok with FTS triggers present and empty convergence debt.Ref #2308
Summary by CodeRabbit
New Features
raw_materialization, including CLI/documentation visibility and replay support.Bug Fixes
Documentation