Repository navigation
fix: prevent silent raw materialization gaps - #2321
Conversation
Raw session artifacts that parse to no sessions now quarantine instead of being stamped as clean, and JSONL stream detection handles drive-cache names such as *.jsonl.txt.json through both the worker and shared decoder paths. Reparse also removes stale sessions for the same raw_id inside the batch transaction so provider redetection does not leave ghost rows.\n\nRaw-materialization debt now recognizes duplicate parsed aliases when the source filename encodes a native session id already materialized for the same origin, including split suffixes like _1. Detection warnings also count as explicit raw-state updates.\n\nVerified with focused pipeline/debt tests and devtools verify --quick. Live production replay materialized 15 affected AI Studio JSONL-cache rows into 6,418 messages and restored FTS exact coverage.\n\nRef #2308
|
Warning Review limit reached
More reviews will be available in 48 minutes and 41 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe PR makes three ingestion-pipeline correctness changes: JSONL/NDJSON source-path detection is broadened to match embedded markers (not just suffixes) in both ChangesIngestion Pipeline Correctness
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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: 33c998c57f
ℹ️ 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".
Problem: the acquisition cursor writer persisted source stat fields into ops.db.ingest_cursor, but RepositoryRawMixin still queried the removed live_cursor table and swallowed the failure. That made known_cursors empty and allowed restart catch-up to keep touching unchanged large source files. What changed: route get_known_source_cursors through the shared cursor query helper so the reader consumes the same ingest_cursor ledger as the writer. Extend the repository mixin regression test to assert the cursor query is forwarded. Verification: devtools test tests/unit/storage/test_repository_insight_runtime.py::test_repository_raw_forwards_query_and_mutation_calls tests/unit/storage/test_archive_tiers_ops_write.py::test_ops_upsert_ingest_cursor_updates_single_row tests/unit/sources/test_live_watcher.py::test_cursor_creates_table_if_missing; devtools verify --quick.
Problem: review found two invariant gaps in the raw-materialization replay patch. Source-path alias suppression could hide parse/blob failures, and stale same-raw session deletion could leave child rows behind when bulk ingest has foreign keys disabled. What changed: limit source-path alias suppression to clean parsed-without-session duplicates. When removing stale same-raw sessions, derive session FK actions from SQLite and manually apply CASCADE/SET NULL semantics before deleting the session row. Verification: devtools test tests/unit/operations/test_archive_debt.py::test_archive_debt_source_path_aliases_do_not_hide_parse_failures tests/unit/pipeline/test_ingest_batch.py::test_process_ingest_batch_sync_replaces_stale_sessions_for_same_raw_id; devtools verify --quick.
|
Addressed the two Codex inline findings in commit 75d0c89:\n\n- Alias suppression is now limited to clean parsed-without-session duplicate rows; parse failures, missing blobs, and pending parses remain visible debt. Added test: tests/unit/operations/test_archive_debt.py::test_archive_debt_source_path_aliases_do_not_hide_parse_failures.\n- Stale same-raw session deletion now manually applies the schema's sessions FK actions while bulk ingest has FK enforcement suspended. Added child-row coverage and PRAGMA foreign_key_check assertion in tests/unit/pipeline/test_ingest_batch.py::test_process_ingest_batch_sync_replaces_stale_sessions_for_same_raw_id.\n\nVerification after the fixes:\n- devtools test tests/unit/operations/test_archive_debt.py::test_archive_debt_source_path_aliases_do_not_hide_parse_failures tests/unit/pipeline/test_ingest_batch.py::test_process_ingest_batch_sync_replaces_stale_sessions_for_same_raw_id\n- devtools verify --quick |
|
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
This PR turns the acquired-but-not-materialized raw-session failure mode into an explicit ingest invariant. JSONL stream detection now handles drive-cache filenames such as
*.jsonl.txt.json, session artifacts that parse to zero sessions are quarantined instead of stamped clean, reparse removes stale same-raw sessions in the same batch transaction, and raw-materialization debt recognizes duplicate raw aliases whose source filenames encode an already-materialized native session id.Problem
Live archive evidence showed raw acquisition could be marked clean while user-visible sessions/messages were absent or wrong. The concrete production case was AI Studio Drive cache files that were actually Claude Code JSONL streams behind a trailing
.jsonsuffix; they had materialized as zero-messageaistudio-drive:*sessions instead of real Claude Code sessions. Treating this as manual repair would leave the same class of bug available to recur.Solution
.jsonl./.ndjson.filenames through the stream parser in both the ingest worker and shared JSON decoder.raw_idbefore writing replacement parse results, inside the ingest batch transaction._1.Live production replay with this source tree:
ac49922f...raw row and restored 782 messages.0rows.messages_fts_docsize=3,987,982, indexable blocks3,987,982.Verification
Focused tests:
Static/generated quick gate:
Push hook reran
devtools verify --quickat33c998c57and passed.Default
devtools verifywas not run because this fresh worktree has no pytest-testmon seed and the command exits with guidance to rundevtools verify --seed-testmonfirst.Follow-up
Targeted replay performance is not acceptable: a 2.2 MiB / 782-message single-row replay spent ~459s in commit/FTS work. That is now live-measured evidence for the dogfooding performance lane.
Ref #2308
Summary by CodeRabbit
Improvements
Bug Fixes