Skip to content

fix(batch): unfreeze stuck owner chains and held-partial uploads - #25601

Merged
Git-on-my-level merged 8 commits into
mainfrom
lane/head-block-stamp
Nov 18, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
lane/head-block-stamp

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Problem

An owner's batch uploads project strictly in order behind a per-owner watermark. When the chain head fails in a way that may still resolve (a transient error, or a fresh "awaiting writer" conflict such as a live target that listen has not persisted yet), the head waits under a durable 24 h bound. After that, the generic poison-head rule holds it and the chain advances.

That bound never started. Projector._note_head_blocked passed a plain function to ProjectionStore.run. run_transactional hands its callable a raw, unbegun transaction, and only a @firestore.transactional callable begins it. So every read raised ValueError('Transaction not in progress, cannot be used in API requests.'). The stamp was swallowed as head_block_note outcome=retry, projection_blocked_since never landed, and head_retry_bound_exceeded could never fire. Every such head waited forever and froze its owner's chain.

Evidence

Prod, read-only ro-prod tier, 2026-11-17 ~11:10Z. backend-integration serves backend-integration-fold-fb3d7732f270 at 100%, OMI_BACKEND_RELEASE_SHA=0ce396503a55.

  • head_block_note outcome=retry exception_type=ValueError: 436 lines in 9 minutes (~48/min).
  • The same ValueError reproduces offline: firestore.Client(...).transaction() passed unbegun to DocumentReference.get(transaction=...).
  • The oldest 300 projection_state=pending results belong to just 6 owners, committed from 10-31 onward. Every one of their chain heads is pending, has no projection_blocked_since, and has not been written since its commit (up to 14 days).
  • A field user's chain has been frozen since 11-16 22:59Z with 625 rows behind its head, and their app shows "processing" for every newer upload.

Fix

  • ProjectionStore.note_head_blocked(segment_id, now, block_type) is a @firestore.transactional read-then-update, written like the store's other transactions (defer_finish). It stamps only a pending/persisted/ready row without an existing stamp, once per episode.
  • Projector._note_head_blocked delegates to it and keeps the same failure logging.
  • A static test fails if utils/batch_pipeline/projection.py calls store.run directly again. A hard type check in ProjectionStore.run was tried and rejected, because unit tests drive run with Mock operations.

Tests

New backend/tests/unit/test_batch_projection_head_block_note.py:

  • The stamp lands through ProjectionStore on StrictFirestore, once per episode, and never on a row outside the assignment states.
  • Projector._note_head_blocked reaches the store, and the 24 h bound starts from it.
  • The static store.run guard.
  • An old backfill head failing with LIVE_TARGET_NOT_PERSISTED is held and frees the chain, through the real owner-chain walk.

Projection and owner-chain suites (test_batch_pipeline*proj*, test_batch_projection*, quarantine, sweep owner chain, jobstore mirror): 1,108 passed. One test, test_batch_projection_playback_artifact_missing.py::test_missing_staged_object_skips_playback_and_counts, failed only in the combined run. It passes alone with and without this change, so it is order-dependent.

Second fix: the held-partial pass never reached late IDs

A single-segment upload whose only unit is failed_held settles partial through the held-partial sweep (Projector.sweep_held). That sweep pages recovery_state in (held, failed_held) in document-ID order, but kept its resume point in Projector.held_after, which is process memory.

  • backend-integration had 40+ revisions since 11-10 and 500+ instance startups in the last 24 h.
  • One pass over the ~53k held/failed_held jobs, at the observed ~32 units per 20–40 s segment under the hourly read governor, takes days.
  • So each new maintenance leader restarted at page one. An upload with an empty-ASR unit, bp_2ba4592b, has been processing since 11-12. An otherwise identical upload (bp_e232cfee) about 800 IDs earlier settled partial on 11-16.

