Repository navigation
fix(batch): stop seal repair waiting on a live pusher pod for aged captures (live-producer seal grace) - #24832
Git-on-my-level wants to merge 3 commits into
Conversation
…ptures fail_recording keeps its producer token as a fence, and seal repair refused 'upload_pending' until that long-lived pusher pod restarted. Completed recordings with failed uploads or leaked upload sessions therefore stayed record_pending for hours (359 of 500 due rows sampled 11:45Z). A completed capture finished more than RECORD_SEAL_LIVE_PRODUCER_GRACE_SECONDS (default 3600, 0 restores the old rule) ago now counts as quiesced in seal repair when every token carries producer identity. The full retained-tail proof and unchanged-state fencing still gate the seal; pre-identity tokens still need the operator attestation; partial arming and the pusher runtime seal keep the pod-restart rule. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r-grace # Conflicts: # backend/config/record_seal_rules.py # backend/docs/feature-flag-registry.md
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. |
There was a problem hiding this comment.
2 issues found across 11 files
Confidence score: 3/5
record_seal_repair.pycan clear upload sessions while a producer is still connected, letting it re-register its token and reopen the row. Require proof that the producer is dead before clearing sessions.record_producer_proof.pyapplies the repair-only exemption to sharedseal_refusalbehavior, including no-job backfill where pod proof is required. Gate the exemption behind an explicit repair flag.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/utils/batch_pipeline/record_seal_repair.py">
<violation number="1" location="backend/utils/batch_pipeline/record_seal_repair.py:72">
P1: This clears `record_upload_sessions` for producers that were never proven dead. `producers_quiesced` only checks completion age and a pod name, so a still-connected pusher can re-register its token and reopen the row. The docstring's claim that no producer can append after the grace is not enforced anywhere. Limit this exemption so it does not authorize clearing tokens, or add an enforced quiescence proof before the patch clears them. The `# Only the exact proven-dead map.` comment in `apply_seals` also needs updating.</violation>
</file>
<file name="backend/utils/batch_pipeline/record_producer_proof.py">
<violation number="1" location="backend/utils/batch_pipeline/record_producer_proof.py:124">
P2: The docstring calls this repair-only, but nothing restricts it to repair. `seal_refusal` is shared with the no-job backfill, whose comment says token rows need pod proof. Gate the exemption behind an explicit repair flag, or keep it out of the nojob path.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| row['record_upload_sessions'], producer_proof, producers_stopped=producers_stopped | ||
| if row.get('record_upload_sessions') and not ( | ||
| producer_tokens_dead(row['record_upload_sessions'], producer_proof, producers_stopped=producers_stopped) | ||
| or producers_quiesced(row, row['record_upload_sessions']) |
There was a problem hiding this comment.
P1: This clears record_upload_sessions for producers that were never proven dead. producers_quiesced only checks completion age and a pod name, so a still-connected pusher can re-register its token and reopen the row. The docstring's claim that no producer can append after the grace is not enforced anywhere. Limit this exemption so it does not authorize clearing tokens, or add an enforced quiescence proof before the patch clears them. The # Only the exact proven-dead map. comment in apply_seals also needs updating.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/batch_pipeline/record_seal_repair.py, line 72:
<comment>This clears `record_upload_sessions` for producers that were never proven dead. `producers_quiesced` only checks completion age and a pod name, so a still-connected pusher can re-register its token and reopen the row. The docstring's claim that no producer can append after the grace is not enforced anywhere. Limit this exemption so it does not authorize clearing tokens, or add an enforced quiescence proof before the patch clears them. The `# Only the exact proven-dead map.` comment in `apply_seals` also needs updating.</comment>
<file context>
@@ -67,8 +67,9 @@ def seal_refusal(
- row['record_upload_sessions'], producer_proof, producers_stopped=producers_stopped
+ if row.get('record_upload_sessions') and not (
+ producer_tokens_dead(row['record_upload_sessions'], producer_proof, producers_stopped=producers_stopped)
+ or producers_quiesced(row, row['record_upload_sessions'])
):
return 'upload_pending'
</file context>
| return True | ||
|
|
||
|
|
||
| def producers_quiesced(row, tokens, now=None): |
There was a problem hiding this comment.
P2: The docstring calls this repair-only, but nothing restricts it to repair. seal_refusal is shared with the no-job backfill, whose comment says token rows need pod proof. Gate the exemption behind an explicit repair flag, or keep it out of the nojob path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/batch_pipeline/record_producer_proof.py, line 124:
<comment>The docstring calls this repair-only, but nothing restricts it to repair. `seal_refusal` is shared with the no-job backfill, whose comment says token rows need pod proof. Gate the exemption behind an explicit repair flag, or keep it out of the nojob path.</comment>
<file context>
@@ -119,3 +119,29 @@ def producer_tokens_dead(tokens, proof, *, producers_stopped=False):
return True
+
+
+def producers_quiesced(row, tokens, now=None):
+ """Aged completed capture whose identified producers can no longer append.
+
</file context>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2796cab76a
ℹ️ 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 row.get('record_upload_sessions') and not ( | ||
| producer_tokens_dead(row['record_upload_sessions'], producer_proof, producers_stopped=producers_stopped) | ||
| or producers_quiesced(row, row['record_upload_sessions']) | ||
| ): |
There was a problem hiding this comment.
Preserve the barrier for producers that can still upload
For a completed capture whose finished_at is already older than the grace period, this accepts even a newly registered, actively uploading producer as quiesced. That scenario remains possible: database/record_audio.py:set_record_upload_pending permits registration on completed rows, and routers/pusher.py continues buffering and uploading after begin_recording without enforcing a finish-age cutoff. Repair can therefore clear that producer's token and close the recording while uploads are outstanding. The retained-tail check only establishes that existing audio reaches the finish timestamp; it does not establish that an active producer has finished uploading other spans, and successful uploads do not increment record_upload_revision. Consequently, the unchanged-state fence does not prevent batch admission from freezing an incomplete recording. Require producer stoppage or an enforced uploader fence before treating these tokens as quiesced.
Useful? React with 👍 / 👎.
| Repair-only exemption from the pod-restart proof. Pre-identity (bare True) | ||
| tokens still require the explicit operator attestation. | ||
| """ | ||
| from config.record_seal_rules import live_producer_grace_seconds |
There was a problem hiding this comment.
Move the configuration import to module scope
The new function-local import violates the explicit import rule in backend/AGENTS.md: “All imports at module top level — never inside functions.” Move live_producer_grace_seconds alongside the existing configuration import; its environment lookup still happens when the function is called, so a top-level import does not snapshot the setting.
AGENTS.md reference: backend/AGENTS.md:L166-L168
Useful? React with 👍 / 👎.
| A completed capture finished more than `RECORD_SEAL_LIVE_PRODUCER_GRACE_SECONDS` | ||
| (default 3600; 0 disables) ago no longer waits for its producer pod to restart: | ||
| seal repair treats identified producer tokens as quiesced and still requires the | ||
| full retained-tail proof. Partial arming keeps the pod-restart rule. |
There was a problem hiding this comment.
Add the required pipeline lifecycle change note
This changes audio-custody and conversation-lifecycle behavior, but the commit adds no note under backend/docs/listen_pusher_pipeline/changes/. The applicable backend/AGENTS.md explicitly requires a note in the same PR for these changes. The environment-contract update here is appropriate but does not replace that note; add a dated note covering the new sealing authority, rollout/rollback setting, and verification evidence.
AGENTS.md reference: backend/AGENTS.md:L164-L164
Useful? React with 👍 / 👎.
| # Completed captures older than this stop waiting on a live pusher pod restart; 0 restores that rule. | ||
| liveProducerGraceSeconds: 3600 |
There was a problem hiding this comment.
Wire the grace rollback setting into the seal sweeper
When operators set recordSealRules.liveProducerGraceSeconds=0 to restore the previous producer-proof rule, the production seal sweeper still uses the new 3600-second exemption. The setting is passed only to the worker and repair templates; templates/record-seal-sweeper.yaml:75–81 omits it, although record_seal_sweeper.py calls the same record_seal_repair.plan_seals and apply_seals functions that now invoke producers_quiesced. With the chart's default sweeper configuration (enabled: true, runtimeEnabled: true, mode: apply), fresh hourly jobs can therefore keep sealing live-producer rows after the advertised rollback. Pass the setting into the sweeper template as well so all consumers honor the rollback and custom grace values.
Useful? React with 👍 / 👎.
…efault off (#25018) ## Merge-main push 5 Head: `1ec50a75e6e8c34eca7601e768148be7ac2c9830`. Merge-main resolution under lead2 `1c606e`; reviewed patch behavior unchanged. Merged main: `28b447f847fccfa960fecf17312561ab390e82a6`. A final refetch added only main's v0.12.574 desktop changelog (two files, +14 lines) in a second normal merge. The sole textual conflict in the initial main merge sets `flag_budget.count` to the merged registry's actual 269 names. Both sides are preserved. The token-lease metrics and quiet-check, erasure guard, receipt replay, renewal retention and deterministic messaging test remain unchanged. Incoming main changes are preserved; no new workflow or UI change was authored. Fresh qualification on this exact head: 44 seal/custody/privacy/lifecycle, pusher and messaging unit files yielded 1,517 passed and 86 existing xfails, zero failures/skips (includes all 24 flag-budget tests). Loopback emulator/lifecycle suites yielded 30 + 4 + 34 + 75 + 39 passed, with 3 existing lifecycle xfails; all emulators shut down normally. Expanded preflight passed all 75 checks. Normal full pre-push passed: 3 metadata checks, 75 shared checks, zero backend typecheck errors, 851 index-guard passes in 7 files, and 34 selected backend files yielding 2,141 passed / 86 existing xfails / 4 emulator skips / 144 integration deselections. The skipped/deselected emulator coverage passed independently above. Merge delta from the reviewed head, including incoming main: 347 files, +15,679/-952. Full PR diff against merged main: 124 files, +9,626/-159. Commands use `omi-heavy run --` with inherited GCP credentials and CLOUDSDK variables removed. Local static/synthetic and loopback emulator evidence only. Exactly one normal fast-forward push completed from `9a48272644889eae505df59221bf8ccf5da78281` to this head. Its mandatory full hook also passed with the same 75 shared checks, zero typecheck errors, 851 index-guard passes, and 2,141 passed / 86 existing xfails / 4 emulator skips / 144 integration deselections across 34 selected backend files. No rebase, force push or hook bypass. STOP for delta-only Luna. No deploy or merge. Historical qualifications below remain attributed to their recorded heads. ## Flag count and backfill CI diagnosis Earlier head: `9a48272644889eae505df59221bf8ccf5da78281` (parent `7d9126fd6738173a6324dadedd7b6973267fe793`). The only incremental source change corrects `flag_budget.count` from 267 to 268, equal to the merged `names` count; no flag or behavior is added. Incremental diff: one file, +1/-1 (two changed non-test lines). Shard 8's backfill assertions all passed; its failure was the unchanged 1.00s CPU guard at 1.14s for `test_backfill_cleared_discard_restore_recovers_only_owed_unarmed_debt[None-still_refused0]`. Current main is `4e9c70405c53f8efcaced2fea369910ade355058`. Local exact-node runs pass on both main and L1; the full backfill file passes on both (101 passed, one existing emulator skip each). The flag budget file passes all 24 tests. No backfill code, test, skip, xfail or timing limit changed. Current main CI also passed this case at 0.89s (Backend Unit Tests run 42946411215, shard 7). Local CPU measurements were 0.80s main / 0.52s L1 for the isolated node and 0.41s on both full-file runs. The exercised backfill, conversation restore, summary-delivery and strict transaction fake match main. Classification: the backfill failure is not reproduced on current main or locally on L1; evidence supports a CI timing flake, with no established L1 functional regression. A main-wide failure is NOT confirmed. Backfill is left unchanged; no timing limit or marker is relaxed. Normal full pre-push passed on this head: 75 shared checks, supplied-body metadata validation, zero backend typecheck errors; seven embedded index-guard files yielded 848 passes, and 34 selected backend files yielded 2,140 passed, 86 existing xfails, four emulator skips and 144 integration-marker deselections. Both exact failing nodes passed independently (one test each); full focused L1 files yielded 125 passed and one existing emulator skip. All gates ran through `omi-heavy run --` with inherited GCP credentials and CLOUDSDK variables removed, private HOME/config and disabled metadata discovery. These are local static/synthetic results, separate from remote CI. Exactly one normal fast-forward push completed from the parent to this head. Its mandatory hook also passed with the same 75 shared checks, zero typecheck errors, 848 index-guard passes and 2,140 passed / 86 existing xfails / four emulator skips / 144 integration deselections across 34 selected files. No hook bypass or timing relaxation was used. STOP after one green push for delta-only Luna. No deploy or merge. Previous qualification remains attributed to its recorded head. ## Merge-main push 3 Earlier head: `7d9126fd6738173a6324dadedd7b6973267fe793`. Merge-main resolution under lead2 `1c606e`; reviewed patch behavior unchanged. Merged main: `4e9c70405c53f8efcaced2fea369910ade355058`. The two textual conflicts are mechanical unions of worker labels/lease defaults and the monitoring keep-regex. Erasure, receipt replay, renewal retention, repair coordinator and messaging-test fix remain byte-identical to the reviewed parent. No workflow file changed. Fresh credential-free local qualification through `omi-heavy`: 43 focused unit files, 1,493 passed and 86 existing xfails; loopback emulator suites 30 + 4 + 34 + 75 + 39 passed with 3 existing lifecycle xfails; expanded preflight 75 checks passed; normal full pre-push passed with 3 metadata checks, 75 shared checks, 848 index-guard tests, zero backend typecheck errors and 34 selected files yielding 2,140 passed / 86 existing xfails / 4 emulator skips / 144 integration deselections. Emulator coverage passed separately above. Local static/synthetic and loopback-emulator evidence only. Merge delta: 52 files, +1,670/-49 (incoming main included). Full PR diff: 124 files, +9,626/-159. Stop after this one push for delta-only Luna and refactor-lead's custody delta. No deploy, ramp or production access. Exactly one normal fast-forward push completed from `5bbf8212c634a5c38f151fbdf310cbb839f64e12` to this head. The mandatory push hook also passed with the same shared, typecheck, index-guard and selected-backend results. ## Merge-main push 2 qualification Earlier head: `5bbf8212c634a5c38f151fbdf310cbb839f64e12`. Merged current main: `aa3df45721c8714c58c66f69f81ebbc507c2f526`. Mechanical merge-main resolution under lead2 `1c606e`; reviewed L1 runtime behavior preserved. The resolution keeps L1 token-lease metrics, custody maintenance, erasure admission, receipt replay and renewal retention alongside main's urgent/recent repair scheduling and quiet-check behavior. The equivalent deterministic messaging test stub is retained from main. Test-only composition reconciliations isolate priority fixtures from custody maintenance/metrics-server IO and align the emulator expectation with main's newest-first order; no runtime policy change. Fresh local qualification on this exact head ran through `omi-heavy run --` with inherited GCP credentials and CLOUDSDK variables removed, private test HOME/config, metadata discovery disabled and synthetic fixtures: - Seal/custody/privacy/lifecycle and pusher retention/barrier units: 43 files, 1,493 passed, 86 existing xfails, zero failures/skips; includes 11 messaging cases and 39 priority cases. - Loopback emulator/lifecycle: custody append 30 passed; no-job seal 4 passed; lifecycle/properties 34 passed and 3 existing xfails; held custody 75 passed; recovery custody 39 passed. Emulator shut down normally. - Expanded preflight: 75 checks passed, zero failures. - Normal full pre-push: 75 shared checks, 3 metadata prechecks, zero backend typecheck errors; 34 selected backend files, 2,108 passed, 86 existing xfails, 4 existing emulator skips, 144 integration deselections. The skipped/deselected emulator cases passed separately above. Merge delta from reviewed head: 63 files, +2,876/-138, including imported main. Full PR diff against merged main: 124 files, +9,626/-159. The incoming workflow change is exactly main's blob; no workflow change was authored in this resolution. Local static/synthetic and loopback-emulator evidence does not establish remote CI or deployed behavior. Stop after the single push for delta-only Luna and refactor-lead's custody delta. No deploy, ramp or production access. ## Test-only messaging determinism fix Earlier head: `4328ac0ff96324d99e35ce5ab57c7f69885085d1` (parent `cd63b355ba4fefaff836908b9767c681cd353f8e`). Test-only determinism fix for a main-wide messaging flake: the optional continuity-load failure regression now executes its in-memory reads directly so the mocked digest succeeds without executor startup/deadline races; product code is unchanged. Incremental diff: one test file, +6/-1 (under 20 changed lines). Exact `test_optional_load_failure_returns_plain_window[failure2]`: 1 passed; full `test_messaging_review_fixes.py`: 11 passed, including all three continuity-failure parametrizations. Checks run via `/Users/david/workspace/omi-workspace/bin/omi-heavy run --` with inherited GCP credentials and CLOUDSDK variables removed, private HOME/config, and disabled metadata discovery. Normal full pre-push passed on this head: 75 shared checks, 3 supplied-body metadata checks, zero backend typecheck errors; 34 backend files yielded 2,080 passed, 86 existing xfails, 4 emulator skips and 144 integration deselections. This is local static/synthetic evidence; no remote CI or deployed behavior is claimed. Exactly one fast-forward push completed; its mandatory hook also passed with the same shared/typecheck/backend counts. Stopped for delta-only Luna; no deploy or merge. Historical qualifications below remain attributed to their original commits. ## Refused-receipt retry fix Earlier head: `cd63b355ba4fefaff836908b9767c681cd353f8e` (parent `b0cee99fdeb521e32b1e7c71fc8e52ac5ab27b62`). Addresses the single FIX-FIRST: `finish()` replays only accepted receipts, so a same-job retry after a refused `202/failed` clears its newly acquired token and records the accepted revision and recovery obligation. Accepted receipt replay remains idempotent. Incremental scope: 2 files, +45/-3; 5 changed non-test lines, under the 40-line cap. The new request-level regression first failed on the parent with the retry token still active; it verifies refusal has no revision/recovery effect, then successful retry records revision 8, schedules recovery, clears custody and replays without another write or late count. Focused custody/token-lease/erasure/privacy qualification passed all 520 tests in 20 isolated files (custody append: 84 passed). Normal full pre-push passed: 75 shared checks, 3 supplied-body metadata checks, zero backend typecheck errors; 33 selected backend files yielded 2,069 passed, 86 existing xfails, 4 emulator skips and 144 integration deselections. This is local static/synthetic evidence; no emulator integration run or deployed behavior is claimed. Checks use `/Users/david/workspace/omi-workspace/bin/omi-heavy run --` with inherited GCP credentials and CLOUDSDK variables removed, private HOME/config and disabled metadata discovery. Exactly one fast-forward push completed from the parent to this head. Its mandatory hook also passed: 75 shared checks, 3 supplied-body metadata checks, zero typecheck errors, and the same backend counts. No workflow, deployment, ramp, access or production change. Stop after one green push for delta-only Luna and refactor-lead custody delta. Historical qualifications below remain attributed to their original commits. ## Current merge-main qualification Earlier head: `584188bf8e8af86592e8c211ed8982649aa2fc58`. Merge-main resolution under lead2 `1c606e`; one normal push from `2afc561cdb03a95695f603d3873c1433ebceda55`, merging current main `75dc53a81df78643cf74c7638350fecc9082ebfc`. Resolution preserves both adjacent flag-catalog additions verbatim. Each parent independently added one index and moved the fixed field-index counts from 23/25 to 24/26; the combined registry requires 25 requirements / 27 modes. Only those two test literals were reconciled after the initial expanded preflight exposed the automatic merge collision. The reviewed token-lease metrics, quiet-check, erasure guard, receipt replay and renewal-retention behavior remain unchanged. No workflow or action was changed by this merge resolution. Fresh checks on this exact head ran through `/Users/david/workspace/omi-workspace/bin/omi-heavy run --`, with inherited GCP credentials and CLOUDSDK variables unset, private HOME/config, disabled metadata discovery and synthetic fixtures: - Seal/custody/privacy/lifecycle plus pusher retention/barrier units: 40 files, 1,433 passed, 86 existing xfails, no failures or skips. - Real loopback Firestore and lifecycle: custody append 30 passed; no-job seal 4 passed; lifecycle/properties 34 passed and 3 existing xfails; held custody 75 passed; recovery custody 39 passed. Emulator shut down normally. - Expanded preflight: 75 passed, zero failures. - Normal full pre-push and actual mandatory push hook: both passed; 75 shared checks and 3 supplied-body metadata checks; backend typecheck zero errors. Each selected 33 backend files, yielding 2,068 passed, 86 existing xfails, 4 emulator skips and 144 integration deselections. The skipped/deselected emulator suites passed independently above. - Merge delta from prior PR head: 60 files, +4,899/-66, including incoming main. Current PR diff against merged main: 123 files, +9,583/-159. The 86 strict lifecycle-invariant xfails and 3 lifecycle simulator xfails are existing; no xfail or skip was added. This is local static/synthetic and loopback-emulator evidence; remote CI and deployed behavior are separate. Exactly one normal push completed. STOP for delta-only Luna and refactor-lead's custody delta. No deploy, ramp or production access. Historical qualifications below remain attributed to their original commits. ## Previous L1 renewal-budget fix Earlier head: `2afc561cdb03a95695f603d3873c1433ebceda55` (parent `023db969b7d158ba0c518c5cb318be11b90f6aaa`). Addresses the custody delta 3 FIX-FIRST: a Firestore renewal refusal no longer enters the storage upload retry ladder. The unchanged batch stays in the ready lane with its existing audio-budget reservation, without incrementing upload retries or reaching `fail_recording`/the exhaustion drop. Disconnect-drain renewal retries remain paced and cancellable. The receive-window path is unchanged. Incremental scope: 2 files, +68/-2; 11 changed non-test lines (under the 60-line cap). The two router regressions inject renewal errors beyond `PRIVATE_CLOUD_SYNC_MAX_RETRIES` during a live socket and after disconnect, then verify exact PCM reaches the synthetic upload writer without `fail_recording`. Both regressions fail against the parent and pass with the fix. Focused pusher barrier/abandon, custody and token-lease qualification: 413 passed across 14 isolated files, no failures/skips. Normal full pre-push on this head passed: 75 shared preflight checks, supplied-body metadata validation, backend typecheck with zero errors; 33 selected backend files yielded 2,068 passed, 86 existing lifecycle xfails, 4 existing emulator skips and 144 integration-marker deselections. All qualification ran through `omi-heavy run --` with inherited GCP credentials and CLOUDSDK variables removed, private HOME/config, disabled metadata discovery, and synthetic fixtures. This is local static/synthetic evidence. Stop after the single fast-forward push for delta-only Luna and refactor-lead custody delta on this exact head. No deploy, ramp or production access. Exactly one fast-forward push completed from the parent above to this head. Its mandatory pre-push hook also passed with the same 75 shared checks, zero typecheck errors, and backend counts. _Requested by **David**; ship owner: refactor-lead._ ## What changed and why A vanished producer can otherwise keep audio unsealed indefinitely. Part A replaces that indefinite fence with a server-observed lease inside the existing producer map. Only storage-backed custody appends and frame-bearing pusher batches establish accepted late audio; custody heartbeat renewal requires this upload's explicitly acquired session in the eligible serve cohort. Off preserves original producer behavior, shadow observes, and serve uses the fresh `record-token-lease` cohort. Raw audio is retained throughout. Custody uploads acquire an exact request token before staging, finalize after durable acceptance, and clear refusals without a revision bump. The custody lease covers the production backend-sync timeout plus the named 300s margin (currently 3900s); frame leases default to 3600s. Late audio invalidates the captured upload revision and re-arms create-only partial recovery, including interior holes. Recovery of accepted serve bytes survives mode rollback. Separate recovery jobs are parked as `record_recovery_waiting` while the original publication is unsettled. Old worker images cannot schedule this state. The active repair CronJob and current workers transactionally promote it to `record_pending` only after the original ledger/publication completes, in off, shadow or serve; privacy revocation exits to `privacy_blocked`. This prevents a rolled-back worker from bypassing the publication fence. Normal partial processing retains its existing `partial_retired` exit and inventory rearm. Finish receipts are idempotent across lost commit responses, enroll account-erasure authority before every write, and expire through the active repair CronJob after 24h. Expiry uses the existing server `recorded_at`, covering prior receipt versions. It deletes metadata only, never audio or recovery jobs. Pusher metadata-renewal failures retain receive windows or requeue projection batches before durable storage, and failed registration cannot be resurrected by a same-frame renewal. Persisted `append_late` survives registration retries; late metrics count durable acceptance exactly once. **Landing order:** #24866 remains open and is an adjacent-file integration dependency, not a runtime prerequisite. Land #25018 first after this fresh-main merge. Then merge that resulting main into #24866 and preserve both its seal-gated scheduling/callback changes and this lease/revision protocol in shared transactions; regenerate its flag registry and rerun both focused suites. Do not rebase the published #25018 branch. #24832's age-only grace is superseded/absorbed. Main's staged-input alerts and both exact token-lease split-file payloads are retained in the regenerated union. ## Consolidated privacy review fixes Custody admission now checks the canonical owner/erasure authority before any custody token or raw staging, including missing accounts and active purge. Actual custody uses the same conversation privacy checks as finish/recovery; sync opt-out retains its existing no-custody behavior while still enforcing owner erasure. A missing identified target refuses admission. Finish/recovery logic is unchanged. Archive heartbeats now identify the exact session acquired by this upload. Custody renewal requires that session and an eligible serve cohort; unowned, shadow and non-cohort archives retain read-only late observations without extending any custody token. Ordinary frame renewal and dead-letter behavior are unchanged. No flag, ramp, workflow, access or production change is introduced. Previous merged candidate: `023db969b7d158ba0c518c5cb318be11b90f6aaa` (includes current main `85de1985f0fb4fddd05e0de4b36c1ac68108d81e`). Exact-head verification is recorded below; earlier results remain attributed to their recorded commits. ## Product invariants affected - INV-DATA-1: preserves the existing production customer identity and data plane. The changes in `gcp_backend_listen_helm.yml` and `gcp_backend_pusher.yml` only validate and bind the four shared record-token-lease rollout inputs; they do not change customer-data endpoints, Firebase/Auth/Firestore projects, UID authority, service accounts, credentials or IAM. This is not a customer-data migration. - INV-MEM-4: canonical admission remains the sole Long-term authority; runtime wiring does not add an admission path. ## Failure class (fixes) Failure-Class: FC-state-deadline-without-reader-exit lease_would_expire is a shadow diagnostic, not a persisted job state. Its observation ends with the next planner evaluation: a fresh append restores liveness, exact finish clears the fence, or serve-mode retained-tail/privacy proof permits seal/partial finish. Named exits: producer lease lapse still requires the quiet heartbeat/append predicate plus retained-tail/privacy proof; exact finish clears custody; complete seal and partial finish remain distinct; late audio reactivates the revision. Parked recovery exits through `database/record_recovery_gate.py:promote` after original publication, independent of the mode. Finish receipts exit through `database/record_custody_receipts.py:prune` or account erasure after the bounded retry window. ## How it was verified Source inspection checked the INV-DATA-1 routing guard entry in `.github/checks-manifest.yaml`, the production-data-plane declaration in `backend/utils/cloud_tasks.py`, and the two small workflow diffs. Those diffs add rollout-input validation/binding only. This is static source evidence, with no live customer-data or deployed-artifact verification. Historical runtime/custody results remain attributed to their original tested commits. Local commands use `bin/omi-heavy`, credential-free private test environments and the canonical `backend/test.sh`, with 900s per file. The batched pre-review report records the exact focused, all-backend custody, lifecycle/emulator, alert/telemetry, real PromQL, hook typecheck and expanded preflight results. New custody, nojob and lifecycle property proofs are wired into the emulator CI lane; the checksum-pinned PromQL check runs in both local and CI manifest lanes. The 50ms race now uses event-driven expiry inside enqueue without weakening its one-write assertion. Evidence: `backend/docs/listen_pusher_pipeline/changes/2026-11-10-token-lease-batched-prereview.md` (local validation report). No production access or GCP credentials used; refactor-lead performs the single push and subsequent independent review. ## Rollout Default lease mode remains `off` with serve percent `0`. This branch and this qualification apply no deployment, traffic shift, environment-variable change, access grant or customer-data operation. The workflow additions take effect only on a separately authorized workflow execution; a branch push does not authorize or perform the production rollout. Checked-in defaults remain off. Bind the same four `RECORD_TOKEN_LEASE_*` protected-environment inputs to Cloud Run and the shared producer ConfigMap; GKE pods consume explicit key references. Roll all producers through shadow for 48h before serving. Configure the separately typed repair vector to match, and enable repair serve only after producer rollout is verified. Use a fixed preview epoch in shadow, pin the first serve epoch across the whole ramp/restarts, and require lead2 approval plus P4 auto-revert at 1/10/50/100%. Retune 3600s only from the signal-gap histogram at 10%; require RECORD_GAP_FILL_PERCENT >= 10 before 100%. Mode shadow/off rolls back behavior while preserving already-acquired custody and recovery obligations. An old-image worker rollback parks separate recoveries until a current worker resumes safe promotion. Capacity disclosure: receipt cleanup before 0, after max 10000 metadata receipts per active repair run, with 128-document query pages and a 30s maintenance budget. Recovery promotion adds one bounded waiting-state query and up to 100 transactional publication/privacy checks with a CAS write to each record-pending scan, reusing the existing due-page limit, with a new 60s recheck backoff and a fresh transactional availability CAS. The active production repair CronJob invokes the same bounded promoter (one query, up to 100 checks, 30s) without enabling the idle seal worker; promotion and receipt cleanup have separate 30s phases, at most 60s total before the unchanged audio-repair budget. No raw-audio retention, audio inventory cap (8192), worker concurrency, executor size or production capacity is increased. The receipt collection-group `recorded_at` index is declared in the generated manifest; normal schema readiness gates apply before shipping. ## UI evidence UI-Evidence: none -- backend custody and validation change only ## Source growth declarations Line-Count-Exception: backend/database/firestore_index_registry.py | 2343 -> 2344 | Declare the receipt-expiry collection-group index at its schema owner. Line-Count-Exception: backend/routers/pusher.py | 2032 -> 2051 | Renew frame custody at the existing appender; retain metadata-refused batches under the audio budget without consuming storage retries. Line-Count-Exception: backend/routers/sync.py | 3830 -> 3852 | Keep the serve-cohort guard adjacent to the existing manifest heartbeat. Line-Count-Exception: backend/testing/listen_pusher_stack/run.py | 1980 -> 1988 | Bound numerical thread pools in every isolated lifecycle child and restart. ## Recovered-head qualification Registry completion is `41a173de1d79959c5b5ab26ba6e9a8c785db29fc`; the synthetic-account fixture is `70a31d885774680bf576d97712575207ae37d64a`. The earlier test-only completion is `4152755f9c4b5471e6f9841d6037c5ff5cfb8849` (+3/-2, one test file). It synchronizes the custody clock at 10000 and aligns the final expectation with the expired frame lease. No product behavior, privacy guard, query, index, lease policy or flag changed in this completion. The final assertion was corrected because the frame token's lease lapsed at the mocked clock; product behavior unchanged. The earlier runtime/custody, emulator/lifecycle, focused, query/index, PromQL/pre-deploy and typecheck results remain recorded at their actual tested commits; they are not represented as rerun on this merged candidate. On merged candidate `3fc6150cc191140c6ffa8e645bac4871b0cce2e5`, the product-file ratchet passed across 28 changed product source files; product-invariants accepted INV-DATA-1 and INV-MEM-4; expanded preflight passed all 75 checks; normal full pre-push passed, including its backend typecheck with zero errors and 28 selected backend unit files. These are local static and synthetic qualification results; CI and deployed-artifact behavior remain separate evidence. No production access, deployment or ramp. The index-count assertion was updated to match this PR's own registry change (24/26); product behavior unchanged. The ci-budget manifest now records the rationale and expected runs for the emulator-proofs trigger change already in this PR; no workflow behavior changed. ## Staging input completion Staging explicitly sets the four `RECORD_TOKEN_LEASE_*` inputs to off/0/3600/a fixed staging epoch, and `STAGING_DIFF_ALLOWLIST` now permits exactly those four names as independent staging inputs. ## Previous merged-head local qualification Earlier head: `30e3ab980a5fd9c7c509ab9410eda7943d649636`. Merged main: `85de1985f0fb4fddd05e0de4b36c1ac68108d81e`. The final allowlist-only commit adds five lines in one file, including exactly four explicit names; staging retains off/0/3600/1794268800. All gates below ran fresh on this head through `/Users/david/workspace/omi-workspace/bin/omi-heavy run --`, with inherited GCP credentials and CLOUDSDK variables stripped, private HOME/config, disabled metadata discovery, and synthetic fixtures: - Staging overlay: 21 passed, zero failures. - Seal/custody/privacy/lifecycle units: 36 files, 1,343 passed, 86 existing strict lifecycle-invariant xfails, zero skips/failures. - Real loopback emulator: custody append 30 passed; no-job seal 4 passed; lifecycle/properties 34 passed and 3 existing xfails; held custody 75 passed; recovery custody 39 passed. Emulator shut down normally. - Expanded preflight against current main: 75 checks passed, zero failures. - Normal full pre-push: passed; shared preflight 75 passed, metadata precheck 3 passed, backend typecheck zero errors; 30 selected files produced 1,962 passed, 86 existing xfails, 4 emulator skips, and 144 integration cases deselected. Skipped/deselected emulator suites passed independently above. Residual expected failures remain the existing 86 lifecycle invariants plus the 3 lifecycle simulator cases: `test_sealed_no_job_registered_recovered`, `test_upload_failed_gets_retried`, and `test_server_batch_completion_ordering[closed-before-completed]`. No xfail/skip marker was added. Local qualification does not establish remote CI or deployed behavior. Stop after push 2/2 for delta-only Luna; no deploy, ramp or production access. ## Receipt replay completion This change completes Luna finding (2): `begin()` recognizes the accepted exact-session finish receipt before adding custody, preserving idempotent finish replay without leaving a token that blocks sealing. The regression proves begin/finish/retry leaves no token, revision or metric change and no seal refusal. Earlier head: `15fc2627f3d9d923bd88c1358232c8e3521859ae` (parent `30e3ab980a5fd9c7c509ab9410eda7943d649636`). Incremental diff: 2 files, 32 additions; 4 product lines and 28 test lines. Focused custody/erasure/privacy/token-lease suites: 515 passed in 20 files. Real loopback Firestore custody-append suite: 30 passed. The new regression was first observed failing on the parent before the guard was added. Normal full pre-push passed: 75 shared checks with supplied-body metadata validation, backend typecheck with zero errors; 30 selected backend files yielded 1,963 passed, 86 existing xfails, 4 emulator skips, and 144 integration cases deselected. The actual push hook also passed with the same counts. Exactly one fast-forward push completed, from the parent above to this head. All checks ran through `omi-heavy` with inherited cloud credentials and CLOUDSDK variables unset, private HOME/config, disabled metadata discovery, and synthetic fixtures. This is local static/synthetic and loopback-emulator evidence; remote CI and deployed behavior are separate. No deploy, ramp or production access. Stop after the single push for delta-only Luna and refactor-lead custody review on this exact commit. ## L1 CI and pusher correction Candidate: `023db969b7d158ba0c518c5cb318be11b90f6aaa`, based on published `15fc2627f3d9d923bd88c1358232c8e3521859ae`. Batch scope is 120 changed non-test lines (cap 150); no workflow file changes. Finding-by-finding resolution: 1. Deploy assertions: render production separately from the pinned staging overlay, assert its actual timeout plus custody margin, and avoid repeating mode-invariant Helm work inside the CPU-timed test. 2. Pusher renewal P2: a failed metadata renewal returns a refusal. Receive windows keep their audio/WAL unacknowledged; projection batches requeue before storage. A pending refusal survives mode rollback until retry succeeds or ownership is retired. Regressions cover retention, retry, and cleanup. 3. Monitoring inventory drift: regenerate the committed inventory with only the two record-token-lease alert consumers and their count adjustment. 4. Alert serialization: restore the combined export's exact split-source bytes. Parsed alert objects, query expressions, thresholds, and notification behavior are unchanged. 5. Composite action: replace unavailable `vars` reads with four explicit action inputs. Defaults remain off/0/3600/0; the same validator writes the complete vector to GITHUB_ENV only after validation. Existing stack callers omit these inputs and therefore stay at defaults. Protected-environment variable forwarding at those callers is not added in this batch; a future rollout must explicitly supply the inputs under separate authorization. Standalone workflow bindings are unchanged. 6. Test drift: align held-state and isolated-canary inventories and remove stale real-clock allowlist entries. No new skip or xfail marker. Fresh credential-free qualification: 994 passed across 34 isolated files, including the deploy, pusher barrier, custody/token-lease and monitoring/action contracts. The initial run hit the unchanged real-clock scanner CPU guard at 1.02s/1.00s after all assertions passed; the canonical single-file rerun passed all 11 cases with unchanged limits. Pinned formatting was applied to the updated CI test. Final normal full pre-push on `023db969b7d158ba0c518c5cb318be11b90f6aaa` exited 0: 75 shared checks, supplied-body metadata validation, zero backend typecheck errors; 33 selected backend test files yielded 2,066 passed, 0 failed, 4 existing emulator skips, 86 existing lifecycle xfails and 144 integration-marker deselections. The first pre-push attempt stopped on the stale pusher growth declaration; it was corrected to 2032 → 2044 before this green rerun. No source change or check bypass was needed. All checks use `/Users/david/workspace/omi-workspace/bin/omi-heavy run --`, with inherited GCP credentials and CLOUDSDK variables unset, private HOME/config, metadata discovery disabled, and synthetic fixtures. Local static/synthetic evidence does not establish remote CI or deployed behavior. The previous shard-5 collection diagnosis remains resolved: interleaved output came from the inventory assertion, not a collection/import failure. The capture-continuity failure remained unreproduced on main and L1 and is untouched. The previously observed emulator cursor-age clock-boundary issue is also untouched; this batch does not claim a new emulator run. Exactly one normal fast-forward push completed from `15fc2627f3d9d923bd88c1358232c8e3521859ae` to `023db969b7d158ba0c518c5cb318be11b90f6aaa`. Its mandatory pre-push hook also passed: 75 shared checks, zero typecheck errors, and the same 2,066 passed / 86 xfailed / 4 skipped / 144 deselected across 33 selected files. Final batch diff: 12 files, +199/-52; 120 changed non-test lines. Stop here for independent delta and custody review on this exact head. No deploy, ramp, production data/config, credentials/IAM, or UI changes.
…aces Review follow-ups on the live-producer seal grace: - The always-on record-seal-sweeper reaches producers_quiesced through plan_seals/apply_seals but never received RECORD_SEAL_LIVE_PRODUCER_GRACE_SECONDS, so recordSealRules.liveProducerGraceSeconds=0 did not restore the pod-restart rule on the path that actually runs in prod. Pass the chart value to the sweeper CronJob and assert the kill switch reaches the worker, sweeper and repair job. - The exemption applies on every path that consults seal_refusal (sweeper, repair job, no-job backfill), so drop the 'repair-only' wording from producers_quiesced, the nojob refusal comment and the flag registry note, and correct the stale proven-dead patch comment. - Clamp graces above seven days to the maximum instead of silently reverting to 3600, which turned the exemption on at one hour; keep only 0 as the documented disable. - Move the new pipeline-doc paragraph out of the upload-failed section, name the chart knob and the pre-identity attestation. - Drop the unused timedelta import and cover the sweeper at age > grace.
|
SCA-2228 readiness result: NO SHIP at
I attempted a normal merge of main Local integration: 665 passed, 7 failed, 3 skipped across 14 focused suites. The seven failures are three in I aborted the failing local merge and restored the clean original head; no commit or push. No merge, deployment, production write or release request. SCA-2222 has the blocker. Required before a release request: replace the age-only authority with an enforced uploader fence or settled-producer proof, preserve late-audio custody, reconcile lease rollback semantics, and obtain fresh green integration tests plus an exact-head SHIP. Merely rejecting all completed-row registrations would risk late-audio custody and is not an accepted fix. |
|
Hey @Git-on-my-level 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Requested by David
Replaces #24598, which was closed as superseded by mistake: main still has no
RECORD_SEAL_LIVE_PRODUCER_GRACE_SECONDS. Same change, with origin/main merged in (head 2796cab, a fast-forward of 43dd1ce).David's ruling of 2026-11-04 11:06Z gave the lead the failed-upload retry and open recorder-session leaks. A read-only sample of 500 due
record_pendingrows at 11:45Z found 359 blocked byrecord_upload_sessionsand/orrecord_upload_failed. All of them werestatus=completed; 181 had finished more than 1 hour earlier.Cause:
fail_recordingdeliberately keeps its producer token (utils/pusher_record_barrier.py). Seal repair then refusesupload_pendingunless it can prove the producing pusher pod has died or restarted (record_producer_proof.producer_tokens_dead). Pusher pods are long-lived, so these rows wait until a pod restart, and admission retries them every 60 s in the meantime.Change: in
seal_refusal, a completed capture finished more thanRECORD_SEAL_LIVE_PRODUCER_GRACE_SECONDSago (default 3600;0restores the previous rule) counts as quiesced when every token carries producer identity. The custody gates are unchanged:True) tokens still need the operator--producers-stoppedattestation;database/record_partial.py) keeps the pod-restart rule, because it can admit without a full tail;No audio is deleted; repair writes only conversation and job metadata.
Wiring: chart
recordSealRules.liveProducerGraceSecondsgoes to the record-seal-worker, record-seal-sweeper and record-seal-repair jobs, so0restores the pod-restart rule on every seal path; flag registry, deployment classification and pipeline doc are updated.Validation: new
test_record_seal_live_producer_grace.py(17). Existingtest_record_partial67,test_record_seal_repair37,test_record_seal_cluster_repair64,test_record_seal_nojob44,test_record_seal_rules21, seal deploy tests 14 andtest_cross_service_deploy_contract23 all pass. Local results only; deploy effect is measured by the admission retryreason=capture_upload_finalization_barrier_not_closedandomi_record_seal_attempts_total{disposition}.Rollback: set
recordSealRules.liveProducerGraceSeconds=0, or revert.Failure-Class: none
🤖 Generated with Claude Code