Skip to content

perf(backend): backend bottleneck bundle: eight open PRs in one, every switch off - #26875

Merged
Nizarius merged 48 commits into
mainfrom
perf/backend-bottleneck-bundle
Dec 1, 2026
Merged

Nizarius merged 48 commits into
mainfrom
perf/backend-bottleneck-bundle

Conversation

@Nizarius

@Nizarius Nizarius commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

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

Where the parts meet

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

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

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 perf(v3): the live builder pass with fewer database requests, behind three switches #26868, perf(v3): keep the stored outlines of stretches a builder pass did not visit (outline_keep_stored, default off) #26832, fix(batch): keep a declared unsupported language on the vendor route for multilingual-profile users #26870 and perf(batch): make commit wake dependable and measured #26860 plus
    test_conversations_v3_unchanged_writes_firestore.py: 45 tests pass, also after the review fixes. After
    the merge of Bound v3 multipart transcript reads and retirement #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 fix(conversations-v3): an older stretch of late-landing speech settles on landing too #26771 and fix: Fence memory redrive and fall back to the builder queue #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.

UI evidence

UI-Evidence: none -- no screen changes

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

Nizarius and others added 30 commits November 30, 2026 17:37
…es in batch

Reliability experiment one_capture_transport (Omi flag store rule, default off, per account), backend half.

The phone-file grant sends a session's pendant audio to batch as uploaded files. It was given without
regard to how the server transcribes the session, so a session recognised live (a language batch does not
take, a profile mismatch, a capture batch does not own) could have the same audio recognised on its
provider stream and again in batch. With the experiment on, the grant goes only to a session with
server_batch_only; a live session is refused with outcome live_session, is not deferred, opens its provider
stream from the first frame and gets no grant on renewal.

mobile_batch_admission also carries server_batch_only, true or false, on every renewal, so a phone running
the app half can keep pendant audio off a batch-only socket and resume at once if the session turns live.

Off, admission and both payloads are unchanged.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… keeps for batch

Reliability experiment one_capture_transport, app half (same flag store rule as the backend half, default off).

A batch-only session's audio is transcribed from uploaded files, yet the phone also streamed every packet
its phone-file journal did not take and uploaded a safety copy of it. With the experiment on, when the
server says it only keeps the connection's audio for batch (server_batch_only on ready, and on each grant
renewal from a server running the experiment), a pendant packet is not sent: it is in a phone file, or in
the safety copy when the journal declined it, and uploads once.

- Packets are held until the first answer (the existing verdict hold, now also for a connection that did
  not ask for the preview), so none reaches a batch-only connection first; a live connection gets them in
  order and then streams as before.
- The safety copies of a batch-only stretch are not stamped with the server's recording row, which holds
  none of that audio.
- Custody first: a packet the safety copy refused is still sent, and capture end still hands
  not-yet-durable copies to an open connection.

Off, routing is unchanged.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…t visit

A builder pass that is not partial wrote the stored outline list from the
stretches it loaded only, so the outline of every other stretch was dropped.
When such a stretch was loaded again with the same lines and the same prompt
(a late line elsewhere in its recording, a speaker field write that re-arms
the recording row), the pass missed the list and paid for the same model call
again; a third visit took the fallback outline, because a cache key gets two
model attempts.

Experiment outline_keep_stored (Omi flag store rule, per account, default
off): a live builder or on-open pass keeps the successful model outlines of
unvisited stretches, newest first, within 128 rows and 256 KiB. The cache key
is unchanged, so only an exact repeat is answered from the list. Backfill and
re-derive passes are untouched.

omi_conversations_v3_outline_reuse_total{source} counts hits on the list:
visited (as on main), kept (a model call saved) and kept_open. It is added to
the backend-sync scrape keep rule.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Both sides register an experiment and add a counter to the backend-sync
scrape keep rule; the scenario reach map is re-measured with both sets
of scenarios.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…sport

# Conflicts:
#	backend/config/reliability_experiments.py
Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The end-to-end test opened its socket with codec=opus, the only e2e test to
do so. The hermetic runner has no native Opus library, so the session closed
with unsupported_audio_format before the first message. The test sends no
audio, so it now uses pcm8 like its sibling tests.

The app test carried an import it no longer used, which the analyzer ratchet
counts as a new finding.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…(fresh_class_for_new_audio, default off)

A phone upload without server capture proof is filed in the backfill sync lane and queued as RECENT
whatever its age. At the 2026-11-30 weekday peak such uploads under 10 minutes old waited a median
154 s for a GPU worker (p90 20 min); the fresh class waited 6 s in the same hours.

With the flag store rule on for the owner, a backfill-lane upload whose age is inside the existing
10-minute fresh bar has its new GPU units served as FRESH: the job row carries priority 0 and
admitted_priority 1. The work item, the sync lane, compute admission, the fair-use meter source and the
enrichment queue binding keep reading the admitted class or the lane. A promotion covers the first wait
(a rejoining row returns to its admitted class) and pauses while the fresh ring holds 600 or more
waiting units; a failed or hung count means no promotion and does not forget a pause. Vendor-route
uploads, automatic releases, repair re-drives and uploads held to be combined are never promoted.
It reorders the queue and adds no capacity.

Rows also rejoin a ring in the GPU workers, so the worker image must carry this build before the first
flag store rule is created.

Measured with omi_batch_pipeline_admitted_to_text_seconds{served} (a retried promoted unit stays in the
promoted series) and omi_batch_pipeline_fresh_class_promotions_total{outcome}; simulated with
python -m testing.pipeline_sim new-audio-wait.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The upload function sits at the type checker's complexity limit, so the decision moves out of it:
batch intake hands admission to fresh_class.admit_served, which runs on the worker thread that already
runs the admission transaction. No extra executor hop, same decision. The scheduler compares the served
class with the work item's own class instead of the untyped row value.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The per-test time guard covers the call phase; the other simulator tests keep their runs in module
fixtures for the same reason.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Rule commit_wake (default off, per account) lets a GPU worker tell the serving
backend which owner it committed for. A wake whose walk met a busy owner claim
was dropped, serving-side commits sent no wake, and nothing counted wakes or
separated woken writes from swept ones.

- Retry a wake's walk after a busy owner claim (0.5, 1, 2, 4 s), outside the
  coalescer's drain gate; then leave it to the sweep.
- Wait 0.5 s before a wake's first walk, so it does not start under the
  worker's next commit attempt and one walk serves the commits of one upload.
- Serving maintenance commits of an admitted owner ask the in-process drain.
- Counters on both ends (sent on the worker, received and walk outcomes on the
  serving backend), wake receipt-to-start histogram, and commit-to-text and
  ready-to-text histograms by path (wake, provider, drain, sweep, other) and
  commit_wake cohort.
- A wake's walk reads under its own Firestore origin, task:batch_commit_wake.

No setting is added. The sweep is unchanged and stays the safety net.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…mulator

Two accounts in one database, one admitted to the experiment through the
per-account resolver, are told the same story; after every builder pass
everything stored under them is compared, the builder's lease document
apart: conversations, recording rows, Home feed rows, the summaries
written and from what input, the created deliveries, and whether a
conversation kept its id.

Real: the builder pass, its lease and attempt counters, the summary
stage's begin, persist and settle writes, the created-delivery claim and
the speaker field write. Faked: the outline, live-title and summary
models, Cloud Tasks and the integrations fanout. The v3 settings are read
from deploy/runtime_env.yaml (backend-sync).

Stories: a late piece that reloads an unchanged stretch, a speaker named
on a line, an app open, speech the model cannot outline, an outline aged
out of the bounds, a capture in progress. With a model that gives the
same answer to the same prompt nothing stored differs in any of them.

Two stories pin the one place the accounts part. On its third visit to
an unchanged stretch the baseline has spent both model attempts, plans
from the fallback outline and hands its first-words title to the model
as the preceding conversation of the next stretch; the experiment still
holds the model's outline. A model that answers a repeat differently has
the same effect one visit earlier. Conversations, cuts, transcripts,
statuses, summaries owed and deliveries stay the same; the wording of
titles outlined afterwards can differ. The change note says so.