The fix persists the cursor in control/projection_held_partial_cursor, through the release scan's load_release_cursor/save_release_cursor (#24361). That costs one read and at most one write per segment. A fresh pass (no cursor) also clears this process's upload dedupe, which another instance's wrap has made stale. New test: test_restarted_instance_resumes_the_held_pass_from_the_durable_cursor. The quarantine-recovery, serving, release, head-block and owner-chain suites pass (511).

Review fixes (panel review-20261117t121718-4c7e)

  • StrictFirestore(require_begun=True) rejects an unbegun transaction the way the SDK does. The stamp tests use it: removing @firestore.transactional from note_head_blocked now fails 3 tests, and a new test pins the pre-fix shape. It is opt-in because about 330 test files drive inner transaction bodies with a raw fixture transaction on purpose.
  • The live-target chain test is split in two. One covers an old capture held by the 6 h age gate. The other covers a recent capture: it waits, gets stamped, holds after 24 h, and the chain frees. That second one fails if the stamp raises. The non-existent env var is gone.
  • merge_ready (source fallback) clears projection_blocked_since/projection_block_type when it re-pends a preserved slot, like the release reset does.
  • The stamp field names moved to database/batch_pipeline_projection_protocol.py, so the store no longer imports from utils.
  • Pipeline change note: backend/docs/listen_pusher_pipeline/changes/2026-11-17-projection-head-block-stamp.md.

Third panel (review-20261117t132925-498a, SHIP) fixes

  • The bound test now fails the head with a transient TimeoutError. An awaiting-writer conflict on a capture older than 6 h holds on the age gate before the 24 h bound is ever consulted. The test asserts the head is still pending at 24 h − 1 s and held at 24 h + 1 s, and it fails if head_retry_bound_exceeded or the stamp is broken.
  • A failed cursor save keeps the in-memory cursor and retries the save, so the next segment doesn't fall back to the stale durable value. save_release_cursor now returns whether it wrote.
  • The store.run static guard also catches a bare store.run(...). The ResultLog.note_head_blocked fake returns False for a missing row.

Rollout note

Nothing is gated, and the existing kill switches are unchanged. After deploy, every waiting head gets stamped on its next visit and holds 24 h later. Heads that have waited for days therefore release about one day after deploy, and their successors then project. Watch omi_batch_projection_* holds and backlog in that window. Held units keep their audio and follow the existing hold-recovery path.

Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1845 -> 1850 | durable held-partial cursor wrapper; the cursor helpers live in batch_pipeline_projection_release.py and the stamp field names moved to batch_pipeline_projection_protocol.py

Failure-Class: FC-unresolved-head-blocks-projection

Product invariants affected

none

🤖 Generated with Claude Code

Projector._note_head_blocked passed a plain function to ProjectionStore.run.
run_transactional hands its callable a raw, unbegun transaction and only a
@firestore.transactional callable begins it, so every read raised
ValueError('Transaction not in progress') and the stamp was swallowed as
`head_block_note outcome=retry`. projection_blocked_since never landed, so
head_retry_bound_exceeded could never fire: a head that waits (transient
failure, fresh awaiting-writer conflict) waited forever and froze its whole
owner chain.

Prod, backend-integration at 0ce3965 (2026-11-17): ~48 failed stamps a
minute; the oldest pending rows belong to six owners whose heads have sat
unstamped and untouched since commit, up to 14 days.

The stamp is now ProjectionStore.note_head_blocked, a @firestore.transactional
method like the store's other transactions. A static test keeps projection.py
from running store transactions itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-18T07:48:31.472369Z
We couldn’t complete this review. Comment @codex review to try again.
0a002db New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0efa06ca2f

ℹ️ 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".

