Repository navigation
fix(batch): retain expired projection holds and re-drive nightly - #24745
Conversation
Failure-Class: FC-batch-fault-domain-head-of-line-poison
Failure-Class: FC-batch-fault-domain-head-of-line-poison
Failure-Class: FC-batch-fault-domain-head-of-line-poison
Failure-Class: FC-batch-fault-domain-head-of-line-poison
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. |
There was a problem hiding this comment.
4 issues found across 26 files
Confidence score: 4/5
- The xfail reason in
test_lifecycle_invariants.pyimplies thequarantine_heldgap is closed, but the clause still fails. Keep the reason aligned with the missingstampedmarker andDEADLINE_ENTRIESentry. - The
release_pagedigest infirestore_batch_pipeline_drivers.pydoes not match the current function body. Recompute it from HEAD and update the pin here and in the registry. - The change note documents the default-on switch and
held_expiredmarkers, butlisten_pusher_pipeline.mdxdoes not. Update the pipeline contract so it matches the behavior described in the note. - The alert description says all stock is
state=dead, but the metric also countsprojection_state=quarantine_heldreceipts. Change the first clause to say “Job stock is only…” so the scope is accurate.
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/tests/support/firestore_batch_pipeline_drivers.py">
<violation number="1" location="backend/tests/support/firestore_batch_pipeline_drivers.py:432">
P3: The new `release_page` digest does not match the current function body. Recompute it with `function_body_digest` on the HEAD source (currently 315ea28b…) and update the pin here and in `firestore_query_driver_registry.py`. The same applies to the `release_scan_pass` pin. The shape-guard tests should then catch future body drift.</violation>
</file>
<file name="backend/tests/unit/test_lifecycle_invariants.py">
<violation number="1" location="backend/tests/unit/test_lifecycle_invariants.py:344">
P2: This xfail reason now reads as if the gap is closed, but the clause still fails: the `quarantine_held` row in `lifecycle_state_table.py` is not marked `stamped` and has no `DEADLINE_ENTRIES` entry. Keep the reason naming the open gap so the strict xfail documents what remains broken; the privacy-hold policy sentence is not the failing condition.</violation>
</file>
<file name="backend/docs/listen_pusher_pipeline/changes/2026-11-06-projection-held-dead-letter.md">
<violation number="1" location="backend/docs/listen_pusher_pipeline/changes/2026-11-06-projection-held-dead-letter.md:22">
P3: This note cites the pipeline contract for the new default-on `BATCH_HELD_DEAD_LETTER_ENABLED` switch and the `held_expired` markers, but `listen_pusher_pipeline.mdx` is not updated and does not mention either. Per the changes README, the env var, its default, and the new fields belong in that contract section. Add a short section to the contract doc in this PR.</violation>
</file>
<file name="backend/charts/monitoring/alerts/batch-held-dead-letter.json">
<violation number="1" location="backend/charts/monitoring/alerts/batch-held-dead-letter.json:142">
P3: This scope first says all stock is `state=dead`, but the metric also counts projection receipts in `projection_state=quarantine_held`, which are not dead rows. Change the first clause to say “Job stock is only…” so operators do not misread the projection cohort’s alert scope.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| ('batch_projection:quarantine_held', 'entry_deadline'): 'Assignment holds stamp held_deadline_at; privacy holds ' | ||
| 'remain explicitly outside phase 4b and must never age-expire. ANX lcinv-lifecycle-invariants', |
There was a problem hiding this comment.
P2: This xfail reason now reads as if the gap is closed, but the clause still fails: the quarantine_held row in lifecycle_state_table.py is not marked stamped and has no DEADLINE_ENTRIES entry. Keep the reason naming the open gap so the strict xfail documents what remains broken; the privacy-hold policy sentence is not the failing condition.
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/tests/unit/test_lifecycle_invariants.py, line 344:
<comment>This xfail reason now reads as if the gap is closed, but the clause still fails: the `quarantine_held` row in `lifecycle_state_table.py` is not marked `stamped` and has no `DEADLINE_ENTRIES` entry. Keep the reason naming the open gap so the strict xfail documents what remains broken; the privacy-hold policy sentence is not the failing condition.</comment>
<file context>
@@ -341,9 +341,8 @@ def assert_clause(row, clause):
- ('batch_projection:quarantine_held', 'entry_deadline'): 'batch_projection:quarantine_held: missing deadline '
- 'stamped at entry; phase contract follow-up; no fix PR '
- 'yet; ANX lcinv-lifecycle-invariants',
+ ('batch_projection:quarantine_held', 'entry_deadline'): 'Assignment holds stamp held_deadline_at; privacy holds '
+ 'remain explicitly outside phase 4b and must never age-expire. ANX lcinv-lifecycle-invariants',
('batch_projection:ready', 'entry_deadline'): 'batch_projection:ready: missing deadline stamped at entry; phase '
</file context>
| ('batch_projection:quarantine_held', 'entry_deadline'): 'Assignment holds stamp held_deadline_at; privacy holds ' | |
| 'remain explicitly outside phase 4b and must never age-expire. ANX lcinv-lifecycle-invariants', | |
| ('batch_projection:quarantine_held', 'entry_deadline'): 'batch_projection:quarantine_held: deadline is not declared as stamped at entry (no DEADLINE_ENTRIES); assignment holds stamp held_deadline_at, privacy holds must never age-expire; ' | |
| 'ANX lcinv-lifecycle-invariants', |
| reason='bounded release scan delegates queries to both page builders; resets are document transactions', | ||
| expect_observed=False, | ||
| body_digest='6585eb78557d3f1f336d97ca78325be4a55146f44f5e21c6c72f11abec183580', | ||
| body_digest='ec3dcf9db1840bbee61eed826b815d0bac6a277975dfa5f0c9f7388b3272e397', |
There was a problem hiding this comment.
P3: The new release_page digest does not match the current function body. Recompute it with function_body_digest on the HEAD source (currently 315ea28b…) and update the pin here and in firestore_query_driver_registry.py. The same applies to the release_scan_pass pin. The shape-guard tests should then catch future body drift.
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/tests/support/firestore_batch_pipeline_drivers.py, line 432:
<comment>The new `release_page` digest does not match the current function body. Recompute it with `function_body_digest` on the HEAD source (currently 315ea28b…) and update the pin here and in `firestore_query_driver_registry.py`. The same applies to the `release_scan_pass` pin. The shape-guard tests should then catch future body drift.</comment>
<file context>
@@ -424,7 +429,7 @@ def entries():
reason='bounded release scan delegates queries to both page builders; resets are document transactions',
expect_observed=False,
- body_digest='6585eb78557d3f1f336d97ca78325be4a55146f44f5e21c6c72f11abec183580',
+ body_digest='ec3dcf9db1840bbee61eed826b815d0bac6a277975dfa5f0c9f7388b3272e397',
),
CoveredByEntry(
</file context>
| body_digest='ec3dcf9db1840bbee61eed826b815d0bac6a277975dfa5f0c9f7388b3272e397', | |
| body_digest='315ea28bf30953ad3395528f321f87a033fdc1560bfc0b397161f86cfd7fcb49', |
| change is included. Synthetic and loopback tests cover payload retention, CAS, | ||
| legacy recovery, entry stamps, backfill and bounded scans. Production stock, | ||
| live re-drive and alert delivery were not measured. See the | ||
| [pipeline contract](../../listen_pusher_pipeline.mdx). |
There was a problem hiding this comment.
P3: This note cites the pipeline contract for the new default-on BATCH_HELD_DEAD_LETTER_ENABLED switch and the held_expired markers, but listen_pusher_pipeline.mdx is not updated and does not mention either. Per the changes README, the env var, its default, and the new fields belong in that contract section. Add a short section to the contract doc in this PR.
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/docs/listen_pusher_pipeline/changes/2026-11-06-projection-held-dead-letter.md, line 22:
<comment>This note cites the pipeline contract for the new default-on `BATCH_HELD_DEAD_LETTER_ENABLED` switch and the `held_expired` markers, but `listen_pusher_pipeline.mdx` is not updated and does not mention either. Per the changes README, the env var, its default, and the new fields belong in that contract section. Add a short section to the contract doc in this PR.</comment>
<file context>
@@ -0,0 +1,22 @@
+change is included. Synthetic and loopback tests cover payload retention, CAS,
+legacy recovery, entry stamps, backfill and bounded scans. Production stock,
+live re-drive and alert delivery were not measured. See the
+[pipeline contract](../../listen_pusher_pipeline.mdx).
</file context>
| "summary": "Held batch dead letters exceed the retained-stock or new-expiry volume threshold.", | ||
| "user_impact": "Recorded audio remains retained but these units have no published transcript.", | ||
| "scope": "Stock is only state=dead with reason held_expired, a new explicit cohort; legacy unrelated dead rows never count. Rate counts unique CAS expirations over 30 minutes. Stock requires a sample younger than 15 minutes. Agent tier only. Each replica stock sample is filtered by its own timestamp before max aggregation, so another replica cannot refresh stale stock.", | ||
| "scope": "Stock is only state=dead with reason held_expired, a new explicit cohort; legacy unrelated dead rows never count. Rate counts unique CAS expirations over 30 minutes. Stock requires a sample younger than 15 minutes. Agent tier only. Each replica stock sample is filtered by its own timestamp before max aggregation, so another replica cannot refresh stale stock. Projection receipt stock counts only projection_state=quarantine_held with held_expired_reason=held_expired; no legacy quarantine stock counts.", |
There was a problem hiding this comment.
P3: This scope first says all stock is state=dead, but the metric also counts projection receipts in projection_state=quarantine_held, which are not dead rows. Change the first clause to say “Job stock is only…” so operators do not misread the projection cohort’s alert scope.
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/charts/monitoring/alerts/batch-held-dead-letter.json, line 142:
<comment>This scope first says all stock is `state=dead`, but the metric also counts projection receipts in `projection_state=quarantine_held`, which are not dead rows. Change the first clause to say “Job stock is only…” so operators do not misread the projection cohort’s alert scope.</comment>
<file context>
@@ -139,9 +139,9 @@
"summary": "Held batch dead letters exceed the retained-stock or new-expiry volume threshold.",
"user_impact": "Recorded audio remains retained but these units have no published transcript.",
- "scope": "Stock is only state=dead with reason held_expired, a new explicit cohort; legacy unrelated dead rows never count. Rate counts unique CAS expirations over 30 minutes. Stock requires a sample younger than 15 minutes. Agent tier only. Each replica stock sample is filtered by its own timestamp before max aggregation, so another replica cannot refresh stale stock.",
+ "scope": "Stock is only state=dead with reason held_expired, a new explicit cohort; legacy unrelated dead rows never count. Rate counts unique CAS expirations over 30 minutes. Stock requires a sample younger than 15 minutes. Agent tier only. Each replica stock sample is filtered by its own timestamp before max aggregation, so another replica cannot refresh stale stock. Projection receipt stock counts only projection_state=quarantine_held with held_expired_reason=held_expired; no legacy quarantine stock counts.",
"verification": "Read omi_batch_held_expired_units and omi_batch_held_expired_total, then inspect reasoned rows using an authorized operator read.",
- "safe_next_action": "Check nightly re-drive and worker failure reasons. Use the private OIDC requeue-quarantined path after resolving the cause. Never delete audio or clear privacy fences.",
</file context>
## Change Projection and held state now have one owned contract before lifecycle phases 2, 4c and 5. Document the current batch, projection, finalization, record-audio custody and conversation state tables, including writers, deadlines, observability, switches and rollback gaps. Reserve terminal_family and follow-on work as PLANNED. Pin the retained shapes from #24736 (b6b1539) and #24745 (3b09c0c): batch merge_pending=true preserves legacy dead-row re-drive; projection keeps quarantine_held and normalizes the capped release counter once. Only uicleanup may introduce another held/dead-letter shape through a CONTRACT.md PR (lead2 2f9297 / PA-1106-01). Dead-lettering never deletes retained content. Correct the older Inputs and outputs description: successful recovery is recovery_state=recovered with state=result_ready, rather than "completed"; failed_held is a recovery outcome, not an absorbing batch state. Add a small offline consistency test comparing table keys to the shared lifecycle inventory and checking documented flags against runtime literals/registry, metrics against source (including generated PhaseMetrics names), expiry metrics against the existing alert, and required retained-shape spellings in the contract. Existing dedicated 4a/4b runtime tests own CAS behavior. It uses the existing backend unit-test lane; no additional CI primitive or workflow is needed. It guards drift in the actual shapes whose pre-change recovery compatibility needed review fixes in #24736/#24745. No runtime, deployment, GCP, or .github changes. Pre-existing Flutter worktree edits are excluded. ## Validation - Via bin/omi-heavy, new consistency test + lifecycle writer/invariant suites: 1,909 passed, 75 expected failures (declared lifecycle gaps). - Final combined run: 1,909 passed, 75 xfailed in 91.73s; the fourth contract test pins retained-shape text. - make preflight on final commit: 36 checks passed in 233.17s. Initial run invalidated by a concurrent commit; rerun against a stable tree passed. - scripts/pr-preflight --suggest: no locked invariant citations or fix-class declaration required. Full --pr-body-file run passed 35 checks; final metadata-only validation passed. - Normal pre-push hook: PASSED (shared preflight, type check with 0 errors, seven selected backend test files, format and release-contract checks); normal push succeeded. No bypass, custom cap or force. - Required Grok review via agentctl-portable and cursor-delegation: first review exec-jewel-inmate-quick-hurt-live-desert found a misplaced finalization budget requeue and writer/test gaps. Corrected leased-to-queued budgeting, privacy/retry/receipt writer citations and retained-shape doc assertions; follow-up exec-couple-burger-west-despair-day-boat: no remaining actionable findings. Both reviews were local read-only Grok through agentctl. No merge/deploy requested or performed. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24753?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24753?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24753&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Assignment-held projection receipts can remain parked indefinitely after their target becomes unrestorable. This adds a seven-day expiry marker and a nightly recovery pass while retaining the receipt in the state that pre-change release code can discover.
ProjectionSession.persiststampsheld_deadline_aton assignment holds; legacy rows receive a full window at first examination. Over-age, still-unrestorable settled holds retainprojection_state=quarantine_heldand receive additiveheld_expired_at/held_expired_reason=held_expiredfields. Persisted multipart suffixes and privacy holds never age-expire.MAX_RELEASE_ATTEMPTS=3. For capped rows, expiry's transaction saves the count inheld_expired_release_attemptsand resets the active counter to zero exactly once. The result, receipt and watermark are unchanged. This keeps expired rows recoverable by the unchanged old scan/release code after a full revert, only when the target becomes restorable.Flag: reuse default-on
BATCH_HELD_DEAD_LETTER_ENABLED/batch_held_dead_letter_enabled(). No separate flag, config binding or.githubedit.Rollback: set the flag false to stop new deadline stamps and expiry. Ordinary unmarked flag-off behavior is unchanged. Already expired rows remain discoverable/releasable by the unchanged pre-4b scan and release implementation, including capped rows normalized during expiry. The new nightly helper also continues with the flag off. A full binary revert needs no metadata rewrite or retained helper. Frozen pre-change code from
b6b1539ctests this behavior; its scan and release ASTs match that baseline exactly.Custody: nothing is deleted. Expiry retains the held result/transcript payload, quarantined receipt, proven parts, audio references, job and owner watermark. Each row has a reason and target-gated requeue path. No TTL, privacy/custody fence change, conversation-status writer, BYOK consumer or finalization requeue change.
Validation (offline/synthetic):
bin/omi-heavyandbackend/test.sh: 2,773 passed, 75 strict expected gaps. No xfails added; the privacy-held deadline gap remains outside scope.make preflight: 41 checks passed;scripts/pr-preflight --pr-body-file: 40 passed. Normal pre-push onbd1a6780b73c0e5267d0637842cba9cc5ff3b1eapassed all 41 checks, zero Pyright errors, OpenAPI and selected backend tests. Firestore guard: 162.69s, no timeout. No hook bypass, cap override or force. One initial push attempt was deliberately stopped to clear inherited cloud credential overrides; the successful attempt ran with all four overrides unset. Exact-head GitHub CI is available in this PR's checks.Review: the final Luna round on
b93002afound one blocking rollback-recoverability P1. This inline correction implements the requested additive-marker design and capped-row regression. No additional review round was launched. Earlier required Grok review attempts all timed out without a verdict (exec-buffalo-pulse-bring-system-ranch-truck,exec-similar-stadium-hour-stand-orchard-wash,exec-fantasy-dignity-record-social-frog-reform); each child was reaped. The PR remains draft because that required verdict is unavailable.Not measured: production stock/dwell, live nightly execution, exporter/alert delivery, index readiness, vendor spend, deployed revision or user-visible recovery. No GCP tier or production access used. No merge or deploy performed.
Product invariant: INV-MEM-4; canonical memory intake/promotion authority is unchanged.
Failure-Class: FC-batch-fault-domain-head-of-line-poison