Skip to content

fix(batch): let record batch text supersede an automatic discard - #24345

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/rollheld-record-discard
Nov 2, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/rollheld-record-discard

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why

Since 10-28, desktop record conversations have been hidden as "empty" while their real batch transcript sat in quarantine with no way out. A desktop batch_live_v1 record finishes with an empty or thin live transcript, and a sync_update relevance pass discards it (empty_transcript, no_content_words, or a jev/model verdict). Hours later the desktop uploads the audio. Batch projection then reaches replace_record, which treats every discarded row as the user's choice and raises RECORD_TARGET_DISCARDED, a terminal hold on every lane. The release pass frees a held unit only once its target is no longer discarded, and nothing un-discards a pipeline verdict. So release_held reports released=0 by design.

Measured on prod with the ro-prod tier, counts only, at 05:10Z 11-02: 1,491 held units, 126 conversations, 70 owners, all desktop, about 204 h of audio. Every target carries a rule, jev or model relevance_decision; none was discarded by the user. The bursts that looked like they followed backend rolls were single long recordings. For example, the 04:15Z burst of 97 was one 10.5 h conversation whose 96 backfill units uploaded together. Audio and results are retained, so custody was never lost. The user just can't see the conversation.

What

  • fragment_visibility.is_automatic_discard(row): a stored discard counts as automatic only if its relevance receipt is a discard decided by rule, model, jev or deterministic. Two signals mark it as the user's instead:
    • sync_relevance_user_kept: set_conversation_as_discarded writes False and restore writes True. It is the only writer of False.
    • jev_discard_restored, or any user-curation marker.
  • replace_record: an automatic discard no longer blocks the batch text. When the pass places new text, it clears discarded and relevance_decision, so the enrichment pass the projection already schedules (SYNC_UPDATE) reassesses the full record. Sync intake already does this for appended speech (superseded_intake_discard). A pass that places nothing, such as record silence, keeps the verdict.
  • The two redrive re-checks in assign_in_transaction and the release pass's _target_restorable use the same predicate, for record targets only. The release pass that already runs then frees the stranded cohort with no operator step. User discards, and bare discarded=True with no receipt, still hold and never release.
  • Luna r1 found one P2, now fixed: a pass that places no text on an automatically discarded record (for example, record silence) still queued SYNC_UPDATE enrichment, whose fresh verdict could un-hide unchanged text. That pass is now marked repeat-only, so enrichment is skipped and the verdict stands. The marker is transient: it is set after encoding and asserted never to be stored. A regression test fails without it.
  • Luna r2 found two P2s on that no-text path, now fixed:
    • A silent pass can remove provisional segments. The relevance rerun is now skipped only when the transcript is unchanged; a changed transcript is resummarized. The test fails without this fix.
    • A pass that would roll over replans an empty set beside the hidden row. That shape now keeps main's hold. The test pins hold-with-no-write; in this fixture the rollover path also holds without the guard, so the test is not fail-first.

Fail-first evidence

The new tests run against origin/main b89bb978a59d without the fix: 10 failed. That was 4 projection cases and 4 release cases (one per automatic reason) plus 2 replace_record cases. The user-discard guards (7 cases) passed both before and after.

Verification (layer: local unit tests, this head)

  • backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST = test_batch_pipeline_hold_recovery.py and test_batch_pipeline_live.py, via bin/omi-heavy, nice 19, with ambient GCP credentials unset: 95 passed.
  • The same runner over the 39 neighbouring unit files that import the changed modules (sync assignment, release, owner chain, fragment visibility, smart merge, size rollover): all passed.
  • scripts/check_conversation_lifecycle_writes.py: passed.
  • Prod dry run (release_dryrun.py, read-only): it replicates every release refusal against field-masked reads. Under this predicate, all 1,491 held units would release, and 0 are user discards.

Safety

  • No double write: the release reset and the re-projection are the existing transactional, receipt-fenced paths. The tests replay assign after projection and assert the target doesn't change. Release is refused on a second call and stays bounded by MAX_RELEASE_ATTEMPTS.
  • No dropped transcript or audio: the job's audio_uri and committed result are asserted unchanged. Only the quarantined receipt is reset.
  • Quality: an un-hidden record is reassessed by the normal SYNC_UPDATE relevance step, so real filler is re-discarded by the same rules and model as any sync conversation.
  • Cost (inference): one enrichment pass per affected conversation, for 126 now and a handful per day after. No STT re-spend, because results are reused.

Deploy: backend, backend-sync and backend-integration (the projection runs in backend-integration). Once it serves, the release scan reaches every held row within about 75 min: it examined 4,348 rows/h at 04:10–05:10Z, against 5,435 held rows.