``ValueError('Transaction not in progress')`` and the 24 h head bound
(``projection_blocked_since``) never started.
"""
from utils.batch_pipeline.projection import PROJECTION_HEAD_BLOCKED_SINCE, PROJECTION_HEAD_BLOCK_TYPE

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move shared head-block constants out of the projector module

The new function-local import introduces a reverse dependency from the database layer into its caller: utils.batch_pipeline.projection already imports ProjectionStore from this module. This violates backend/AGENTS.md's explicit top-level-import and dependency-hierarchy requirements and creates a circular dependency concealed by the deferred import. Move the shared field constants into a lower-level module, such as config.batch_pipeline, and import them at module scope in both consumers.

AGENTS.md reference: backend/AGENTS.md:L168-L174

Useful? React with 👍 / 👎.

@Git-on-my-level Git-on-my-level changed the title fix(batch): stamp a blocked chain head inside a real transaction fix(batch): unfreeze stuck owner chains and held-partial uploads Nov 17, 2026
Git-on-my-level and others added 3 commits November 17, 2026 19:25
sweep_held kept its resume point in Projector.held_after, process memory.
backend-integration starts instances hundreds of times a day while one pass
over ~53k held units takes days under the read governor, so every new
maintenance leader restarted at page one and units late in ID order were
never examined. bp_2ba4592b's failed_held unit has waited since 11-12 while
an otherwise identical upload earlier in the ID order settled partial.

Persist the cursor in control/projection_held_partial_cursor through the
release scan's load/save helpers (#24361), one read and at most one write per
segment. A fresh pass also drops this process's upload dedupe, which another
instance's wrap made stale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…drive

Review panel review-20261117t121718-4c7e:
- StrictFirestore(require_begun=True) rejects an unbegun transaction like
  the SDK; the stamp tests use it, so dropping @firestore.transactional fails.
- Split the live-target chain test: old capture holds on the age gate; a
  recent capture is stamped, then held after the 24 h bound.
- merge_ready clears projection_blocked_since/projection_block_type when it
  re-pends a preserved slot.
- Move the stamp field names to batch_pipeline_projection_protocol so the
  store no longer imports from utils.
- Pipeline change note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review panel review-20261117t130323-9a5a F2: privacy replays continue the
same head-wait episode; only the release reset and source-fallback redrive
clear the stamp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5bf9249a68

ℹ️ 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".

Comment on lines +814 to +818
from database.batch_pipeline_projection_release import (
HELD_PARTIAL_CURSOR_KEY as key,
load_release_cursor,
save_release_cursor,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the release-cursor imports to module scope

The new import inside sweep_held violates the explicit requirement in backend/AGENTS.md that all imports be at module scope, never inside functions. Move these cursor helpers and the constant into the module-level import section so this new path follows the repository's dependency convention.

AGENTS.md reference: backend/AGENTS.md:L168-L174

Useful? React with 👍 / 👎.

…ved cursor

Review panel review-20261117t132925-498a (SHIP):
- F3: the bound test failed the head with an awaiting-writer conflict, which
  the 6 h age gate holds first; drive it with a transient TimeoutError and
  assert pending at 24 h - 1 s, held at 24 h + 1 s.
- F4: a failed cursor save keeps the in-memory cursor and retries the save.
- F7/F9/F10: test fake and static guard tightening.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d320876401

ℹ️ 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".

Comment on lines +824 to +826
start = self.held_after = self.held_after if unsaved else durable
if start is None:
self.held_pass_seen = set()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Invalidate upload dedupe when another instance wraps the pass

With multiple projector instances sharing this cursor, another instance can wrap the scan and advance into the next pass before this instance loads it, so start is non-null while held_pass_seen still belongs to an older pass. Uploads whose previous completion returned waiting or raised an error can then be skipped indefinitely. Exercising these methods with one-row pages reproduces this: instance A processes b, instance B processes c, wraps, and processes a, then A repeatedly skips b on every subsequent fleet pass. Persist a pass generation alongside the cursor and invalidate local dedupe when that generation changes, rather than relying on observing a null cursor.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Git-on-my-level
Git-on-my-level merged commit b517fea into main Nov 18, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/head-block-stamp branch November 18, 2026 08:19
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