Repository navigation
fix(sources): corroborate catch-up cursor skips against index presence - #3223
Conversation
Problem polylogue-emx2 (Finding 8 of perf-investigation-2026-07-18): watcher catch-up trusted ops.db ingest_cursor rows as proof of full materialization. After an index reset/rebuild, source.db retained 14,879 cursors recording "acquired and parsed", but index.db started empty. `_needs_work_from_state`'s hot-skip fast path (byte-size + content-fingerprint match) never checked whether the index actually held a materialized session for the cursor's raw -- it skipped the file outright, leaving 100% of the restore drain to the 1-per-30s background conveyor. PRs #3129 and #3193 (merged) fixed a related but distinct bug: batch.py was misclassifying a raw with a pending/decided membership arbitration as a full-ingest failure. That repaired the accounting *after* a file was resubmitted for ingest, but never addressed the original finding -- the cursor-trust fast path in the watcher still never consults the index at all. Solution `polylogue/sources/live/watcher.py`: - `_archived_cursor_reconciliation_scope` now computes, once per catch-up planning pass (reusing its already-shared source.db/index.db connections), whether the index tier is globally uncorroborated: `_index_lacks_all_corroboration` returns True when source.db holds at least one successfully parsed raw row but index.db's `sessions` table is completely empty -- the exact post-reset signature from Finding 8. - `_needs_work_from_state` (renamed inner decision logic to `_needs_work_from_state_uncorroborated`) now wraps that logic: when it would skip a file and the index is flagged uncorroborated, a cheap per-candidate existence check (`_cursor_skip_corroborated_by_index`, reusing the existing `_archived_cursor_row` raw->session join) decides whether to honor the skip or demote it to "needed". - The gate defaults to trusted (no behavior change) whenever the index has any session at all, so the common case adds zero queries. - Demoted files re-enter the normal batch ingest path, which is already content-hash idempotent, so no bytes are re-acquired for unchanged files (AC: "no re-acquisition of unchanged bytes"). Verification - `devtools test tests/unit/sources/test_live_catchup_planning.py`: 19 passed (16 pre-existing + 3 new). - `devtools test tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_watcher_catchup_order.py tests/unit/sources/test_live_watcher_locking.py`: 101 passed. - `mypy --strict polylogue/sources/live/watcher.py tests/unit/sources/test_live_catchup_planning.py`: no issues. - `devtools verify --quick`: exit 0 (ruff format/check, mypy, render all, topology/layering/manifests/doc-commands/etc. all ok). - Anti-vacuity: reverted only the watcher.py fix (kept the new tests) and reran `test_catch_up_demotes_hot_skip_cursor_when_index_holds_no_sessions` -- it failed with the exact live symptom (`plan.needed == ()` instead of the healthy-cursor file), and `test_catch_up_index_lacks_all_corroboration_detects_empty_index_with_parsed_raw` failed with `AttributeError` for the missing method. Restoring the fix turned both green. Ref polylogue-emx2
|
Warning Review limit reached
Next review available in: 24 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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 |
|
Coordinator review stand-in (CodeRabbit rate-limited — no findings produced). Read the full diff. Assessment:
Verification per PR body: 19+101 focused tests green, mypy --strict clean, quick-gate green. Merging. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92617b3555
ℹ️ 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".
…hermes_verification collapse bug Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
|
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
Watcher catch-up's hot-skip fast path trusted
ops.dbingest cursors asproof of full materialization without ever checking whether
index.dbactually holds the corresponding session. This PR adds a corroboration
check that demotes cursor-trust skips to "needed" when the index tier
cannot back up the claim.
Problem
polylogue-emx2 (Finding 8 of perf-investigation-2026-07-18): after an
index reset/rebuild,
source.dbretained 14,879 ingest cursorsrecording "acquired and parsed", but
index.dbstarted empty._needs_work_from_state's hot-skip fast path (byte-size +content-fingerprint match) never checked whether the index actually
held a materialized session for the cursor's raw — it skipped every
one of those files outright, leaving 100% of the restore drain to the
1-per-30s background conveyor.
PRs #3129 and #3193 (merged, both linked to this bead) fixed a related
but distinct bug:
batch.pywas misclassifying a raw with apending/decided membership arbitration as a full-ingest failure. That
repaired the accounting after a file was resubmitted for ingest, but
never addressed the original finding — the cursor-trust fast path in
the watcher still never consulted the index at all. This PR closes
that remaining gap.
Solution
polylogue/sources/live/watcher.py:_archived_cursor_reconciliation_scopenow computes, once percatch-up planning pass (reusing its already-shared source.db/index.db
connections), whether the index tier is globally uncorroborated:
_index_lacks_all_corroborationreturnsTruewhensource.dbholds at least one successfully parsed raw row but
index.db'ssessionstable is completely empty — the exact post-resetsignature from Finding 8.
_needs_work_from_state(the prior single-purpose decision method,renamed
_needs_work_from_state_uncorroborated) now wraps thatlogic: when it would skip a file and the index is flagged
uncorroborated, a cheap per-candidate existence check
(
_cursor_skip_corroborated_by_index, reusing the existing_archived_cursor_rowraw→session join) decides whether to honor theskip or demote it to "needed".
has any session at all, so the common healthy case adds zero extra
queries.
content-hash idempotent, so no bytes are re-acquired for unchanged
files.
Verification
devtools test tests/unit/sources/test_live_catchup_planning.py:19 passed (16 pre-existing + 3 new).
devtools test tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_watcher_catchup_order.py tests/unit/sources/test_live_watcher_locking.py: 101 passed.mypy --strict polylogue/sources/live/watcher.py tests/unit/sources/test_live_catchup_planning.py: no issues found.devtools verify --quick: exit 0.and reran the suite —
test_catch_up_demotes_hot_skip_cursor_when_index_holds_no_sessionsfailed with the exact live symptom (
plan.needed == ()instead ofthe healthy-cursor file), and
test_catch_up_index_lacks_all_corroboration_detects_empty_index_with_parsed_rawfailed with
AttributeErrorfor the missing method. Restoring thefix turned both green.
devtools verify --all/ integration suite (out ofscope for a focused fix; the touched-file testmon selection above is
the relevant net).
Ref polylogue-emx2