Repository navigation
fix: recover unsealed no-job batch captures with digest-gated backfill - #24104
Conversation
Add a bounded counts-only operator backfill with fresh digest approval, dead-producer and retained-tail proofs, and atomic seal plus canonical job registration. Retain batch obligations before finalizer completion, including the silent-backfill processing fence.
Require serving-role flags for the operator path, binding them into its approval digest rather than resolving job policy from the laptop environment.
Bind exact mutable row state only for entries that can be written. Refused rows retain their scope and disposition in the digest and grant no authority.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Address Luna R1: refuse incomplete or invalid ramp maps before planning, and reset an exhausted keyset cursor so continued bounded runs revisit late matches. Document pass boundaries separately from aggregate backlog settlement.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c086c296b
ℹ️ 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".
| if not await run_blocking( | ||
| db_executor, register_recording, uid, {**conversation_data, **conversation.model_dump()} | ||
| ): | ||
| raise ConversationFinalizationError('record_registration_refused') |
There was a problem hiding this comment.
Fence intentionally discarded captures instead of failing registration
When processing legitimately marks a batch-owned capture as discarded, process_conversation persists that result before reaching this block. register_recording explicitly returns False for discarded conversations, even if their deterministic job already exists, so this now turns a successful relevance discard into ConversationFinalizationError. The pusher handler consequently reports processing_failed and queues a retry instead of reaching the existing fanout claim, which terminally fences discarded rows. Distinguish intentional registration exclusions from failures to persist a required obligation, or fence discarded captures before this check.
Useful? React with 👍 / 👎.
## Summary Adds a content-free replay corpus for the pusher **record path** (seal, sticky upload failure, producer tokens, batch admission barrier) and a runner that drives each trace through the real `routers.pusher` websocket handler. Batch shadow re-runs recognition on stored audio and never exercises this path. Both 10-29/30 live batch stops and the current unsealed no-transcript backlog were on it, so a record-path change had no pre-deploy replay. This gives one: add a trace per incident, in the PR that fixes it. - `backend/testing/record_traces/traces/*.json`: `record-trace/1` fixtures (row seed, websocket sessions as 103/101/104 frames with an upload outcome, expected end state). Durations and protocol shape only: no audio, IDs or user content. - `backend/tests/unit/test_record_traces.py`: replays each trace with the existing strict-Firestore and recording fakes. Finalize-only traces run with `AUDIO_DURABLE_OUTBOX_ENABLED` both off and on. Traces with audio run legacy-only, and the corpus check refuses durable-plus-audio until an outbox fake exists, so a durable replay can never pass without exercising custody. It asserts `sealed`, `upload_failed`, `open_tokens` and whether `require_record_audio_barrier` would admit the row. - Seven goldens pin main `a05342f`: - a reconnect that finalizes with no new audio (unsealed-rca path 1), with and without an earlier audio session; - the `batch_sync_v1` owner; - a legacy owner that is never sealed; - an exhausted upload followed by a clean reconnect; - one session that uploads audio and finalizes; - a drained-pod producer token that blocks the seal, marked `known_gap` for the sealsweep fix (#24104) to flip. - Finding pinned by the exhausted-upload trace: the failed session's producer token stays on the row. This is harmless for admission because `record_upload_failed` is sticky, but a dead-token sweeper must keep requiring `record_upload_failed == false`. Test-only: no runtime code, flags or deploy. ## Test plan - `cd backend && python -m pytest tests/unit/test_record_traces.py -q`: 11 passed locally (7 traces × their modes, plus the corpus shape check). - Bounded pre-push gate passed. Archive listing and tail durability are proved at admission against storage and are not modeled here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Require audio registration unless a server archive is explicitly closed and never received audio, with no failed upload, pending producer or durable bounds. Keep ordinary photo fanout and the silent-backfill processing fence for that case, while unknown or unclosed audio obligations remain retryable.
Preserve main's registration refusal counter and content-free warning inside the reviewed audio-obligation gate, before the retryable refusal. Keep the counter contract test and assert refused registration cannot claim fanout.
Preserve both adjacent seal operator runbooks after the sweeper merge.
|
Integration review response at Grok accepted the production resolution, photo-only obligation guard, retained operator documentation and shared pod-parser compatibility. Its sole FIX-FIRST finding claims That finding is rebutted by the existing outer handler in Both parameters passed in the exact-head |
Keep both adjacent backfill and record-barrier operator documentation.
Classify the persisted processing result before requiring registration. Keep the existing discard and silent fences while retaining revived obligations.
Return to the reviewed finalizer behavior per lead ruling f498ab. Track intentional discard retry churn and a restore-aware correction separately.
|
The intentional-discard finding is tracked in #24110. Lead ruling f498ab explicitly retains the reviewed strict registration behavior for this PR: the observed P2 is bounded retry churn, while skipping registration from a discarded processing model introduces a P1 race if the user restores the durable row before fanout claims it. The prototype was reverted in |
Summary
Completed batch-live captures without a deterministic job can remain unsealed and never reach transcription. Add a one-time operator tool that scans at most 128 conversation references per resumable page, proves retained tails and dead producers, and atomically seals each eligible row with canonical
record_pendingregistration.Dry-run accepts
ro-prodorprod-operator; apply requiresprod-operatorand a fresh--approve-plan-sha256. Output contains aggregate counts, closed dispositions and the plan digest. Private cursor files stay in 0700 Ephemeral scratch directories and are written as 0600. Explicit serving-role admission flags prevent operator environment settings becoming a stored job policy. Failed uploads and privacy-excluded rows stay untouched.The flags file must provide both current batch and retirement ramps; incomplete, nonfinite or non-nested values are refused before planning. An empty discovery page resets the private output cursor for another bounded pass. Repeat passes and reconcile aggregate no-job counts before declaring settlement; an empty page alone is not a completion proof.
The finalizer now fails retryably on registration refusal for audio obligations. Proven closed, never-received server captures retain ordinary photo finalization without an audio job; upload failures, pending producers and unknown/unclosed archives retain the strict gate. Silent backfill registers an existing audio obligation before returning its existing processing fence. Intentional-discard retry churn and a restore-aware correction are tracked in #24110 under lead ruling f498ab; the model-only discard prototype was reverted because a concurrent restore could lose the audio obligation.
Validation
backend/test.shshards: 387 passed, 2 emulator-only tests skipped, including executor/barrier compatibility; throughomi-heavy,nice -n 19andBACKEND_UNIT_TEST_FILE_LIST. Final tree is byte-identical to validated 04e0c76; the discarded prototype's 390-test result is not final-tree evidence.Failure-Class: FC-split-mutation-authority
Line-Count-Exception: backend/utils/conversations/finalizer.py | 792 -> 812 | Retain audio obligations before terminal fanout and preserve main refusal telemetry, ordinary photo finalization for proven-empty archives, and the silent-backfill processing fence.
The backfill uses canonical registration in the seal transaction and shares the retained-tail proof with the existing repair tool. Regression tests enforce privacy/read-before-write fences and refusal before finalizer terminal fanout.