The suite joins the emulator proofs.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
pyright (reportUnnecessaryIsInstance): drain_owner returns an int.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…three switches

One live builder pass re-read its lease document about ten times, renewed the
lease before every stretch and the commit, read the pending recording rows
twice and read the account background for the outline prompt on passes that
never asked the model.

Three per-account experiments, default off:

- lean_builder_pass: the back-off state is read inside the lease claim and that
  copy serves the load; the lease is renewed by age; the pending page the
  terminal scan read seeds the load and an empty clear transaction is not run;
  closure sources and planned ids are fetched in batched reads. What the pass
  plans and commits is unchanged.
- outline_context_on_demand: a stored outline also carries a key of its lines,
  and the background is read only when a stretch needs a model call.
- tombstone_check_written_rows: the commit looks up tombstones only for rows
  it writes.

Old against new on the Firestore emulator
(tests/integration/test_conversations_v3_fewer_requests_firestore.py): the
same documents and the same model prompts after every step, with 35% fewer
reads, 19% fewer writes and 39% fewer round trips over a synthetic day. In
the pipeline lab no conversation, title or summary differs on any scenario.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…for multilingual-profile users

The multilingual-profile rule (#26431) stops trusting a supported conversation pin for a
multi-language user whose live speech shows a language batch Parakeet cannot transcribe. Its two
intake lines drop every declaration of such a user, also an unsupported one: a user who declares
Japanese and speaks Japanese live is admitted as multi on the GPU route, probed, refused by the
worker (unsupported_language) and transcribed by a vendor only after the recovery sweep. Before
the rule the declaration gave the upload the vendor route at admission.

Flag store rule declared_unsupported_language_route (default off, per account): for such a user,
a declaration that is a known language Parakeet cannot serve stays the declaration and the
inherited language, so select_route admits the upload on the vendor route with no probe and no
GPU unit. A supported or unknown declaration is still dropped and classified on audio. Serving
intake and shadow intake decide through one helper; the rule is read only for an upload it can
change, from the process's flag-store snapshot.

With the rule off the two functions answer what they answer on main (tested value for value).

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…h the declared-language rule on and off

The lab's routing step modelled only owners whose legacy sync is on, where an excluded upload goes
to legacy. With "legacy_sync": "draining" or "dark" in the routing inputs it now follows intake for
an admitted upload: a declared language Parakeet cannot serve goes to the vendor at admission (no
probe); anything else goes to the GPU, a multi upload is probed once, and a frozen verdict that is
not Parakeet's is a refusal the vendor serves after recovery. The product's own helpers decide each
step, including the experiment declared_unsupported_language_route from the arm's env; the refusal
and the recovery are a label on the route, their wait is not modelled.

- A recording expectation can pin what routing decided (route, route_reason, lid_probes,
  gpu_refused); metric stt_routing counts GPU refusals and vendor admissions.
- Scenarios stt_route_declared_unsupported_language_vendor (rule on) and
  stt_route_declared_unsupported_language_gpu_refused (rule off) run one synthetic upload through
  the route and on through the batch worker, projection, v3 builder and Home.
- A committed synthetic language answer for the committed synthetic audio (fixtures/lid/) and
  synthetic routing inputs (fixtures/stt_routing/), so both run in CI without a private lab root.
- reach.json re-measured: the two new scenarios added, the 26 existing ones unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Strict pyright rejected the untyped lease copy and the conditional keyword
arguments passed to store.load. No behaviour change.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…queries

The emulator proofs job has a 20 minute limit and the suite took 106 s of it: the
comparison listed subcollections with one request per document, and every test
re-read the runtime env file. One recursive query per top-level collection and a
cached settings read bring it to about 30 s. The recursive walk was checked against
the per-document walk on every comparison of a full run: same documents.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e test notes

Found while testing the branch on a local stack and on a test phone:

- With no socket audio the baseline End, which finalizes the socket's
  recording row, closes nothing. End closes the conversation only when
  end_open_conversation is on for the same account. Said in both flag
  descriptions, the registry row and the change note.
- Stored text then depends on the phone's serial upload queue alone. Noted
  as a known limit, with what the phone test showed.

No behaviour change.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…nd bottleneck bundle

Failure-Class: none
- Retry a busy owner claim also when the try wrote rows first (row-by-row
  claim); count the write as well.
- Take the wake's receipt time on every try, so a wake served by a retry
  leaves no stale time for a later wake to be measured from.
- A targeted walk with the owner-chain switch off stops as chain_off and is
  counted as stopped, not as empty.
- Flag text names the retry waits instead of a total.
- Tests that read product source are marked slow and the file joins the
  slow-guardrail manifest.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 91 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread backend/docs/feature-flag-registry.md Resolved
Comment thread backend/docs/feature-flag-registry.md Resolved
Comment thread backend/testing/pipeline_sim/README.md Resolved
Nizarius and others added 10 commits December 1, 2026 00:55
The job took 18.5 to 19.5 minutes on main on 2026-12-01 and was cancelled at 20 on branches that add a
proof, this one included (its three added proofs take about 70 s there).

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
one_capture_transport (app): safety copies are left untagged per conversation window, by whether pendant
audio was kept off the socket in that window, so phone-microphone copies keep their tag and a mode change
on a renewal leaves nothing waiting; the app half acts only with end_open_conversation; refusal flushes go
through the routed sender; hold counters of a socket held only for its mode are cleared. Flag texts say the
rule covers the preview grant and name the pairing as a precondition of every cohort.

declared_unsupported_language_route: with language inheritance off and a conversation language that
declares nothing, serving and shadow intake now take the one kept declaration.

commit_wake: the busy-claim retry set names the stop the walk really returns; ready_to_text times a
vendor-route row without ready_at from its settle instant.

tombstone_check_written_rows: the ramp starts with the deletion owner's agreement.

Pipeline simulator clears an inherited experiment override; the lab verdict carries STT routes and queue
counts and validates route names at load. Tests strengthened where the review found them weaker than their
names; docs corrected where they promised more than the code does.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…get change

The nightly contract pins each reusable job's runner and timeout; the 20 to 30 minute change of the
emulator proofs job is entered in INTENTIONAL_BUDGET_CHANGES with the measured runs. budget_p50 is unchanged.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Two conflicts. capture_latency.py: the admitted-to-text histogram keeps the served label of the fresh-class
part and takes main's shared buckets; main's by-priority histogram is observed beside it.
cloud_run_gmp_sync.yaml: main's rewritten keep rule, with outline_reuse added to it again.

Failure-Class: none
Two conflicts with #26847 (bounded multipart reads and part retirement), both in the projection commit.
conversations_v3.py: the planned part-retirement field is dropped in staged_row, the helper the
tombstone_check_written_rows decision and the write loop share, so both see the row main's loop wrote.
firestore_query_driver_registry.py: the commit's body digest is pinned again and both re-review notes kept.
test_conversations_v3_fewer_requests.py follows main: the multipart switch takes the uid, and the staged
manifest and the prior manifest are in the shape part retirement reads.

Failure-Class: none
One conflict with #26866 (predecessor intake overflow on backend-sync), in the imports of
utils/batch_pipeline/intake.py: both sides' names are imported. The overflow choice applies to the FRESH
sync lane and the fresh-class promotion to the backfill lane, so the two do not meet.

Failure-Class: none
… one UTC day

World starts recording A eight hours before the run and A lasts 26 minutes. In the 26 minutes of a day when
that span crosses midnight UTC (07:34 to 08:00), the baseline outlines one more stretch and
test_naming_a_speaker_rearms_a_recording_and_nothing_stored_differs fails on its counts. A then starts half
an hour earlier. Seen on 2026-12-01 at 07:53 UTC; with the change the file passes inside that window.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
#26882 gives the emulator proofs job 25 minutes on main. This branch's own change of that limit (30) and
its budget entry are dropped in favour of main's, so the workflow and the nightly contract test are main's.

Failure-Class: none
Conflicts with #26771 (an older stretch of late speech settles on landing) and #26873 (memory redrive fence).
service.py: _load_live_batch and reconcile carry both the pass's shared sibling_reads allowance and the
lean_builder_pass lease row and clock; every load attempt gets both. The load driver names both sets of
neutral arguments. The projection commit's body digest is pinned again with both re-review notes. The
metrics keep rule is main's with outline_reuse added again. reach.json is measured again on the merged tree
(31 scenarios). test_conversations_v3_fewer_requests.py expects the sibling_reads argument on the load call.

Failure-Class: none
@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: The production changes here are careful and well fenced: every behavioural change sits behind a default-off per-account rule, audio custody is preserved packet by packet, and all 69 check runs on this head are green. I found no blocking defect. What remains are two maintainer decisions and a few ramp watch-items, so this goes to human maintainer review rather than an automated sign-off.

What I checked (sampled from the 58 non-test files)

  • backend/database/conversations_v3.py (tombstone_check_written_rows): refuse_deleted now runs after staged_row()/stored_already() decide which rows will actually be written; absorbed/retired/settled ids stay in the lookup, a multipart row whose parts are written stays in it even when the row itself is skipped, and every read stays ahead of every write. clear_terminal_pending skips the fenced transaction only when the scan found no terminal marker and the claim's own lease copy supplies the limit; the projection commit still checks lease and deletion marker in its own transaction.
  • backend/utils/conversations/v3/service.py, outline.py, context.py: lines_key hashes a strict subset of cache_key's input, so a fingerprint hit always implies a lines hit and the on-demand lookup cannot lose a reusable outline. _renew_lease renews at a third of lease life, which shrinks the renewal margin from 240 s to >=160 s.
  • backend/utils/batch_pipeline/commit_wake.py, provider_drain.py: retry sleeps are taken outside the drain gate; _busy/_received entries are popped on every exit path; the provider route keeps retry_delays=() so its behaviour is unchanged.
  • backend/utils/batch_pipeline/fresh_class.py, scheduler.py, database/batch_pipeline_intake.py: admitted_priority is stamped only when a promotion happens, _append(admitting=False) returns a requeued row to its admitted class, and service_priority is never forwarded to a provider-stage enqueue. capture_latency.served_class reads promoted only when admitted_priority >= priority with the field present, so FRESH-admitted units still read fresh.
  • app/lib/services/capture/capture_one_transport.dart: _keepsOffSocket returns false whenever walAccepted is false, so a packet the safety copy refused still reaches the socket; _sendRoutedPendant applies the same check to held frames released on timeout or refusal. capture_conversation_custody.dart leaves safety copies untagged per conversation window, so phone-mic copies that were always sent keep their stamp.
  • backend/config/batch_pipeline_language.py: unsupported_declaration_kept warms the rule only for a multilingual-profile upload with a known-unsupported declaration; declared_language returns kept or 'multi', so the shadow and serving intakes take one kept value.
  • backend/routers/listen/local_preview.py: the new live_session refusal is read after learn_transport_rule warms the rule off the loop; no endpoint, auth or payload-shape change beyond the optional server_batch_only field.

Maintainer decisions needed

  1. tombstone_check_written_rows changes the commit's deletion guard: a pass that planned an unchanged conversation whose tombstone exists now commits its other rows instead of parking the owner on target_deleted. Nothing is written for the tombstoned conversation, but this is the conversation-deletion owner's call. The flag ramp gates the first cohort on their agreement; please get that agreement on record on this PR before any rule is created.
  2. Six separable, independently rollbackable parts in one merge unit is a real trade-off. The stated reason (all six edit the same three flag files, so sequential merges each cost a full CI run) and the intact per-part merge history make it acceptable to me, but confirm one merge/rollback unit is what you want.

To watch during the ramps

  • omi_conversations_v3_races_total{reason="lease_lost"} under lean_builder_pass (smaller renewal margin).
  • commit_to_text.observe() runs for every account, not only the cohort, and evaluates wake_enabled(uid) per written part; fine if that is an in-process snapshot lookup, worth confirming it is not a flag-store round trip.
  • fresh_class_for_new_audio requires every process that requeues rows (GPU workers included) to run this build before the first rule exists; the flag row says so, make it a deploy checklist item.
  • Could not verify from the diff alone: the allowed == (0, 0) gate in conversations_v3.load() (the variable is outside the hunk) and the regenerated reach.json.

Performance/cost: fewer Firestore round trips per builder pass (emulator: reads -35%, writes -19%), ~11% fewer outline model calls once outline_keep_stored is on, commit-to-written median 11.2 s -> 0.52 s in the local load test; no new external spend.
Security: no new endpoints, auth paths, dependencies or workflows; cloud_run_gmp_sync.yaml only widens a metric keep-regex.
Blast radius: unchanged with every switch off; each switch touches only admitted accounts and reverts by deactivating its rule.

USER IMPACT: none at deploy, every switch is off. Once rules are admitted: just-recorded phone audio is transcribed in seconds instead of minutes at peak, batch results show up in conversations sooner, a declared language the GPU cannot serve no longer waits on a GPU refusal, and pendant audio on batch-only sessions is uploaded once instead of also being streamed.

Leaving for human maintainer review: the deletion-guard change in backend/database/conversations_v3.py needs the conversation-deletion owner's agreement, and the six-part bundle is a merge-unit decision.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces positive-signal Automation verified a genuine fix/quality contribution backend Backend Task (python) labels Dec 1, 2026
@Nizarius

Nizarius commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you for the review. Answers to the points that can be settled from the code, on head 7a1ab3b71b:

Watch item: commit_to_text.observe() and wake_enabled(uid). It is an in-process lookup, not a flag-store round trip per written part. wake_enabled is reliability_experiments.enabled('commit_wake', uid), which goes to utils/reliability_flags.admits: on a worker thread that is omi_flags.resolve over the process's rule snapshot (the store refreshes that snapshot at most every 15 s for the whole process), and on an event loop it is the answer last learned for that account. The line above it, capture_latency.observe, already evaluates every registered experiment for the same owner at the same write, so this adds one more evaluation of the same snapshot.

Could not verify: allowed == (0, 0) in conversations_v3.load(). allowed is set a few lines above the hunk: allowed = _locked_allowance(uid, key='builder'), then reset to (0, 0) when _charge_locked_attempt refuses. The claim's copy of the lease document is reused only when lease_state is not None and not conversation_id and allowed == (0, 0). For a listed owner the charge has just written the lease, so that owner reads the lease document again, as before.

Could not verify: reach.json. It was rewritten by python -m testing.pipeline_lab scenario reach from one traced run of all 31 committed scenarios on this merged tree (all pass); tests/unit/test_pipeline_lab_affected.py passes on it.

Decision 1, the deletion guard. Agreed that this is the conversation-deletion owner's call. The flag row's ramp now starts with a step that admits no account, the internal allow list included, until that owner has reviewed and agreed the change, and the runbook says the same. No rule exists for any of the switches in this PR.

Decision 2, one merge unit. Yes, one merge unit is intended, for the reason in the description. Each part is rolled back by deactivating its rule, and none has a rule today.

fresh_class_for_new_audio and the worker image. Noted as a deploy checklist item: no rule before every process that requeues rows, the GPU workers included, runs this build.

🤖 Addressed by Claude Code

@Nizarius
Nizarius merged commit 6d3c16e into main Dec 1, 2026
77 of 78 checks passed
@Nizarius
Nizarius deleted the perf/backend-bottleneck-bundle branch December 1, 2026 12:43
Git-on-my-level added a commit that referenced this pull request Dec 1, 2026
…hone capture was removed

#26875 added a phone-microphone case to one_capture_transport_test.dart and #26345 then removed
phone microphone capture (and phone_mic_pigeon.g.dart) without that case, so Dart Analyze fails on
main. Phone capture no longer exists, so the case goes; the pendant cases are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants