Repository navigation
test(sources): directly assert persisted cursor state in live-batch tests - #3305
Conversation
…ests Problem: CodeRabbit's review on #3282 flagged 5 spots in test_live_batch_support.py where passing tests asserted cursor-complete/ non-retryable/deferred-debt behavior only indirectly, via the in-memory succeeded/failed batch-result lists, rather than the durable state those claims are actually about. None were bugs -- the assertions were correct, just less protective against a future regression than they could be. What changed: strengthened 5 sites with direct checks of the persisted state each comment already claims to hold: - test_incomplete_full_jsonl_capture_retries_without_losing_split_record: spies on CursorStore.record_convergence_debt to prove the deferred FTS debt row was actually recorded for the session before this same ingest_files call's own synchronous convergence consumes it again (list_convergence_debt() after the call is empty either way, so reading final state alone cannot distinguish "recorded then cleared" from "never recorded"). - test_live_multi_session_divergence_reopens_raw_authority, test_live_third_raw_reunifies_with_backfill_retired_siblings, test_bundle_replay_respects_unconvertible_single_session_head, test_single_session_full_cannot_overwrite_divergent_membership_head: these all drive LiveBatchProcessor via _ingest_full_paths_sync directly, a layer that has no CursorStore row of its own (cursor persistence lives one level up, in ingest_files). The actual durable non-retry evidence at this layer is raw_sessions.parse_error staying NULL (what a future full- ingest pass would treat as needing retry) plus, for the membership case, the exact-path-scoped raw_session_memberships.decision/revision_authority row -- added those checks instead of a nonexistent cursor.get_record(). Verification: - devtools test tests/unit/sources/test_live_batch_support.py -> 71 passed. - ruff check / ruff format --check tests/unit/sources/test_live_batch_support.py and mypy --strict tests/unit/sources/test_live_batch_support.py -> clean. - Anti-vacuity: temporarily commented out the self._cursor.record_convergence_debt(stage="fts", ...) call in polylogue/sources/live/batch.py -- the strengthened split-record test failed (assert False on the spy check) while it would previously have passed (repair_message_fts_index_sync masks the missing debt). Separately, temporarily forced `decisions: dict[str, str] = {}` in apply_raw_membership_classification (archive.py) instead of populating ambiguous_raw_ids -- the strengthened divergence test failed on the new parse_error/decision/revision_authority assertion (before the file's own pre-existing indirect assertions even reached that state). Both breaks reverted after confirming failure. - devtools verify --quick: pre-existing docs/topology-status.md drift unrelated to this test-only change (confirmed present on the unmodified tree via git stash), not touched here. Ref polylogue-y9d0 Co-Authored-By: Claude <[email protected]>
Problem: #3301 (merged to master) added LiveParseStage without running devtools render topology-projection/topology-status, leaving docs/plans/ topology-target.yaml and docs/topology-status.md out of sync (908 stable modules vs. the committed 907). devtools verify --quick's render-all-check step fails on this pre-existing drift for any branch based on current master, including this one, blocking the pre-push hook. What changed: ran devtools render topology-projection && devtools render topology-status to bring the generated docs back in sync with source. Unrelated to this branch's test-strengthening change (Ref polylogue-y9d0); folded in here only because it was blocking the push gate. Verification: devtools render all --check -> all surfaces sync OK. Co-Authored-By: Claude <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 51 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 Plus Run ID: 📒 Files selected for processing (3)
✨ 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 |
Summary
Strengthens 5 test sites in
tests/unit/sources/test_live_batch_support.pythat CodeRabbit flagged on #3282 as asserting cursor-complete/non-retryable/deferred-debt behavior only indirectly (via the in-memorysucceeded/failedbatch-result lists) rather than the durable state those claims are actually about. None were bugs — the assertions were correct, just less protective against a future regression than they could be.Problem
CodeRabbit's review on #3282 identified 4-5 spots where tests check
result.succeeded == [x]/result.failed == []as a proxy for a comment's claim about persisted state ("cursor advances", "deferred authority debt persisted", "cursor is complete rather than retried", "must remain retryable"), without ever reading the actual persisted record. This was deferred rather than blocking #3282's merge (which fixed the real critical bug CodeRabbit also found in that PR).Solution
test_incomplete_full_jsonl_capture_retries_without_losing_split_record: this test goes throughLiveBatchProcessor.ingest_files, which does have aCursorStorerow, and already checked it directly (final_cursor.byte_offset/failure_count). The specific gap was the FTS deferral claim:record_convergence_debt(stage="fts", ...)gets called mid-parse but the sameingest_filescall's own synchronous convergence pass clears it again before returning — confirmed empirically (cursor.list_convergence_debt()is[]either way, recorded-then-cleared or never-recorded look identical from outside). Added a spy onCursorStore.record_convergence_debtto prove the debt row was actually recorded for the session before this batch's convergence consumes it.test_live_multi_session_divergence_reopens_raw_authority,test_live_third_raw_reunifies_with_backfill_retired_siblings,test_bundle_replay_respects_unconvertible_single_session_head,test_single_session_full_cannot_overwrite_divergent_membership_head: these driveLiveBatchProcessorvia_ingest_full_paths_syncdirectly — a layer with noCursorStorerow of its own (cursor persistence happens one level up, insideingest_files, confirmed by tracingbatch.py). The durable non-retry evidence at this layer israw_sessions.parse_errorstayingNULL(what a later full-ingest pass treats as needing retry) plus, for the membership case, the exact-path-scopedraw_session_memberships.decision/revision_authorityrow. Added those direct checks instead of acursor.get_record()call that would always returnNoneat this layer.Existing indirect assertions are all kept — only additive direct checks were introduced.
Verification
devtools test tests/unit/sources/test_live_batch_support.py→71 passed.ruff check/ruff format --check/mypy --stricton the touched test file → clean.self._cursor.record_convergence_debt(stage="fts", ...)inpolylogue/sources/live/batch.py— the strengthened split-record test failed (assert Falseon the spy check), where it previously would have passed silently (the manualrepair_message_fts_index_synccall masks a missing debt). Reverted after confirming.decisions: dict[str, str] = {}inapply_raw_membership_classification(archive.py) instead of populating fromclassification.ambiguous_raw_ids— the strengthened divergence test failed on the newparse_error/decision/revision_authorityassertion, before the file's own pre-existing indirect assertions further down even got a chance to fail. Reverted after confirming.devtools verify --quick: found pre-existingdocs/topology-status.md/docs/plans/topology-target.yamldrift inherited from feat(sources): pre-parse watcher full-ingest candidates off the writer hold #3301 (LiveParseStageadded without the topology render step) — unrelated to this change but blocking the pre-push gate for any branch off current master. Folded in a small separate regen commit (devtools render topology-projection && devtools render topology-status) so the branch can push;devtools render all --checknow reports all surfaces sync OK.Ref polylogue-y9d0
🤖 Generated with Claude Code