Failure-Class: none

Product invariants: INV-DATA-1.

🤖 Generated with Claude Code

Desktop batch_live_v1 records are rule- or model-discarded as empty before
their batch text lands. replace_record treated every discard as the user's,
raising RECORD_TARGET_DISCARDED, a terminal hold the release pass never frees.
Prod 11-02: 1,491 units, 126 conversations, 70 owners held since 10-28.

An automatic discard (pipeline relevance receipt, no user discard, restore or
curation marker) no longer blocks the record replacement; placed text clears
the verdict so the scheduled SYNC_UPDATE enrichment reassesses it. The redrive
re-checks and the release pass use the same predicate, so the existing release
scan frees the stranded cohort. User discards still hold.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-02T05:18:22.195374Z
We couldn’t complete this review. Comment @codex review to try again.
e925418 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

View guided diff | Turn on auto-fix | Re-trigger cubic

Git-on-my-level and others added 2 commits November 2, 2026 12:27
Luna r1 P2: a record pass that places no new text on an automatically
discarded record still scheduled SYNC_UPDATE enrichment, whose fresh verdict
could un-hide unchanged text. Mark that pass repeat-only (a transient marker
set after encoding, never stored) so no relevance rerun is queued.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Luna r2 P2s on the no-text path for an automatically discarded record:
- a silent pass can remove provisional segments; only skip the relevance
  rerun when the transcript is unchanged, so a changed one is resummarized;
- a pass that would roll over replans an empty set beside the hidden row;
  keep main's hold for that shape instead.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit a253523 into main Nov 2, 2026
64 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/rollheld-record-discard branch November 2, 2026 06:05
Git-on-my-level added a commit that referenced this pull request Nov 2, 2026
…4361)

## Why

The held-unit release scan keeps its keyset cursor in memory on the
per-instance `Projector`. Every backend-integration instance start
(scale-out, roll or recycle) begins again at page one, and an instance
never lives long enough to wrap the whole set.

Measured on prod with the ro-prod tier, counts only, at 06:55Z 11-02: of
**16,932** `quarantine_held` result rows in scan order (`__name__`),
release attempts exist only in deciles 0–1. **Deciles 2–9 carry no
attempt at all.** The scan examined about 4,750 rows/h, but always the
same front rows. Any held unit that becomes releasable, including the
1,491 desktop units #24345 makes releasable, waits indefinitely unless
it happens to sort early.

## What

- `load_release_cursor` and `save_release_cursor`
(`database/batch_pipeline_projection_release.py`) keep the cursor in one
`{namespace}_control` doc, `projection_release_cursor`.
- The doc has no scheduler fields (`p*_active`, `p*_service`), so the
control-shard queries never select it.
- `Projector.release_held_scan` resumes from that cursor when its
in-memory cursor is empty, which happens on a new instance or after a
wrap. It writes the new position after each pass that examined rows or
moved the cursor; a wrap writes `None`.
- Both helpers are advisory. A failed load starts from the top, and a
failed save only repeats rows the next pass re-checks, since release is
transactional and idempotent. The scan itself never fails on them.
- Concurrent instances may overwrite each other's position. That only
repeats or skips ahead within one pass's span, and every instance keeps
moving forward.
- Cost: one read and one transactional write per pass, about 80 of each
per hour.

## Fail-first evidence


`test_release_scan_resumes_from_the_durable_cursor_after_an_instance_restart`
on `origin/main` `3c329ff7661a`: three fresh scanners all started at
`None` (`[None, None, None]`). With the fix they read `[None, 'held-01',
'held-03']`, and the empty page past the end wraps back to `None`.

## Verification (layer: local unit tests, this head)

`backend/test.sh` through `bin/omi-heavy`, nice 19, with ambient GCP
credentials unset. The file list was the 9 unit files that reference the
release scan, serving maintenance or the release module: release, hold
recovery, serving, quarantine recovery, merge fresh-first, jobstore
shadow seams, revision drain harness, record admission and memories.
**All passed.**

## Side effect, intended

The scan will also reach 3,329 units held on visible record targets
(`provenance_mismatch` holds, 10-29 to 11-01). They already pass every
release check but were never examined. Each one re-projects under the
ordinary transactional provenance fences. It either lands its batch
text, or it re-holds within the existing 3-attempt bound. Audio is
untouched.

## After deploy (expected; measured afterwards)

At about 4,750 rows/h, one full wrap of about 16.9k held rows takes
about 3.6 h. `release_held` summaries should then show the #24345 cohort
releasing across every decile, not only the front.

Deploy: backend-integration (the scan runs there; backend and
backend-sync take it on their next roll).

Failure-Class: none

Product invariants: INV-DATA-1.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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