Skip to content

test(sources): directly assert persisted cursor state in live-batch tests - #3305

Merged
Sinity merged 2 commits into
masterfrom
feature/test/strengthen-live-batch-cursor-assertions
Jul 27, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/test/strengthen-live-batch-cursor-assertions

Conversation

@Sinity

@Sinity Sinity commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Strengthens 5 test sites in tests/unit/sources/test_live_batch_support.py that CodeRabbit flagged on #3282 as asserting 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.

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 through LiveBatchProcessor.ingest_files, which does have a CursorStore row, 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 same ingest_files call'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 on CursorStore.record_convergence_debt to 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 drive LiveBatchProcessor via _ingest_full_paths_sync directly — a layer with no CursorStore row of its own (cursor persistence happens one level up, inside ingest_files, confirmed by tracing batch.py). The durable non-retry evidence at this layer is raw_sessions.parse_error staying NULL (what a later full-ingest pass treats as needing retry) plus, for the membership case, the exact-path-scoped raw_session_memberships.decision/revision_authority row. Added those direct checks instead of a cursor.get_record() call that would always return None at 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 --strict on the touched test file → clean.
  • Anti-vacuity proof Gemini AI Studio exports need one reproducible archive path #1: temporarily commented out self._cursor.record_convergence_debt(stage="fts", ...) in polylogue/sources/live/batch.py — the strengthened split-record test failed (assert False on the spy check), where it previously would have passed silently (the manual repair_message_fts_index_sync call masks a missing debt). Reverted after confirming.
  • Anti-vacuity proof feat: unify Gemini export rendering and Drive sync in gmd #2: temporarily forced decisions: dict[str, str] = {} in apply_raw_membership_classification (archive.py) instead of populating from classification.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 further down even got a chance to fail. Reverted after confirming.
  • devtools verify --quick: found pre-existing docs/topology-status.md/docs/plans/topology-target.yaml drift inherited from feat(sources): pre-parse watcher full-ingest candidates off the writer hold #3301 (LiveParseStage added 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 --check now reports all surfaces sync OK.

Ref polylogue-y9d0

🤖 Generated with Claude Code

Sinity and others added 2 commits July 27, 2026 08:38
…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]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 21dd64cf-4844-4187-bcc0-b6a07098399c

📥 Commits

Reviewing files that changed from the base of the PR and between 4b46006 and 82b01b9.

📒 Files selected for processing (3)
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • tests/unit/sources/test_live_batch_support.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/strengthen-live-batch-cursor-assertions

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit fede339 into master Jul 27, 2026
3 checks passed
@Sinity
Sinity deleted the feature/test/strengthen-live-batch-cursor-assertions branch July 27, 2026 06:46
Sinity added a commit that referenced this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant