Repository navigation
fix: Bound conversations v3 reconcile work per dispatch - #26859
Conversation
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.
6 issues found across 16 files
Confidence score: 2/5
- In
models.py, backfilled notes can keep a reconcile provider call running for up to 12 seconds after the delivery budget expires. Keep this work under the shared pass budget. - In
pass_budget.py,limit()can let final durable or enqueue work cross the 120-second deadline and still report success. Check the deadline before returning success and defer when it has expired. - In
pass_budget.py,bound_providercan miss its timeout if provider work blocks the event loop, allowing the pass to exceed its budget. Check the absolute deadline after the await and classify the result as a timeout. - In
memory.py, an unrelated conversation update can keep resetting the age check and leave a lost memory task pending indefinitely. Track the memory obligation’s age rather than using the conversation’supdate_time.
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/conversations/v3/memory.py">
<violation number="1" location="backend/utils/conversations/v3/memory.py:157">
P2: `snapshot.update_time` is the whole conversation's last-write time, not the memory obligation's age. An unrelated conversation update can continually reset this check, leaving a lost memory task pending indefinitely; persist and project a memory-marker timestamp (or otherwise age the obligation itself) instead.</violation>
</file>
<file name="backend/tests/unit/test_conversations_v3_stage_queues.py">
<violation number="1" location="backend/tests/unit/test_conversations_v3_stage_queues.py:1088">
P2: This test bypasses the production `service.reconcile` implementation, so it does not verify the claimed reconcile budget behavior across recursive passes and lease handling. Exercise the real reconcile path while stubbing only the expensive processing boundaries, or narrow the test name and assertions to the route/drain behavior it actually covers.</violation>
</file>
<file name="backend/utils/conversations/v3/models.py">
<violation number="1" location="backend/utils/conversations/v3/models.py:144">
P1: Backfilled notes bypass the shared pass budget whenever `_backfill_notes_deadline` is set, so an active reconcile can continue its provider call for up to 12 seconds after the 120-second delivery budget expires. Apply `pass_budget.bound_provider` inside the backfill timeout as well, preserving the backfill timeout for its own deadline.</violation>
</file>
<file name="backend/utils/conversations/v3/pass_budget.py">
<violation number="1" location="backend/utils/conversations/v3/pass_budget.py:31">
P1: `limit()` exits without checking whether the wrapped delivery crossed its deadline, so final durable or enqueue work can run past 120 seconds and still return success instead of `policy_defer`. Check the budget after the body returns, before resetting the context.</violation>
<violation number="2" location="backend/utils/conversations/v3/pass_budget.py:61">
P1: `bound_provider` can let slow provider work escape the 120-second budget when the coroutine blocks the event loop past the timeout callback. Check the absolute deadline after the await and classify timeout errors raised after it as `PassBudgetSpent`, otherwise slow outline or summary work can keep the Cloud Tasks slot past the intended cap.</violation>
</file>
<file name="backend/utils/conversations/v3/service.py">
<violation number="1" location="backend/utils/conversations/v3/service.py:2197">
P3: Move this production import to the module import block. Backend import policy requires imports at module scope, and keeping it inside `sweep()` makes dependency loading inconsistent and harder to statically audit.
(Based on your team's feedback about backend imports at module scope.) .</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| return await pass_budget.bound_provider(invoke) | ||
| remaining = deadline - monotonic() | ||
| if remaining <= 0: | ||
| raise BackfillNotesAdmissionTimeout('backfill_notes_budget_exhausted') |
There was a problem hiding this comment.
P1: Backfilled notes bypass the shared pass budget whenever _backfill_notes_deadline is set, so an active reconcile can continue its provider call for up to 12 seconds after the 120-second delivery budget expires. Apply pass_budget.bound_provider inside the backfill timeout as well, preserving the backfill timeout for its own deadline.
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/conversations/v3/models.py, line 144:
<comment>Backfilled notes bypass the shared pass budget whenever `_backfill_notes_deadline` is set, so an active reconcile can continue its provider call for up to 12 seconds after the 120-second delivery budget expires. Apply `pass_budget.bound_provider` inside the backfill timeout as well, preserving the backfill timeout for its own deadline.</comment>
<file context>
@@ -140,7 +141,7 @@ async def within_notes_admission(invoke: Callable[[], Awaitable[_T]]) -> _T:
deadline = _backfill_notes_deadline.get()
if deadline is None:
- return await invoke()
+ return await pass_budget.bound_provider(invoke)
remaining = deadline - monotonic()
if remaining <= 0:
</file context>
| def limit(): | ||
| token = _budget.set(_Budget(monotonic() + PASS_SECONDS)) | ||
| try: | ||
| yield |
There was a problem hiding this comment.
P1: limit() exits without checking whether the wrapped delivery crossed its deadline, so final durable or enqueue work can run past 120 seconds and still return success instead of policy_defer. Check the budget after the body returns, before resetting the context.
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/conversations/v3/pass_budget.py, line 31:
<comment>`limit()` exits without checking whether the wrapped delivery crossed its deadline, so final durable or enqueue work can run past 120 seconds and still return success instead of `policy_defer`. Check the budget after the body returns, before resetting the context.</comment>
<file context>
@@ -0,0 +1,70 @@
+def limit():
+ token = _budget.set(_Budget(monotonic() + PASS_SECONDS))
+ try:
+ yield
+ finally:
+ _budget.reset(token)
</file context>
| yield | |
| yield | |
| checkpoint() |
| """Limit cancellable model I/O while its caller still owns the lease.""" | ||
| budget = _budget.get() | ||
| if budget is None: | ||
| return await invoke() |
There was a problem hiding this comment.
P1: bound_provider can let slow provider work escape the 120-second budget when the coroutine blocks the event loop past the timeout callback. Check the absolute deadline after the await and classify timeout errors raised after it as PassBudgetSpent, otherwise slow outline or summary work can keep the Cloud Tasks slot past the intended cap.
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/conversations/v3/pass_budget.py, line 61:
<comment>`bound_provider` can let slow provider work escape the 120-second budget when the coroutine blocks the event loop past the timeout callback. Check the absolute deadline after the await and classify timeout errors raised after it as `PassBudgetSpent`, otherwise slow outline or summary work can keep the Cloud Tasks slot past the intended cap.</comment>
<file context>
@@ -0,0 +1,70 @@
+ """Limit cancellable model I/O while its caller still owns the lease."""
+ budget = _budget.get()
+ if budget is None:
+ return await invoke()
+ checkpoint()
+ timeout = asyncio.timeout(budget.deadline - monotonic())
</file context>
| scanned += len(rows) | ||
| for snapshot in rows: | ||
| # A fresh marker or recent attempt belongs to the normal task and its retries. | ||
| if snapshot.update_time > stale_before: |
There was a problem hiding this comment.
P2: snapshot.update_time is the whole conversation's last-write time, not the memory obligation's age. An unrelated conversation update can continually reset this check, leaving a lost memory task pending indefinitely; persist and project a memory-marker timestamp (or otherwise age the obligation itself) instead.
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/conversations/v3/memory.py, line 157:
<comment>`snapshot.update_time` is the whole conversation's last-write time, not the memory obligation's age. An unrelated conversation update can continually reset this check, leaving a lost memory task pending indefinitely; persist and project a memory-marker timestamp (or otherwise age the obligation itself) instead.</comment>
<file context>
@@ -111,12 +119,69 @@ async def deliver(uid, lane=handoff.BACKGROUND):
+ scanned += len(rows)
+ for snapshot in rows:
+ # A fresh marker or recent attempt belongs to the normal task and its retries.
+ if snapshot.update_time > stale_before:
+ continue
+ row = snapshot.to_dict() or {}
</file context>
| return 'committed' | ||
|
|
||
| monkeypatch.setattr(service, '_process_leased', process) | ||
| monkeypatch.setattr(service, 'reconcile', reconcile) |
There was a problem hiding this comment.
P2: This test bypasses the production service.reconcile implementation, so it does not verify the claimed reconcile budget behavior across recursive passes and lease handling. Exercise the real reconcile path while stubbing only the expensive processing boundaries, or narrow the test name and assertions to the route/drain behavior it actually covers.
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_conversations_v3_stage_queues.py, line 1088:
<comment>This test bypasses the production `service.reconcile` implementation, so it does not verify the claimed reconcile budget behavior across recursive passes and lease handling. Exercise the real reconcile path while stubbing only the expensive processing boundaries, or narrow the test name and assertions to the route/drain behavior it actually covers.</comment>
<file context>
@@ -1015,6 +1063,68 @@ async def test_the_route_runs_a_user_lane_wake_in_the_foreground_and_retries_a_b
+ return 'committed'
+
+ monkeypatch.setattr(service, '_process_leased', process)
+ monkeypatch.setattr(service, 'reconcile', reconcile)
+ body = route.ReconcileRequest(uid=UID)
+ yielded = await route.reconcile(body, request_, _retry=0)
</file context>
| if len(purges) < 1000: | ||
| break | ||
| cursor = purges[-1] | ||
| from utils.conversations.v3 import memory |
There was a problem hiding this comment.
P3: Move this production import to the module import block. Backend import policy requires imports at module scope, and keeping it inside sweep() makes dependency loading inconsistent and harder to statically audit.
(Based on your team's feedback about backend imports at module 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/utils/conversations/v3/service.py, line 2197:
<comment>Move this production import to the module import block. Backend import policy requires imports at module scope, and keeping it inside `sweep()` makes dependency loading inconsistent and harder to statically audit.
(Based on your team's feedback about backend imports at module scope.) .</comment>
<file context>
@@ -2181,6 +2194,9 @@ async def sweep():
if len(purges) < 1000:
break
cursor = purges[-1]
+ from utils.conversations.v3 import memory
+
+ await memory.redrive_pending(client, now)
</file context>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd8ec0516e
ℹ️ 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 deadline is None: | ||
| return await invoke() | ||
| return await pass_budget.bound_provider(invoke) |
There was a problem hiding this comment.
Restore the processing attempt when the pass budget yields
When the shared budget expires during notes preparation or provider I/O, PassBudgetSpent propagates after _process() has called writers.begin_processing(), but nothing restores the incremented v3_process_attempts. That writer terminally fails unchanged content after two attempts. Consequently, a conversation with one previous transient failure can spend its last attempt on this policy cancellation, and the next delivery marks it attempts_exhausted instead of resuming the summary—even if the provider never received a request. Preserve or restore the attempt on budget yields, as the existing backfill-admission path does, so dispatch pacing does not exhaust the conversation's processing retries.
Useful? React with 👍 / 👎.
| if len(purges) < 1000: | ||
| break | ||
| cursor = purges[-1] | ||
| from utils.conversations.v3 import memory |
There was a problem hiding this comment.
Move the new memory import to module scope
The new import inside sweep() violates the explicit requirement in backend/AGENTS.md: “All imports at module top level — never inside functions.” Move this dependency to the module import section, restructuring the dependency boundary if necessary to avoid a circular import.
AGENTS.md reference: backend/AGENTS.md:L165-L167
Useful? React with 👍 / 👎.
## Summary SCA-6066 follows the review of #26859. A stale memory obligation now checks the canonical account-deletion marker and conversation tombstone before redrive. The transaction checks both again before claiming work. The handler rechecks them before it sends transcript content for extraction and supplies the source revision and ownership epoch to the canonical memory write fence. If Cloud Tasks returns NotFound for the memory queue, redrive tries the builder queue with the same named memory task. Other dispatch errors leave the marker for the next sweep. The existing exported memory counter now distinguishes `redriven`, `redrive_fallback`, and `redrive_failed`. The runbook covers flag-off recovery and how to drain both queues before rolling back the handler. ## FIX-FIRST follow-up Add a fresh deletion check for deferred v3 transcript extraction after message preparation, immediately before provider dispatch. Account or conversation deletion now clears the rejected claim's pending marker in its transaction. The sweep also retires fenced markers transactionally if no queued task reaches the claim. The provider check adds up to two marker reads and one conversation authority read per guarded dispatch. Sweep cleanup adds a transaction only for a fenced stale candidate. ## Data path and rollout The sweep adds up to two marker reads per eligible stale candidate. The claim and the pre-extraction recheck each add up to two marker reads. The canonical write uses its existing source and account validation. When deletion fences an owed memory obligation, claim, post-claim, and stale-sweep transactions clear its pending marker; active obligations are unaffected. A missing memory queue adds one Cloud Tasks create attempt per redrive. The sweep retains its existing pagination, cadence, and document-update-time cutoff. Deploy with the memory route and the pending-memory index ready. Release can keep the stage queue disabled while verifying builder fallback and watching for persistent `redrive_failed` across sweep intervals. Full privacy review and green CI are required before merge and before the separate queue activation. ## CI follow-up Align the external-text assertion and the offline finalizer fake with the current extraction signatures. Remove the obsolete transcript-only callback. The active dispatch guard checks the account and source before both text and transcript model calls. The L1 source digest is refreshed at `l1-1` because admitted calls use the same prompt inputs and output schema. ## Verification - Follow-up unit verification: 86 tests passed across `test_conversations_v3_stage_queues.py` and the external extractor's pre-dispatch fence test. Coverage includes transactional marker retirement after deletion before claim and after claim, and same task ID reuse on builder fallback. - The CI follow-up passed nine focused backend unit files under `BACKEND_UNIT_TEST_FILE_LIST` and `bash test.sh`. The dead-letter title test used 0.56 seconds of CPU against its existing 1.00-second limit. - Pipeline Lab ran all 26 affected local-stack scenarios with STT replay. All 26 passed. - The local Listen Pusher Stack Gauntlet passed, including the listener restart and duplicate ACK. All 13 accompanying Firestore concurrency tests passed. The lifecycle simulator and property tests passed in an isolated home after preflight refused ambient credentials (34 passed, three expected failures). - Repository gates: draft-body validation and the focused suite passed. `make preflight` passed all 41 selected checks; the bounded pre-push gate passed. | Stage-queue scenario | Assertions passed | | --- | --- | | Automatic end | 11/11 | | Late text rewrite | 14/14 | | Missing queues | 15/15 | | Model failures | 14/14 | | Switch flipped in flight | 19/19 | | User end | 12/12 | | User end during backlog | 14/14 | ## Product invariants affected The stage uses the canonical memory write fence for the account and source (INV-MEM-3). The shared conversation processing and memory extractor files also map to INV-MEM-4 and INV-TASK-2. Failure-Class: FC-settle-path-skips-sibling-fence-and-wake Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3559 -> 3581 | Pass the conversation source to the canonical memory dispatcher so it can recheck authority before the model call. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/26873?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/26873?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26873&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. -->
…y switch off (#26875) ## What changed and why Open pull requests from the backend bottleneck work, joined into one so they take one pass through CI instead of one each. Two of the eight parts (#26862, #26851) have since merged on their own; this PR carries the same commits, so they add nothing to its diff. Six of them add a row to the same three flag files (`config/feature-flags.yaml`, the generated registry page, `backend/config/reliability_experiments.py`), so merged one at a time each merge made the next one conflict and cost it another full CI run. Each part is the head of its own PR, merged here with a merge commit, so the history of every part is intact. The original PR carries the full description, measurements and review notes of its part; they are closed in favour of this one. | Part | Original PR | Switch | What a merge changes in production | |---|---|---|---| | Flag budget renewal | #26862 (merged) | none | Already on main. | | GPU worker floor 6 to 12 | #26851 (merged) | none | Already on main. Nothing changes until the worker chart is rolled by the release owner. | | Fresh class for just-recorded phone audio | #26848 | `fresh_class_for_new_audio`, off | One more histogram label; one in-process flag evaluation per qualifying upload. | | Commit wake made dependable and measured | #26860 | `commit_wake` (existing), off | New counters and two histograms for every account; behaviour only for admitted accounts. | | Declared unsupported language stays on the vendor route | #26870 | `declared_unsupported_language_route`, off | Nothing without a rule. | | One capture transport per listen session | #26822 | `one_capture_transport`, off | Nothing without a rule, on the backend or in a new app build. | | Stored outlines of unvisited stretches are kept | #26832 | `outline_keep_stored`, off | One new metric; nothing else without a rule. | | Live builder pass with fewer database requests | #26868 | `lean_builder_pass`, `outline_context_on_demand`, `tombstone_check_written_rows`, all off | Nothing without a rule. | No flag store rule exists for any of the seven new switches, so no account's behaviour changes at deploy. ### The parts in one paragraph each - **Flag budget renewal (#26862).** Carries the three-file change of #26600 (SCA-3850) onto current main: the 26 rows of `backend/config/flag_budget.json` that passed `review_by` on 2026-11-30 move to 2026-12-06 with the reasons #26600 gives. One difference from #26600, after review: the five rows that already carried a row-specific reason (`BATCH_PIPELINE_PROTECTED_SHARE_ENABLED`, `BATCH_PIPELINE_PROTECTED_SHARE_PERCENT`, `SYNC_BACKFILL_WORKER_API_URL`, `SYNC_BACKFILL_WORKER_AUDIENCE`, `LISTEN_BATCH_RECONNECT_ENABLED`) keep that text, with the renewal sentence appended. No rollout setting or runtime value changes. - **GPU worker floor (#26851).** `replicaCount` and `autoscaling.minReplicas` of the production batch worker go from 6 to 12; `maxReplicas` stays 16. Nodes for the weekday peak cannot be obtained on the day, so the floor is the only setting that has them in place before the ramp. In a replay of nine weekdays it about halves the mean wait for a worker for 27% more worker node-hours. - **Fresh class for new audio (#26848).** A phone upload in the backfill lane whose audio is at most 10 minutes old is served with the fresh class (job row `priority` 0, `admitted_priority` 1). Metering, the enrichment queue and admission still read the admitted class. It reorders the GPU queue and adds no capacity; the ramp in the flag row stops at 25% until GPU capacity covers the weekday peak. The GPU worker image must carry this build before the first rule is created. - **Commit wake (#26860).** A wake that meets a busy account claim is retried (0.5, 1, 2, 4 s), the first walk waits 0.5 s, and serving-side commits of an admitted account ask the in-process owner drain. Counters at both ends and `commit_to_text` / `ready_to_text` histograms by path and cohort. In the local load test, commit to written fell from a median of 11.2 s to 0.52 s. - **Declared unsupported language (#26870).** For a multilingual-profile user (#26431), a declared language Parakeet cannot serve stays the declaration, so the upload takes the vendor route at admission: no language probe, no GPU unit, no refusal, no recovery wait. Supported and unknown declarations, legacy-on owners and the record lane are unchanged. - **One capture transport (#26822).** With the rule on, a batch-only session sends no pendant audio on the socket and a live session gets no phone-file grant, so the same audio is no longer transcribed twice. Admit accounts to `end_open_conversation` together with this rule: without socket audio the baseline End closes nothing. Stored text then depends on the phone's serial upload queue alone. - **Stored outlines kept (#26832).** A live builder or on-open pass keeps the stored outlines of stretches it did not visit, so a later visit with the same lines and prompt reuses the model's answer instead of paying for it again. About 11% fewer outline calls with every account on. - **Fewer database requests per builder pass (#26868).** Three experiments remove bookkeeping reads and writes of the live builder pass. On a synthetic day against the Firestore emulator: same documents and prompts, reads down 35%, writes down 19%. `tombstone_check_written_rows` touches the commit's deletion guard: please review it as such, and agree it with the owner of conversation deletion before any account is admitted. ### Where the parts meet - `_reconcile_outlines` in `backend/utils/conversations/v3/service.py` now takes both `keep_stored` (#26832) and `clock` (#26868). The two do not interfere: a stretch found by its lines key keeps its stored fingerprint, and `outline.with_unvisited` drops stored rows by that fingerprint as before. - `config/feature-flags.yaml`: the `commit_wake` row is #26860's; #26822 only adds its own row beside it. - `backend/testing/pipeline_lab/scenario/reach.json` was measured again on the combined branch. - `backend/docs/feature-flag-registry.md` was rendered again from the combined YAML. ### Changed after the automated review The review bot left 34 comments. One was not valid, three are answered without a code change, the rest are fixed in this PR. Behaviour with every switch off is unchanged by all of them. What changed in behaviour: - **`one_capture_transport`, app half.** Safety copies are left untagged per conversation window, by whether pendant audio was really kept off the socket in that window, not by the socket's mode when the conversation closes. Before, phone-microphone copies (always sent) could end marked as sent with no conversation id and no upload. The app half now does nothing unless `end_open_conversation` is also on for the account, because without socket audio the baseline End closes nothing. The flag row makes that pairing a precondition of every cohort. The flag texts now say the rule covers the grant that comes with the on-phone preview; the Standard cohort grant is unchanged and listed as a known limit. - **`declared_unsupported_language_route`.** With language inheritance switched off (`BATCH_PIPELINE_LANGUAGE_INHERITANCE_ENABLED=false`) and a conversation language that declares nothing, the kept declaration was lost and the upload went to the GPU. Serving and shadow intake now take one kept value. - **`commit_wake`.** The retry set held a busy-claim token no walk returns (it mattered only with the owner drain switched off); corrected. `ready_to_text` now times a vendor-route row without `ready_at` from its settle instant, as the ordered merge does. - **`tombstone_check_written_rows`.** The ramp now starts with a step that admits no account until the owner of conversation deletion has agreed the change to the deletion guard. - **Simulator and lab.** The pipeline simulator clears an inherited `OMI_RELIABILITY_EXPERIMENTS`; the lab's final verdict carries STT routes and queue counts; a scenario's `route` is validated when it is loaded. - **Docs.** Wording corrected where it promised more than the code does (the fresh-class pause is a bound on promotions, not a guarantee for units already fresh; `served` is the class on the job row, not who transcribed the unit; when `lines_key` is written; which rollout readouts are fleet-wide). ### CI The first run of this PR had its emulator proofs job cancelled at the 20-minute limit (the job took 18.4 to 19.5 minutes on main that day; this PR's three added proofs take about 70 s there). #26882 has since raised the limit to 25 minutes on main, so this PR changes no workflow. ### Tuning - MAX_READY_UNITS (#26848, fresh ring size at which promotion pauses), new: 600 waiting units, about 30 s of fleet work at the weekday peak's lease rate; promotion resumes under 300. - MAX_TIMED_OWNERS (#26860, receipt times kept for the wake start histogram), new: 8192 accounts per process. Past it a wake still walks, untimed. - SETTLE_SECONDS (#26860, wait before a wake's first walk): before 0 s, after 0.5 s. - BUSY_RETRY_DELAYS (#26860, retries of a wake's walk after a busy account claim): before 0 retries (the wake was dropped), after 4 retries at 0.5, 1, 2 and 4 s. - Worker floor (#26851): before 6, after 12 (`replicaCount` and `autoscaling.minReplicas`); `maxReplicas` stays 16. ### Not in this PR #26857 (the sweep that gives a lost memory extraction its task back) is left out. #26859, merged to main on 2026-12-01, recovers the same lost memory obligations with its own re-drive in the builder sweep, so the two would now run side by side. #26857 stays open for its author to rework or close. Line-Count-Exception: backend/utils/batch_pipeline/scheduler.py | 1529 -> 1534 | the enqueue takes the served class and a rejoining row returns to its admitted class; both belong to the two functions that own the ring Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1978 -> 2003 | the walk now returns its stop reason to the caller (`walk_owner`, with `project_owner` kept as a wrapper for its existing callers) and names its origin for the commit-to-text series; one observe call, two origin markers and the method's signature and docstring. Splitting the projector is outside this change. Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 5265 -> 5276 | call sites of the experiment at the per-packet routing boundary, socket publish, socket close and the status handler; its state and helpers are in the new part file capture_one_transport.dart Line-Count-Exception: backend/routers/listen/receiver.py | 3066 -> 3070 | two one-line calls and their two imports; the logic is in routers/listen/local_preview.py Line-Count-Exception: backend/utils/conversations/v3/service.py | 2570 -> 2647 | the experiments' branches sit in reconcile and _reconcile_outlines beside the baseline calls they replace, so the two paths can be read side by side and deleted together when the rollouts end; the old branches and the switches go then Line-Count-Exception: backend/database/conversations_v3.py | 3075 -> 3171 | PendingPage, the pending page clear_terminal_pending returns and the batched source read share load's private helpers and the commit's tombstone decision is carved out of its write loop in place; the baseline paths they duplicate are removed when the rollout ends ## Product invariants affected - INV-CAP-1: the change of #26822 is in the capture routing boundary (`app/lib/services/capture/capture_controller.dart`, `capture_conversation_custody.dart`). No packet loses custody: one that is not sent is already in a phone file or the safety copy, and one the safety copy refused is sent as before. Tests follow each packet to exactly one place. ## How it was verified Each part was verified on its own branch; the commands and results are in its PR. On the combined branch: - Unit, after the review fixes: the test files the parts change, every `test_conversations_v3*`, `test_reliability_experiment*`, pipeline lab and simulator file, the batch intake, commit, projection, scheduler, admission and language files, the local preview and Standard batch files, the Firestore query shape guard and the flag files, plus the multipart and part-retirement files, every unit file that exercises batch intake and the unit files main changed since: 216 files, 9,661 tests, all pass (`BACKEND_UNIT_TEST_FILE_LIST=<list> bash test.sh`). - App, after the review fixes: `flutter test` on `one_capture_transport_test.dart`, `local_preview_admission_test.dart` and `reliability_experiments_test.dart`: 73 pass; `flutter analyze` on the changed files: no issues. - Firestore emulator: the integration files of #26868, #26832, #26870 and #26860 plus `test_conversations_v3_unchanged_writes_firestore.py`: 45 tests pass, also after the review fixes. After the merge of #26847 (multipart reads and part retirement, which meets `tombstone_check_written_rows` in the projection commit) the same files plus `test_conversations_v3_finish_emulator.py` and `test_v3_multipart_transcript_firestore.py`: 92 pass; after the merge of #26771 and #26873, with the locked closure cost and live catch-up files added: 104 pass. One of them, `test_naming_a_speaker_rearms_a_recording_and_nothing_stored_differs`, failed when run between 07:34 and 08:00 UTC, because the story's first recording (26 minutes, starting eight hours before the run) then crosses midnight UTC and the baseline outlines one more stretch. The test now starts that recording half an hour earlier in that case, and the file passes inside the window. - Pipeline lab, all 30 committed scenarios: 30 pass (`scenario run --trace-calls`, the run `reach.json` was measured from), 30 pass again after the review fixes, and all 31 (main added one) after the last merge of main. - Pipeline lab, old against new, run before the review fixes (`scenario compare`, four arms: `origin/main`, this branch with every switch off, with the four v3 switches on together, with all eight switches on together). With the switches off, every scenario main can run (28 of 30) has the same conversations and exactly the same reads, writes and no-op writes as main. With the switches on, no conversation differs; reads fall 10.6% and writes 9.3% over those scenarios, and the four v3 switches together give the same result as all eight. The four scenarios whose verdict changes with a switch are the ones written to show that switch (`fewer_requests_two_talks_and_late_sync`, `outline_kept_across_passes` and the two `stt_route_declared_unsupported_language_*`). - `scripts/check_feature_flag_registry.py`: OK. `scripts/pr-preflight`: 65 of 65 checks pass. Not verified on the combined branch: a running stack, a phone, production. The app half of #26822 was run on a test phone from its own branch (results in #26822), not from this one, and that run predates the changes made in review (per-window untagging, the `end_open_conversation` guard): tests are their only evidence. ## Tests Every part brings its own tests (listed below). Added or strengthened in review: the per-window untagging, the `end_open_conversation` guard, a capture-end flush and the hold counters in the app tests; the provider open and the warm-before-admission order in `test_reliability_experiment_one_capture_transport.py`; the kept declaration with inheritance off in the three language test files; the real projector walk with the claim held and the vendor-row ready time in `test_reliability_experiment_commit_wake.py`; changed lines against a stored outline in `test_conversations_v3_fewer_requests.py`; a real opened conversation in `test_reliability_experiment_outline_keep_stored.py`; the simulator's inherited override in `test_pipeline_sim_new_audio_wait.py`; the lab verdict's routes and the route names at load. - #26848: `tests/unit/test_reliability_experiment_fresh_class.py`, `tests/unit/test_pipeline_sim_new_audio_wait.py`. - #26860: `tests/unit/test_reliability_experiment_commit_wake.py`, `tests/integration/test_batch_commit_wake_firestore.py`. - #26870: `tests/unit/test_batch_multilingual_profile_routing.py`, `tests/unit/test_batch_admission_language.py`, `tests/integration/test_batch_declared_unsupported_language_route_firestore.py`, two pipeline lab scenarios. - #26822: `tests/unit/test_reliability_experiment_one_capture_transport.py`, `app/test/services/capture/one_capture_transport_test.dart`. - #26832: `tests/unit/test_reliability_experiment_outline_keep_stored.py`, `tests/integration/test_conversations_v3_outline_keep_stored_firestore.py`. - #26868: `tests/unit/test_conversations_v3_fewer_requests.py`, `tests/integration/test_conversations_v3_fewer_requests_firestore.py`, one pipeline lab scenario. - #26851: `tests/unit/test_batch_pipeline_chart.py` and the two HPA replay files follow the new floor. - #26862: `tests/unit/test_flag_budget.py` follows the new dates. ## UI evidence UI-Evidence: none -- no screen changes ## Failure class (fixes) Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
SCA-6050. Slow outlines and inline summaries can exhaust the shared builder's Cloud Tasks dispatch slots during the peak.
policy_defer, so Cloud Tasks retries the same owner, lane and stage payload. Synchronous work that already owns a lease settles under its existing fence and can extend the response past the budget.Data path and cost
The pass budget adds no reads or writes to the ordinary successful path. Yielded deliveries can repeat builder reads and leases. The sweep adds one read per pending memory marker observed every five minutes, plus the minimum charge for an empty query. It reads metadata only and enqueues only stale, unclaimed markers. Recovery executes through the existing memory handler and its existing claim, retry, and eligibility fences.
Verification
FIX-FIRST validation covered the lease-fenced refund through the summary task endpoint and confirmed that a second delivery settles a row with an earlier failed attempt. The stage-queue, backfill, and task retry suites passed (195 tests, four emulator-only skips).
affectedand all 26 committed local-stack scenarios with emulator, Redis, and a fake model gateway.make preflight, including serving-query and generated-index checks selected for this diff.Failure-Class: FC-per-hop-timeout
Line-Count-Exception: backend/utils/conversations/v3/service.py | 2395 -> 2417 | Place deadline checkpoints at existing lease boundaries and call the indexed memory redrive from the scheduled sweep.
Line-Count-Exception: backend/database/firestore_index_registry.py | 2422 -> 2423 | Register the collection-group index required by the memory redrive sweep.