Repository navigation
Fence the record gap fill against admission and add the option A retained-copy ack (dark) - #24940
Conversation
The closed-record gap fill now holds the drain's own lease while it writes, so no admission lists retained audio mid-fill. A post-write transaction re-checks privacy and that the job is still record_pending under that lease before releasing it; otherwise the outcome is `raced`. A live lease is `skipped_busy`. Any create collision is `skipped_collision`. Behind RECORD_RETAINED_ACK / RECORD_RETAINED_ACK_PERCENT (default off), a jobs-missing upload whose fill ended cleanly gets the existing covered 200 once every WAL sample is proven byte-exact against lossless chunks/ objects in the archive buckets, read pinned to their listed generations. Anything else keeps today's 503. The WAL is decoded once and shared by the fill and the proof, since decoding consumes the uploaded files. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
Codex Review Summary: ✅ CompletedThis 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. |
Pyright flagged outcome as possibly unbound after the finally block. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
There was a problem hiding this comment.
All reported issues were addressed
You’re at about 99% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24d2052ca5
ℹ️ 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".
Measure the write deadline from before the gates take the lease, and bound each create-only piece upload (per request and across retries) inside the lease margin, so a slow upload started before the deadline cannot outlive the fence. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
… proof A cancelled upload cannot stop a storage thread that is still writing, so the serving entry now leaves the lease to lapse instead of releasing it under that write. The retained-ack proof reads each object's sample rate from the listing's span, as admission does. Docs and flag summaries name the gap-fill prerequisite, the real rollback, and the committed lifecycle rules. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7257bef787
ℹ️ 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".
…ping sources The storage write gate does Firestore authority reads with no deadline, so the chunk writer now re-checks the write deadline just before uploading and stops the fill on a piece boundary if it passed. The retained-ack proof now advances by each covering object's matching prefix, so overlapping lossless objects that together hold every sample are acked. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
…-cqxm31 # Conflicts: # backend/docs/feature-flag-registry.md # config/feature-flags.yaml
Main now requires new kill switches that default off to be config_switch, and rollout owners to be lanes under the per-owner backlog cap. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
What changed and why
Follow-up to #24889 (closed-record gap fill, merged dark), built under lead2's be4c23 after David's custody ruling e11df2 (option A). Two parts, race fix first:
record_pendingjob (available_at = now + 600 s) in the same transaction as the privacy fence, sodueand the drain'sclaimskip the row while the fill writes. A live lease isskipped_busy. After the write, one transaction re-checks privacy and that the job is stillrecord_pendingunder this exact lease, then releases it; otherwise the outcome israced(new counter value) and the lease is left to whoever moved the job. Writes stop on a piece boundary 60 s before the lease ends. Any create collision is now alwaysskipped_collision.RECORD_RETAINED_ACK+RECORD_RETAINED_ACK_PERCENT(both default off), a jobs-missing upload whose fill endedwritten/skipped_no_gap/skipped_no_audio/skipped_markerwith a clean settle gets the existingcovered_response()200 ifrecord_retained_ack.provepasses; the shipped phone then marks those WALs synced and sends the next batch. The proof re-listschunks/and counts only lossless single-chunk.bin/.encobjects at 16 kHz in the private-cloud-sync or derived audio bucket, read pinned to the listed generation. Every WAL sample must equal the sample at the same capture time in a counted object, inside[started_at - 1 s, finished_at + 1 s]; privacy is re-checked after the read. Everything else keeps today's 503. The WAL is decoded once and shared by the fill and the proof, because decoding consumes the uploaded files.Hard condition:
RECORD_GAP_FILLstays off until this merges and lead2 re-reviews the fence. The ack rides inside the fill entry, so it is also off until then.Bucket lifecycle (read-only check via Coordkit): omi-private-cloud-sync only transitions
chunks/**.batch.{enc,bin}to Coldline (never counted, and not a delete); the derived bucket has no rules. The batch-pipeline staging bucket (30-day delete) is never listed bylist_audio_chunks, and the proof now explicitly refuses to count any object outside the two archive buckets.Change note:
backend/docs/listen_pusher_pipeline/changes/2026-11-08-record-gap-fill-fence-and-retained-ack.md.Product invariants affected
none
How it was verified
pytest tests/unit/test_record_gap_fill.py tests/unit/test_sync_admission_diagnostics.py tests/unit/test_reason_label_enums.py: 117 passed.live_upload,record_gap_fill,registered_record_responseorreason_label: 1265 passed.test_sync_capture_time_skew.pyandtest_sync_cloud_tasks.pyfail 12 tests identically on cleanorigin/main(pre-existing, unrelated).make preflightandscripts/pr-preflight --pr-body-file: 40 checks passed.scripts/check_feature_flag_registry.py: OK.Tests
In
backend/tests/unit/test_record_gap_fill.py:skipped_busy);live.drain_recordingsrun mid-fill admits nothing and admits after; a job moved mid-fill (state change or foreign lease) israced, never acked, and its lease is untouched; a privacy block at the recheck israced.skipped_bytes_differ; a WAL hole the fill stopped at isskipped_uncovered; gate refusals are never proven; privacy block at the ack recheck isskipped_privacy; a replaced object fails the generation-pinned read (failed); enhanced.encfill objects count; multi-batch walk (batch 1 already held, batch 2 filled) acks both and admission's tail passes; real decoder on real WAL files; Opus /.opus.enc/ batch / raw-live sources never count or get read; WAL outside the record window is refused before any listing; objects outside the archive buckets never count; the call site answers the covered 200 when acked and keeps the 503 otherwise.UI evidence
UI-Evidence: none -- backend only
Failure class (fixes)
Failure-Class: none
Generated by Claude Code
Tuning
Both knobs are new and only bound the dark retained-ack proof (RECORD_RETAINED_ACK, default off).