Skip to content

fix(notes): first summary as soon as a sealed recording's transcript lands - #25635

Merged
kodjima33 merged 3 commits into
mainfrom
fix/live-record-first-summary-latency
Nov 17, 2026
Merged

kodjima33 merged 3 commits into
mainfrom
fix/live-record-first-summary-latency

Conversation

@kodjima33

@kodjima33 kodjima33 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Goal: a recording's summary within about a minute of it ending, with the existing Processing row shown meanwhile. For a batch-owned mobile live recording (batch_live_v1, server_batch_only), four things held the first summary back or hid the row. This PR removes all four. It adds no new user-visible concept and no flag; it shares the SYNC_UPLOAD_WATERMARK_ENABLED kill switch with #25538.

  1. Deadline wait after a complete transcript. Production runs with RECORD_NOTES_EAGER_ENABLED=false (backend-integration and backend-sync, read back today). So the record's units marked notes on the main settle path (database/batch_pipeline_projection.py:483, due +600 s). Dispatch then waited for the 120 s first-summary deadline (utils/enrichment/outbox.py:475), even after the record's last unit landed.
    • Fix: when the record binding completes, ProjectionStore.complete moves the row's existing open notes obligation to due now, inside the completion's commit transaction. After that commit it writes the ledger's transcribed, and only then wakes the obligation.
    • This also fixes a latent ordering race: the old code woke notes before writing the transcribed stage that the woken callback's seal proof reads.
  2. One held unit blocked the first notes for about an hour. A unit whose ASR came back empty is quarantined for recovery. That keeps the binding's complete() open (batch_pipeline_projection.py:849), so the ledger never gets transcribed, and fix(notes): a sealed mobile recording gets notes right away, not after a 10-minute quiet wait #25538's seal proof (utils/sync/capture_end.py:248-255) returns units_pending. The callback (utils/enrichment/callback.py:125) then fell back to the 600 s sync quiet wait (utils/sync/processing_hold.py:20,201). That wait restarts whenever a phone copy or a released bridge piece merges in (utils/sync/assignment.py:980).
    • Fix: hold_for_quarantine already reads every sibling in one transaction. When every unit is projected or held for recovery and the row passes seal_barrier, it:
      • stamps sync_processing_hold.units_settled_seal_at = record_sealed_at, and only on rows that already have a hold state;
      • moves the obligation to now in the same transaction, and wakes it after commit.
    • Both wakes (here and in complete()) are fail-open, like _rearmed. An exception is logged and left to the outbox sweep. It never fails the unit job, and in complete() it never skips _mirror or _settle_allowance after the durable commit.
    • seal_proof returns units_held while the stamp equals record_sealed_at; the metric outcome is sealed_held. A reseal invalidates the stamp.
    • A unit that is still transcribing (not quarantined) keeps the existing wait, so the first summary never fires halfway through a projection.
    • Accepted tradeoff: a held unit that recovers after the first notes is late content and follows the existing late-run rules (immaterial, late_cap, at most one material late run). So its text can land in the transcript while staying out of the notes. In debba5b8 that unit held 4 words.
  3. Summarized rows hidden for up to 2 h. The processing write merges maps (database/conversations.py:1378,1745,1747), so the stand-in's structured.title_provenance='server_minimum' outlived the real notes. is_settling_fragment (utils/conversations/fragment_visibility.py:196) then kept the summarized row off GET /v1/conversations until 2 h after its end. This was reproduced on a sync piece reprocessed today.
    • Fix: when a processing write carries real notes and omits the marker, summary_delivery.merge_result (called by both writers) deletes it (retires_title_marker).
  4. Home: a row with speech never disappears, and every read agrees.
    • Where prod Home reads today: the prod backend service runs HOME_FEED_ENABLED=false and no OMI_INDEXED_LIST_READS_ENABLED, and EPISODES_ENABLED=off. So prod Home is GET /v1/conversations (routers/conversations.py:1164-1189), which classifies full rows. That path already saw the row-level summary_title_provenance. The compact feed (database/home_feed.py:338), the slim list select and the episode member read classify a field mask that never loaded it (utils/conversations/home_titles.py:26).
    • Change 1: that field is now loaded, so those paths match the full-row list. For example, a projected batch row that owes notes shows the existing "Processing… · Writing notes…" row. No effect in prod until one of those paths is enabled.
    • Change 2, the settled Home rule: a row whose only stand-in marker is the row-level one, with no debt, no summary and no summary_blocked_reason, is now classified ready (a finished card), not noise (which both app paths hide: home_rows.dart:376, home_card_rows.dart:29).
      • Only stamp_projection_debt marks the row alone, and only when projected transcript text landed (live_projection.py:150-157). So these rows always carry speech.
      • They occur when the projection lands past the repair age gate, or when a later write clears the debt.
      • Rows that truly owe notes still show Writing notes. A row with real notes is ready.
      • These stay noise:
        • an intake stand-in (structured.title_provenance, e.g. "Mm-hmm.") with no debt;
        • a blocked row: local_only (including terminal_no_derived_effects and deferred), blocked_byok, and empty_output_exhausted even with HOME_EMPTY_OUTPUT_NOISE=false.
      • This reverses the "hide" half of 50d85f5's expectation, limited to unblocked rows carrying projected speech. The other half, never presenting "Writing notes" forever, is kept. The stamp_projection_debt docstring and the renamed age-gate test now say this.
    • Measured, read-only: last 7 days, Nik plus 30 randomly sampled batch owners, 10,540–11,350 non-deleted rows, current prod flags. 0 rows flip from visible to noise with the new field mask, and 0 rows reach the provisional branch's noise.
    • Limits of that measurement: it covers only those sampled owners, not every user. It also cannot cover a flag flip, such as enabling the feed, the indexed list reads, or setting HOME_EMPTY_OUTPUT_NOISE=false. The blocked-row tests pin the classification for those cases instead.
    • Not changed here: prod rows that are noise today all come from other branches. 1,128 are empty_output_exhausted (16 of them with a nonzero word count; Nik's 12 have none) and 24 are below the content floor. Those are a separate "missing from Home" candidate.

Prod timeline (read-only Firestore, ledger, batch job docs and Cloud Run logs, 2026-11-17 UTC)

debba5b8 (36 min recording, 8 record units, sync live target with one phone piece merged):

Step Time Wait Where
Cut (end observed) / audio end 18:06:05 / 18:06:07 listen
Record sealed 18:06:11 6 s record_sealed_at
Intake claimed → compute admitted 18:06:15 → 18:06:54 43 s batch jobs record_intake_claimed_at, compute_decision.at
STT ready, 7 of 8 units 18:07:11 17 s job ready_at
Unit d7ce8acf (92 s audio, 3.5 s VAD speech) worker_failed/empty_asr, quarantined 18:07:11 job quarantine_reason
Results committed (ordered merge) 18:09:03-06 114 s result committed_at
Text persisted on the row 18:09:57-18:10:25 52-80 s projection.persisted_at
Notes obligation opened (per-unit marks) 18:10:52 27 s summary_first_pending_at
Released bridge piece / phone copies merged; quiet clock restarted 18:06:26, 18:12:38 sync_merged_from, hold last_content_at
First-summary deadline run → deferred quiet_wait (seal proof units_pending, no ledger transcribed) 18:13:09 137 s outbox deferred_since/deferred_reason
Quiet due 18:22:38 569 s processing_hold.py:201
Enrichment request started → summary written 18:23:26 → 18:24:54 48 s dispatch + 88 s processing backend-integration request log
Held unit's recovery started → projected → binding complete 19:08:56 → 19:12:15 ~62 min held job recovery.prepared_at
  • Before: cut → summary 18.8 min.
  • After (same row, projected): the last unit's mark at 18:10:52 stamps the seal and wakes notes now, so the summary lands at about 18:12:20 (dispatch plus the 88 s processing). That is about 6.3 min from cut, and about 90 s after the transcript became complete on the row.
  • A row with no held unit gains the 120 s deadline back. Measured on 6c2a7917, ledger noted − transcribed = 137 s before this change; it becomes processing time only.

Other rows:

  • 604bd874: summary at 17:25:54, 18 s after its seal at 17:25:36. The cut came at 17:25:34, 2 min after audio end at 17:23:35, from the listen silence cut that a parallel listen PR shortens. Because of that 2-minute lag, the quiet window had already passed by the seal. This summary was built from merged phone content; notes were rewritten at 17:45:32 after the record landed.
  • 6ccc2ca6 (pure sync_vad piece): summary at 17:40:52, which is quiet due (last content 17:29:41 + 600 s) plus 71 s. That is the phone-upload quiet rule, unchanged here.
  • Sync pieces 5731e148 / c35a2059: held by pending_live_bridge for as long as live target c92384c3 is in_progress.
    • The callback re-polls every 30 s (utils/sync/bridge.py:395-433), and hourly after 6 h (utils/enrichment/outbox.py:69).
    • On the first poll after the target leaves in_progress, _finish_pending_live_bridge (bridge.py:196-244) merges a piece into the live row when choose_live_overlap picks it and the piece has no notes. Otherwise the piece is summarized on its own, under its own hold.
    • A merge restamps the live row's quiet clock. That restamp is exactly what this PR's seal proof now overrides for the first notes.
    • So bridge release adds at most about 30 s plus one dispatch.

Not changed / not verified

  • Batch STT pipeline time. Seal → transcript complete on the row took 4 min 41 s here: 43 s intake and admission, 114 s ordered merge, 52-80 s projection, 27 s finish. "Summary under 1 min after the recording ends" is not reachable until those stages shrink.
  • Processing time. The LLM notes step alone took 88 s (this 36-min recording) and about 100 s (a 21-min reprocess). That bounds what "within a minute of transcript ready" can mean.
  • Quarantine recovery. Recovery of an empty-ASR unit took about 62 min to start. Untouched here; the held unit now only arrives as late content.
  • Phone tail upload. The phone's own upload of the record tail got 503 for over an hour (sync_record_upload outcome=pending reason=audio_coverage_unproven). It does not gate the summary; not investigated further.
  • Conversations v3 is untouched (fix(conversations): start summary-only notes after quiet #25548 owns its quiet snapshots).
  • Listen lifecycle (routers/listen) is untouched.
  • Verification level. Unit tests only. No emulator or prod run, no deploy, no flag change. Existing stale structured.title_provenance leaves on already-summarized rows clear on their next processing write; nothing is backfilled.

Product invariants affected

none

How it was verified

  • Read-only prod evidence: Firestore conversations, pipeline_ledger, batch_pipeline_prod_jobs/_results, sync_reprocess_outbox; Cloud Run request and app logs.
  • Targeted suites, one pytest process per file:
    • test_record_complete_notes 46 passed
    • test_sync_capture_end 57
    • test_outbox_firestore 30
    • test_summary_delivery 65
    • test_home_step 128
  • Every new test fails with its source change reverted. Tests that assert "unchanged" behavior pass both ways.
  • Read-only prod Home measurement (above), with the real home_step.classify under prod's Home env values.
  • Follow-up commit: all 156 suites the selector and a grep tie to the changed files pass, one process each.
  • Changed-file selector (scripts/select_backend_unit_tests.py): all selected files, each in its own process. That run caught a decorator misplacement in an intermediate revision (3 suites), fixed before this commit. test_pusher_storage_pcm_saturation fails its RSS bound on this Mac on the base commit too.
  • Lints: scan_async_blockers 0 findings; scan_import_time_side_effects and check_module_stub_pollution 0 violations.
  • make preflight and scripts/pr-preflight --pr-body-file.

Tests

  • test_record_complete_notes.py:
    • eager-off completion makes notes due now, and the ledger write precedes the wake;
    • notes already written, an unsealed record and the kill switch each leave the obligation alone;
    • a held unit stamps the seal and wakes notes, while a still-transcribing unit does not;
    • a held unit after first notes changes nothing.
  • test_sync_capture_end.py: the units_held truth table (reseal, barrier); the stamp proves with no ledger read; the kill switch.
  • test_outbox_firestore.py: expedite_update never creates, reopens, unparks, re-leases or touches blocked or already-due rows.
  • test_summary_delivery.py: real notes delete the marker through the production leaf mask, and the stored row is no longer a settling fragment. A stand-in, empty output and new rows keep or skip it.
  • test_home_step.py:
    • a projected batch row read through CONVERSATION_FIELDS classifies writing_notes;
    • a past-age-gate stamped row (built with the real stamp_projection_debt) classifies ready on both the field-masked feed read and the full row;
    • a no-debt intake stand-in stays noise;
    • parametrized local_only, blocked_byok, and empty_output_exhausted with HOME_EMPTY_OUTPUT_NOISE=false stay noise.
  • test_batch_pipeline_live.py: the age-gate projection test (renamed ..._stamps_no_debt_and_stays_on_home) now expects ready; it had pinned noise.
  • test_record_complete_notes.py:
    • the held-unit wake carries the rotated token;
    • a raising wake does not fail hold_for_quarantine (the row stays due now);
    • a raising wake in complete() still returns the result and runs _mirror and _settle_allowance.
  • Each new test fails with its fix reverted.

UI-Evidence: none -- backend projection fields only; the app renders the existing server step unchanged.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

Change note: backend/docs/listen_pusher_pipeline/changes/2026-11-17-sealed-record-first-notes-latency.md. Related classes for parts 3 and 4: FC-read-projection-omits-visibility-field (Home field mask) and a merge write keeping an omitted leaf (no existing class).

🤖 Generated with Claude Code

…or the deadline, a held unit, or a hidden title marker

- Record completion (eager notes off, as in prod) writes the ledger's transcribed
  stage first, then moves the row's open notes obligation to due now instead of
  the 120 s first-summary deadline.
- A unit held for recovery (empty ASR, quarantined ~1 h) no longer holds the
  record's first notes: once every other unit is projected, hold_for_quarantine
  stamps the seal on the hold state and moves the obligation to now; seal_proof
  accepts the stamp (units_held, metric sealed_held).
- Real notes delete the stand-in's structured.title_provenance. The merge write
  kept that leaf, so the settling-fragment filter hid summarized rows for 2 h.
- Home's feed and list reads load summary_title_provenance, so a projected batch
  row that owes notes shows the existing Writing notes step.

Failure-Class: FC-batch-fault-domain-head-of-line-poison
…it notes wake

- home_step: a row marked a stand-in only at row level (the batch projection
  stamps it only when transcript text landed) with no debt and no summary is a
  finished card, not noise. Intake stand-ins with no debt stay noise.
  Measured on 7 days of prod rows (Nik + 30 batch owners): 0 rows change.
- hold_for_quarantine: a wake exception after commit is logged and left to the
  outbox sweep instead of failing the unit job; test pins the rotated token.
- Change note: ordering (due-now move in the commit, ledger after commit,
  then wake) and the accepted late-unit tradeoff.

Failure-Class: FC-batch-fault-domain-head-of-line-poison
…s wake

- home_step: the finished-card branch for a row-level stand-in now also
  requires no summary_blocked_reason, so local_only, BYOK and empty-output
  blocks (also with HOME_EMPTY_OUTPUT_NOISE off) stay noise.
- complete(): the post-commit notes wake shares the fail-open helper with
  hold_for_quarantine, so a raising wake never skips _mirror or
  _settle_allowance or fails the unit job.
- stamp_projection_debt docstring and the age-gate test name match the
  settled Home behavior.

Failure-Class: FC-batch-fault-domain-head-of-line-poison
@kodjima33
kodjima33 merged commit 0c999f7 into main Nov 17, 2026
71 of 73 checks passed
@kodjima33
kodjima33 deleted the fix/live-record-first-summary-latency branch November 17, 2026 21:55
kodjima33 added a commit that referenced this pull request Nov 18, 2026
…allowlist canary) (#25673)

## What changed and why

**Problem.** A pendant recording should show its transcript and summary
on Home within 60 s of the seal. In prod it takes minutes. The largest
p50 stage after the seal is not the GPU. It is the ordered merge: 80% of
recordings wait the full 60 s `BATCH_PIPELINE_MERGE_HEAD_WAIT_SECONDS`
behind a starved head. That head is a days-old `retry` job, and the
existing bypass then commits the same row 60 s late.

**Change.** Owners listed in the new
`BATCH_PIPELINE_MERGE_STALE_HEAD_UID_ALLOWLIST` (default empty) skip the
head wait when it is waiting only on starved rows. A starved row was
admitted at least 1,800 s ago and has waited that long for a lease:
`ready`/`retry` with `available_at` at least 1,800 s in the past, or
`leased` with `lease_until` at least 1,800 s in the past. Every
lease-ending path (`_defer`, admission hold, missing-input repair, held
requeue, redrive, quarantine) resets `lease_until` to 0 and stamps
`available_at`, so a row that failed seconds ago, or is due again in
seconds, is not starved. The skip commits exactly the row the expired
wait would commit (the owner's earliest ready pending row) through the
same transaction body. Inside that transaction it also requires:
- the row is a native record unit whose earlier binding units are
settled;
- every pending row captured before it is starved. A new bounded
`pending_page` read (129 rows, `first_pending`'s filters, order and
index, on every store backend) checks this; a longer backlog refuses.

A refused skip returns before the catch-up hold and the backlog-release
fallback. Without the early return, a provider-route record candidate
could set `held['backlog']` and the tx-fresh fallback would run before
60 s; with it, that fallback is unreachable from a skip. A skip logs
`event=batch_merge outcome=stale_head_skip` (head state + wait bucket)
and does not write `head_wait_bypass`, so the bypass field and log stay
real expiries only. Unchanged:
- unlisted owners
- head wait off
- non-record rows
- any unready row ahead that is in flight, recently leased, younger than
30 min, or in another state (`record_pending`, `held`)

### Stage budget, seal to Home summary (prod, read-only)

Sample: 600 random `batch_live_v1` rows with `record_sealed_at`, sealed
45 min to 8 h before 2026-11-18 07:50Z, out of 6,730 eligible. 432 had
every unit committed. Per recording, the critical path is the last unit
to commit. Units per recording: p50 1, p75 2, p90 5.

| Stage | p50 s | p75 s | p90 s | Note |
|---|---:|---:|---:|---|
| seal -> intake claimed | 8 | 396 | 732 | bimodal: 56% < 15 s, 36% wait
5-15+ min |
| claimed -> staged/admitted | 6 | 9 | 19 | |
| admitted -> GPU result (queue + compute) | 9 | 21 | 62 | GPU is not
the bottleneck |
| **GPU result -> committed (ordered merge)** | **62** | 137 | 372 |
346/432 via head-wait bypass: p50 67 s single-unit, 98 s multi-unit.
Without bypass: 0.1 s |
| committed -> persisted (projection discovery) | 21 | 33 | 43 | |
| persisted -> ledger `transcribed` (follow-up/completion) | 37 | 62 |
99 | 33 s single-unit (eager wake), 46 s multi-unit |
| `transcribed` -> `summary_completed_at` (notes) | 38 | 58 | 93 | Luna
`conv_structure` |
| seal -> `summary_completed_at`, end to end (n=235) | 452 | 708 | 1,496
| |

Sum of p50 stages on the fast-claim path: about 181 s.

**Root cause of the merge stage.** For 20 of 20 sampled bypassed owners,
the earliest pending fresh-class row is a native record job in `retry`,
captured 36-215 h ago and due long ago (`available_at` in the past).
`fresh_capture` is fixed at admission. The tx-fresh gate and
`_fresh_pick` therefore treat these rows as fresh heads, and every new
recording waits out the full 60 s. The canary account (`viUv7G...`) has
this shape: a 78.6 h-old catch-up `retry` head, with fresh-class `retry`
stock from 84 h ago behind it.

### Ranked cuts (expected p50 seconds saved for the seal -> summary
path)

1. **Stale-head skip (this PR).** Saves 45-55 s on ~80% of recordings.
All 75 of the canary owner's rows ahead are starved under this rule:
`retry`, due 10.3-90.3 h, unleased (53 at attempt 1, 22 at attempt 0, so
an `attempt == 0` rule would exclude most of them). They fit inside the
129-row page. Sampled owners had 8-134. Low risk: same rows and outcome
as today's bypass, 60 s sooner, allowlist-scoped. After a CPU roll the
commit lands on the next serving tick (10 s on prod
backend-integration). After a GPU worker roll it lands at publication,
saving about 60 s.
2. **Persisted -> `transcribed` completion.** Saves 20-35 s. Low-medium
risk, small to medium effort. `RECORD_FOLLOWUP_WAKE_ENABLED` covers only
single-unit records (`projection.py:1627`), and even single-unit takes
33 s. Extending the eager wake to multipart, and finding the single-unit
delay, comes next.
3. **Post-commit projection wake (committed -> persisted).** Saves 15-20
s. Medium effort. The GPU pump commits directly with no `on_committed`
hook, so this needs a GPU image roll.
4. **Intake-claim tail.** p50 unchanged, p75 about -380 s. Medium risk
and effort. 36% of seals wait 5-15+ min for the `record_pending` claim.
Needs diagnosis: record-drain capacity (10 rows per pass) vs ~1,200
seals/h, or barrier refusals.
5. **Starved fresh-class `retry` heads themselves.** Same seconds as cut
1, for every owner. Medium effort. This is a scheduler question: why due
FRESH `retry` rows go unleased for days. Fixing it removes the need for
cut 1's allowlist.
6. **Notes model time.** At most 5-15 s, with quality risk. Luna
one-shot; the fleet notes histogram is ~25 s model time. Needs a quality
eval before any model or prompt change. Not recommended now.
7. **Staged cuts, no gain now.**
- `RECORD_FRESH_MERGE_ENABLED` (cut 4): its blocker is unresolved. The
prod GPU worker image tag is `ef42ee8` (2026-11-14), which predates the
sibling guard `a0a8816`. It would also not help here, because the stale
heads are already fresh-class.
- `RECORD_NOTES_EAGER_ENABLED` (cut 2): superseded by #25635, which
already moves the notes obligation to due-now at completion. The
lease-off producer revision blocker is still open.
8. **Pre-seal admission of completed units.** Saves at most ~25 s
(admission + GPU = 15 + 9 s p50). Very high custody risk: the seal
barrier is the admission contract (`require_record_audio_barrier`). Not
recommended.

**What remains to reach 60 s p50.** After cut 1 (with a GPU roll), the
fast path is about 8 + 6 + 9 + ~1 + 21 + 37 + 38 ≈ 120 s. Cuts 2 and 3
bring it to about 65-75 s. The rest has to come from notes (cut 6) or
claim/staging. The intake-claim tail (cut 4) dominates p75 and must be
fixed for a p75 target.

**Related.** #25633 (120 s speech-quiet seal) and #25635 (first summary
when the sealed transcript lands) are live. #25601 and #25623 (David)
work on stuck projection chains/heads; they touch no file here. The
staged cuts and the 60 s head wait are documented in
`2026-11-14-record-post-seal-latency.md`.

## How to canary and roll back

- **Canary for one account.** Set on prod Cloud Run
`backend-integration` (the serving loop host,
`BATCH_PIPELINE_SERVING_ENABLED=true`):
`BATCH_PIPELINE_MERGE_STALE_HEAD_UID_ALLOWLIST=viUv7GtdoHXbK1UBCDlPuTDuPgJ2`.
This PR deliberately adds no runtime-env overlay entry: put it in the
`backend-integration` section of
`backend/deploy/runtime_env/prod.overlay.yaml` as part of the canary
change, so the next deploy keeps it. The backend image must contain this
PR. `config/deployment-setting-classification.json` classifies the
variable as `config`. The GPU worker needs nothing; adding the same env
there after its next image roll moves the commit to publication time.
- **Readback.** A skip leaves no durable marker, so readback relies on
the `event=batch_merge outcome=stale_head_skip` log line. On the canary
account's next recordings, `committed_at - ready_at` of the last unit
should drop from ~60-100 s to ≤ ~10 s, with no `late_capture` within a
recording.
- **Rollback.** Remove the uid or unset the env. No migration; committed
rows keep their order.

## Product invariants affected

none

## How it was verified

- Prod measurement used read-only Firestore (collection-group
`conversations` query on `record_lane_owner`/`status`/`finished_at`,
joined to `batch_pipeline_prod_jobs` and `_results` and to
`pipeline_ledger`) and read-only `kubectl`/`gcloud` describes. No prod
writes, env or flag changes.
- `pytest tests/unit/test_batch_pipeline_merge_stale_head.py`: 32
passed. Jobstore SQL safety plus protocol parity: 210 passed.
- 94 directly affected test files pass locally: merge, jobstore, parity,
scheduler, transaction-attempt, pipeline sims, all Firestore query/index
guards, `test_flag_budget.py` and `test_record_seal_latency.py`. CI runs
the full 1,260-file selection.
- Existing merge suites unchanged and passing:
  - `test_batch_pipeline_merge_head_wait.py` (177)
  - `test_batch_pipeline_merge_fresh_first.py` (59)
  - `test_batch_pipeline_merge_tx_fresh_gate.py` (24)
  - `test_record_seal_latency.py` (58)
  - `test_batch_provider_merge_membership.py` (46)
  - `test_batch_terminal_poll_skip.py` (42)
  - `test_batch_backlog_release.py` (57)
  - the recovered-release suites and the head-wait sims
- All 24 changed-file-selected unit test files pass, including
`test_flag_budget.py`, `test_pipeline_sim*`,
`test_lifecycle_invariants.py` and
`test_cross_service_deploy_contract.py`.
- `backend/scripts/typecheck.sh`: 0 errors. `make preflight`: 43 checks
passed. `scripts/check_feature_flag_registry.py`: OK.
- Not verified: a live canary. That requires the backend roll and env
change, which belong to the parent.

## Tests

`backend/tests/unit/test_batch_pipeline_merge_stale_head.py` (32 cases)
covers:
- a listed owner commits at once behind a starved head, with its own log
and no `head_wait_bypass`; an expired wait keeps the bypass marker
- **realistic heads that are not starved keep the wait:** in flight; the
reviewer's lease-expired retry due again in 10 s (`lease_until=0`,
`attempt=1`); a retry that failed 10 min ago; a row redriven a minute
ago; `record_pending`; `held`
- a prod-shaped retry due for 10 h without a lease is starved and skips
- a head deferred between the probe and the transaction keeps the wait
- **a young, leased recording captured earlier blocks the skip**; both
then commit in capture order
- **a refused skip of a backlog-held (provider) unit commits nothing,
adds no held owner and runs no early fallback transaction** before 60 s
- the 129-row page bound: 128 starved rows ahead skip, 129 refuse
- unset, empty or other-uid allowlists keep the 60 s wait
- head wait off keeps strict order
- an unready earlier unit of the same recording waits
- non-record rows keep the wait
- the prod shape (catch-up head plus fresh-class stock), with the tx
fresh gate on and off
- exact allowlist parsing

Mutation check: restoring the old `lease_until`-only rule fails 4 of
these tests, and removing the early return fails the backlog test.

`test_jobstore_sql_safety.py` adds `pending_page_in` binding and
limit-cap coverage. `test_jobstore_protocol_parity.py` checks that every
backend serves `pending_page`, and the Firestore query-shape registry
drives the new query.

## UI evidence

UI-Evidence: none -- backend merge scheduling only

## Failure class (fixes)

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant