Skip to content

E1: batch pipeline policy snapshot - #22448

Merged
Git-on-my-level merged 27 commits into
mainfrom
lane/flag-policy-e1
Oct 19, 2026
Merged

Git-on-my-level merged 27 commits into
mainfrom
lane/flag-policy-e1

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Result

E1 records immutable policy parts where their owners make the first decision. Admission persists only its own fields. Projection, scheduler and recovery each CAS a part on first handling; first-summary policy is stamped when its obligation is created. Every part has schema_version, source_role and a stable content-hash policy_id. Subsequent handling and replay consume the recorded part, preserving the first writer across env changes and restarts.

This implements the parent's 2026-10-19 per-owner source ruling. No new RPC, env/config/IAM edits, or prod/dev env-value changes. Worker-owned pump.py and diarizer/batch_pipeline.py are untouched by this diff; main's #22358 GPU controls remain explicit E1b exceptions; EMPTY_ASR_* and worker dispositions remain E1b. Listen session policy remains E2.

Per-role ownership

Part First stamp / owner Recorded on
Admission Admitting sync/native-record role: batch arm/percent/allowlist, live-record admission, nested retirement, local final-pass decisions Batch job policy (outside projection_binding), Redis sync job beside ledger_fence_mode
Projection First projection handling: contention, async, labels, live-target requirement, timing Job policy_parts.projection
Scheduler First scheduler pull/failure: head priority, shared live, attempts Job policy_parts.scheduler
Recovery First quarantine-owner handling: mode/cohort, multilingual/provider and terminal-empty decisions Job policy_parts.recovery
First summary Enrichment owner at obligation creation: cohort and deadline; coalescing retains it Outbox first_summary_policy; sim's recorded obligation

Read-only ro-prod evidence compared the two traffic-serving Cloud Run revisions (not templates). They differ on these seven keys, so an intake-wide snapshot would change behavior: BATCH_PIPELINE_AUTHORITATIVE_LABELS_ENABLED, BATCH_PIPELINE_REQUIRE_LIVE_TARGET_ENABLED, BATCH_PIPELINE_PROJECTION_CONTENTION_ENABLED, BATCH_PIPELINE_PROJECTION_TIMING_ENABLED, BATCH_PIPELINE_RECOVERY_MODE, BATCH_PIPELINE_SPEECH_EMPTY_MULTILINGUAL_ENABLED, BATCH_PIPELINE_TERMINAL_EMPTY_DISPOSITION_ENABLED. Key names only; no env values or user data are included here.

When B ships a canonical stage profile, these owner parts can move to admission without changing consumers. E1 does not add a remote dependency.

Before / after read map

Reader Before After
Sync routing, record-upload routing, intake, admission transaction Independently re-read admission/live-record cohorts One admission policy passed separately through every edge and recorded on jobs; transaction compares the recorded decision; status polls and non-admission roles stay read-only for admission metadata
Projection, transactional retry, follow-ups Re-read contention, async projection, authoritative labels, live-target requirement and timing Owner's CAS part, passed through projection; mixed policies drain together
Scheduler pull and failure Current shared-live/head-priority flags and scheduler-construction max attempts First scheduler part fixes eligibility and attempt limit
Quarantine recovery / task handler Re-check current owner and recovery mode, including after download First recovery-owner part; live privacy and paid-intent fences remain authoritative
Batch first-summary obligation / simulator grader Current cohort could reinterpret an existing obligation Creation policy persisted on enrichment and graded from the recorded snapshot
Shadow final-pass arm and promotion Two final-pass getter reads One invocation snapshot (the inventory's shadow read was final-pass, not batch admission)

Process startup, auth/service endpoints, provider packing, scrape controls and recovery discovery page size remain outside E1 snapshot ownership. Live E1 ops switches use only kill_switch(name): recovery task dispatch, projection pagination and the leader lease (which retains its on-unless-false semantics). The allowlist is checked against registry lifecycle: ops_kill. Privacy/deletion fences remain live data checks.

The policy boundary fails direct reads of the declared snapshot-owned batch keys and live-switch keys outside config/policy/, and rejects consumer calls that re-resolve stage getters. Unowned BATCH_PIPELINE_* keys print WARNING lines naming the file/key as E1b candidates, with a successful exit status. There is no hand-maintained worker-key allowlist, so another team's new worker knob cannot block their PR. Tests cover owned-key failures, live-switch failures, and warning-only handling for new unlisted keys.

Examples awaiting E1b are BATCH_PIPELINE_PUBLISH_CONCURRENCY (config/batch_pipeline.py, pump publication series), BATCH_PIPELINE_FLIGHT_BATCH_SECONDS and BATCH_PIPELINE_FLIGHT_BATCHING_ENABLED (config/batch_pipeline_providers.py, GPU batching / worker series #22368), and BATCH_PIPELINE_DIARIZE_SPEECH_ONLY_ENABLED / BATCH_PIPELINE_MODEL_BATCH_SIZE (diarizer/batch_pipeline_flight_qualify.py, #22368). These remain worker-owned and are not snapshotted by E1.

Cohort salts and retirement

Cohort Salt Membership
batch pipeline Existing empty salt; exact sha256 first-four-byte bucket unchanged
live-STT retire Same batch salt intentionally nested
summary_guarantee / first-summary Existing empty salt; compatibility exception unchanged
final-pass percent Existing empty salt; compatibility exception unchanged
recovery Named allowlist only unchanged

Retire percent is clamped to batch percent and retirement additionally requires batch admission. This intentionally closes unsafe retire-without-batch configurations. Every new percentage cohort needs its own nonempty salt; E1 does not reassign existing first-summary/final-pass users.

Grok follow-up

  • Main already exempts a durable record_pending reservation from a fresh cohort check, and its existing live regression expects draining after rollback. E1 preserves that accepted-work behavior, rejects an explicitly recorded false reserve bit, and adopts the recorded reserve part without comparing unrelated source-role/final-pass fields.
  • Recovery/redrive/disposition/artifact paths use the stored recovery part. The import-aware getter guard covers new directories and aliases; pre-unit listen admission remains E2.
  • Worker/projection/recovery handling cannot stamp an admission fallback from their own env. Admission fields stay unset on old rows until an admitting role handles them.
  • The new role_policy trace records policy values, source roles and hashes under different sync/integration environments. Swapping either projection or recovery to sync must independently break its golden. Existing golden bytes remain unchanged.

Validation

  • Targeted batch suites, all simulator scenarios and characterization checks run through file-isolated backend/test.sh, serially at nice -n 10.
  • Full selector: 2,010 files (2,009 isolated unit files plus the selector's canonical-memory E2E entry, run through its hermetic harness). The long serial unit pass completed; its ten CPU-only fixture overruns and one missing local workflow-output fixture are all pass in the final corrected same-runner rerun. Fixture construction/imports and the shared canonical reference move into setup; actual product operations, assertions and normal timing budgets remain unchanged. The 45-WAL permutation and replay properties run as separate guarded cases across all 12 arrival orders. No skip or duration exceptions.
  • All eight existing characterization JSON files are byte-identical to current main. Main's independent test(batch): align harness with #22321 recovery contract #22385 and fix(batch): one outstanding quarantine-recovery wake per paid intent #22458 refreshed dispatch/wake goldens; E1 changes none of those files relative to main. The additive role-policy golden incorporates main's wake leasing while its policy fields remain unchanged. The added policy-window golden covers obligation creation at first-summary percent zero and rejects a counterfactual current-policy grade.
  • Initial CI found and fixed a read-only Redis status regression and disabled-cohort read amplification; unchanged ownership, purity and membership suites pass after the fix.
  • Cross-service current-manifest and mutation cases pass. All three real pre-fix/fix historical comparisons also passed; their setup now runs in fixtures under the normal timing guard, without an exception.
  • The final full sync + batch emulator gauntlet passed after atomic policy repair, with persisted role/hash and first-summary creation-stamp assertions. Hermetic E2E: 128 passed; existing 3 skips and 2 expected failures are unchanged. Typecheck passed with zero errors. Policy/registry checks passed. make preflight passed all 36 local checks after moving native-record policy repair onto the database executor; Both final local make preflight and CI-lane body preflight passed all 36 checks on the final tree.
  • Cloud tier: ro-prod, read-only serving-revision metadata comparison only. No product endpoint calls, deployment, config or IAM changes.

The shared primitive is the immutable resolver plus durable per-unit snapshot. The AST guard enforces its boundary; it is not a replacement for the primitive. The real incident it prevents is the 2026-10-18 policy window, where obligations created at first-summary percent zero were graded against a later 120-second contract. The guard runs in both local and CI manifest lanes and rejects aliased/subscript env reads too.

Product invariants affected

INV-MEM-4 (product/invariants/memory-promotion-authority.md): vector storage remains a rebuildable derived view. The canonical-vector test only moves its existing isolated database setup into a fixture; its real vector and privacy assertions remain intact. E1 does not change memory authority or promotion.

Rollback

Revert E1 snapshot wiring. Admission and stage metadata are additive job fields; projection_binding retains the exact pre-E1 schema. A frozen constructor fixture from main 0d8e125 accepts the bindings E1 writes. No policy is copied into old bindings. Pre-E1 admission fallback is written only by an admitting role; other roles leave admission fields unset and stamp only their own part. Durable fields need no deletion. Preserve accepted-work drain and privacy fences. The parent handles Grok review/merge; deployment belongs to the two-lane train.

Failure-Class: FC-additive-field-decides-identity

# Conflicts:
#	backend/config/batch_pipeline.py
# Conflicts:
#	backend/testing/sync_cloud_tasks_stack/batch.py
# Conflicts:
#	backend/routers/batch_pipeline.py
#	backend/tests/unit/test_batch_pipeline_serving.py
#	backend/utils/batch_pipeline/serving.py
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T12:30:53.936143Z a743ec1 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: 3a62781fcf

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

retire = min(parse_percent(env.get('BATCH_LIVE_STT_RETIRE_PERCENT', '0')), percent)
final_pass = False
if env.get('TRANSCRIPTION_FINAL_PASS_DIARIZER', 'legacy') == 'pyannote_shadow':
final_percent = max(0.0, min(100.0, float(env.get('TRANSCRIPTION_FINAL_PASS_PERCENT', '0'))))

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 Fail closed on malformed final-pass percentages

When TRANSCRIPTION_FINAL_PASS_DIARIZER=pyannote_shadow, a malformed TRANSCRIPTION_FINAL_PASS_PERCENT now raises ValueError here. Because sync_local_files_v2 unconditionally calls resolve_batch_policy(uid) before routing every upload, a typo in this otherwise unrelated final-pass setting makes all sync uploads return an error rather than merely disabling the final pass. Non-finite values are also unsafe: nan is clamped to 100 by this expression and unexpectedly enables the cohort. Parse this value with the same finite, invalid-to-zero handling used for the batch percentages.

Useful? React with 👍 / 👎.

Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…ider_reason='byok')

The route stays language-only; provider_reason='byok' records that admission
funded the unit while the validated keys were present. The provider stage
never re-runs the keyless funding check for it. Writing the same value into
ProjectionBinding.policy (lane 6's GPU dispatch skip) waits for E1 (#22448):
neither ProjectionBinding.policy nor BatchUnitPolicy.provider_reason exists
on integration yet.

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: 35e73d5005

ℹ️ 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 +71 to +73
policy = replace(
resolve_batch_policy(uid), batch_enabled=True, live_admission_enabled=True, live_record_enabled=True
)

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 Preserve the policy chosen when reserving native recordings

When a recording is reserved as batch_live_v1, this code can run minutes or hours after the route was chosen, but it resolves every policy field from the current environment and only forces the three batch/live booleans. If rollout percentages or final-pass settings change while the recording is in progress, the durable job records new batch_percent, retirement, and final-pass decisions rather than the policy under which the capture actually ran, corrupting rollout attribution and replay results. Persist the admission policy with the route reservation and reuse it here.

Useful? React with 👍 / 👎.

Comment on lines +545 to 550
if (
outcome == 'ok'
and metadata['comparison']['remap_safe']
and policy.final_pass_authoritative
):
metadata['promoted'] = conversations_db.promote_final_pass_if_current(

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 Honor the recorded authority through final-pass promotion

When TRANSCRIPTION_FINAL_PASS_AUTHORITATIVE is rolled back after _run_shadow captures this policy but before the pass completes, this branch still runs under the recorded true decision, yet promote_final_pass_if_current immediately re-reads authoritative_for(uid)—both before and inside its transaction—and refuses the promotion. Because the old code checked enablement immediately before starting the pass, the new earlier snapshot can now spend the full final-pass work only to have the live downstream gate discard it; pass the recorded authority into the fenced promotion instead of consulting mutable rollout state again.

Useful? React with 👍 / 👎.

Comment on lines +32 to +36
job.get('recovery_state') == 'failed_held'
or RecoveryPolicy.from_dict(
(job.get('policy_parts') or {}).get('recovery', {})
).terminal_empty_disposition
and spent_canary(job)

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 Resolve legacy recovery policy before classifying canary rows

For a pre-E1 spent-canary job with recovery_state='held' and no policy_parts.recovery, this expression constructs the default policy, so terminal_empty_disposition is always false. The operator census calls SpeechRedriveStore.terminal from checked_job before prepare gets a chance to stamp the fallback stage policy, causing the historical canary row to be rejected as not_failed_held even when the recovery/disposition rollout is enabled; classify it with the candidate fallback policy (or stamp that part before the census) instead of treating an absent part as a recorded off decision.

Useful? React with 👍 / 👎.

Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…ion (lane 8 slice 2) (#22457)

* feat(batch): C8 provider-STT stage core (lane 8 slice 1, behaviour-neutral)

Adds the batch provider-STT stage for languages Parakeet cannot serve, so
batch never needs the legacy fallback for them:

- resolve_route(): admission-time stt_route/provider_reason/provider_service
  (contract (c) fields). Unknown language is 'multi' -> Parakeet, as legacy.
  BYOK never changes the STT route (sync prerecorded never used BYOK keys).
- enqueue_in_transaction(): writes a provider unit as provider_pending with
  merge_pending set, outside the GPU DRR ring, keeping the owner revision
  fence and late-capture watermark. Intended for an admit() enqueue hook.
- ProviderSttStore/ProviderSttStage: paid-once job-row intent
  (pending -> running CAS mints the token), one Modulate call with client
  retries disabled, deterministic per-token result object, settle to the
  same result_ready transition Scheduler.complete performs. Redelivery
  reconciles, never re-spends; vendor failure and abandoned intents settle
  failed_held (never 'held', so quarantine recovery cannot pay twice).

Nothing imports the new module yet: intake wiring, the queue consumer and
the router follow once the lane-1 stubs and the admit() hook land.
Expected C8 traces are pinned under pipeline_sim_goldens_pending/ with a
strict xfail until the sim configs exist.

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

* refactor(batch): route the intake language decision through provider_stt.resolve_route

Behaviour-neutral at legacy_sync 'on': unknown and 'multi' languages keep
today's legacy fallback explicitly, and a parametrized test pins the old and
new conditions equal for every language class with and without BYOK. This is
the seam the C8 provider route replaces in draining/dark.

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

* test(batch): keep the pending C8 golden check inside the fast-unit CPU budget

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

* feat(batch): admit() enqueue= and adopt= hooks (additive, keyword-only)

Contract (a) amendment (lead ruling 10-19): enqueue= lets the C8 provider
stage write its units and their outbox rows outside the GPU ring in the
admission transaction; adopt= lets intake take over a legacy ledger row it
re-validates inside that transaction (a row legacy can no longer finish).
With both unset, behaviour is unchanged. File owned by E1/Sol: needs Sol's
agreement before merge.

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

* feat(batch): C8 provider-STT consumer, route and draining/dark admission (lane 8 slice 2)

- ProviderSttConsumer (kind provider_stt, role workers, 1800s lease, no
  heartbeat) maps the stage onto contract (a) results; the route
  POST /v2/batch-pipeline/provider-stt/run answers 200 / 409 retry / 400
  malformed under Cloud Tasks OIDC, never 429/503.
- Intake, with legacy_sync draining or dark: a language Parakeet cannot serve
  is admitted to the provider stage (outbox row in the admission transaction,
  wake after commit); legacy-owned content is fenced per contract (h)
  invariant 4 through lane 10's fence_decision; a stranded legacy row is
  adopted once by the admit() adopt= CAS; a legacy final-pass recording is
  acknowledged, never re-admitted. At 'on' every route is today's.
- BYOK (David, 10-19): routed like every other upload. The batch 503
  sync_batch_byok_unavailable and the live-upload legacy owner choice for BYOK
  are removed; enrichment runs on Omi's keys.
- merge.py (lead sign-off, one line): provider results carry the
  recovery_version marker, so projection uses vendor labels as for recovered
  units.

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

* fix(batch): resolve the provider-STT outbox off the event loop

Failure-Class: none

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

* test(batch): keep lane-8 tests inside the fast-unit CPU budget

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

* feat(batch): record BYOK as the admission-time funding decision (provider_reason='byok')

The route stays language-only; provider_reason='byok' records that admission
funded the unit while the validated keys were present. The provider stage
never re-runs the keyless funding check for it. Writing the same value into
ProjectionBinding.policy (lane 6's GPU dispatch skip) waits for E1 (#22448):
neither ProjectionBinding.policy nor BatchUnitPolicy.provider_reason exists
on integration yet.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Two-lane lead (legacy-retire swarm): please add these fields to BatchUnitPolicy (and carry them on ProjectionBinding.policy) in this PR, per contract (c) lane-8 fields:

  • provider_reason (e.g. byok, unsupported_language, multi)
  • stt_route (gpu | provider)
  • provider_service (provider id when stt_route=provider)

Why: lane 8 (#22457, merged to integration/legacy-retire) admits BYOK uploads into batch, and lane 6's dispatch funding skip (#22425) keys on policy.provider_reason == 'byok'. Until the field exists, BYOK units can be re-held on every lease once batch-lane cap enforcement is enabled (it stays off until then). Lane 8 writes the values in its first slice after this merges.

Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…slice 3, stacked on #22457) (#22467)

* feat(batch): C8 provider-STT stage core (lane 8 slice 1, behaviour-neutral)

Adds the batch provider-STT stage for languages Parakeet cannot serve, so
batch never needs the legacy fallback for them:

- resolve_route(): admission-time stt_route/provider_reason/provider_service
  (contract (c) fields). Unknown language is 'multi' -> Parakeet, as legacy.
  BYOK never changes the STT route (sync prerecorded never used BYOK keys).
- enqueue_in_transaction(): writes a provider unit as provider_pending with
  merge_pending set, outside the GPU DRR ring, keeping the owner revision
  fence and late-capture watermark. Intended for an admit() enqueue hook.
- ProviderSttStore/ProviderSttStage: paid-once job-row intent
  (pending -> running CAS mints the token), one Modulate call with client
  retries disabled, deterministic per-token result object, settle to the
  same result_ready transition Scheduler.complete performs. Redelivery
  reconciles, never re-spends; vendor failure and abandoned intents settle
  failed_held (never 'held', so quarantine recovery cannot pay twice).

Nothing imports the new module yet: intake wiring, the queue consumer and
the router follow once the lane-1 stubs and the admit() hook land.
Expected C8 traces are pinned under pipeline_sim_goldens_pending/ with a
strict xfail until the sim configs exist.

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

* refactor(batch): route the intake language decision through provider_stt.resolve_route

Behaviour-neutral at legacy_sync 'on': unknown and 'multi' languages keep
today's legacy fallback explicitly, and a parametrized test pins the old and
new conditions equal for every language class with and without BYOK. This is
the seam the C8 provider route replaces in draining/dark.

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

* test(batch): keep the pending C8 golden check inside the fast-unit CPU budget

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

* feat(batch): admit() enqueue= and adopt= hooks (additive, keyword-only)

Contract (a) amendment (lead ruling 10-19): enqueue= lets the C8 provider
stage write its units and their outbox rows outside the GPU ring in the
admission transaction; adopt= lets intake take over a legacy ledger row it
re-validates inside that transaction (a row legacy can no longer finish).
With both unset, behaviour is unchanged. File owned by E1/Sol: needs Sol's
agreement before merge.

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

* feat(batch): C8 provider-STT consumer, route and draining/dark admission (lane 8 slice 2)

- ProviderSttConsumer (kind provider_stt, role workers, 1800s lease, no
  heartbeat) maps the stage onto contract (a) results; the route
  POST /v2/batch-pipeline/provider-stt/run answers 200 / 409 retry / 400
  malformed under Cloud Tasks OIDC, never 429/503.
- Intake, with legacy_sync draining or dark: a language Parakeet cannot serve
  is admitted to the provider stage (outbox row in the admission transaction,
  wake after commit); legacy-owned content is fenced per contract (h)
  invariant 4 through lane 10's fence_decision; a stranded legacy row is
  adopted once by the admit() adopt= CAS; a legacy final-pass recording is
  acknowledged, never re-admitted. At 'on' every route is today's.
- BYOK (David, 10-19): routed like every other upload. The batch 503
  sync_batch_byok_unavailable and the live-upload legacy owner choice for BYOK
  are removed; enrichment runs on Omi's keys.
- merge.py (lead sign-off, one line): provider results carry the
  recovery_version marker, so projection uses vendor labels as for recovered
  units.

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

* fix(batch): resolve the provider-STT outbox off the event loop

Failure-Class: none

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

* test(batch): keep lane-8 tests inside the fast-unit CPU budget

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

* feat(batch): record BYOK as the admission-time funding decision (provider_reason='byok')

The route stays language-only; provider_reason='byok' records that admission
funded the unit while the validated keys were present. The provider stage
never re-runs the keyless funding check for it. Writing the same value into
ProjectionBinding.policy (lane 6's GPU dispatch skip) waits for E1 (#22448):
neither ProjectionBinding.policy nor BatchUnitPolicy.provider_reason exists
on integration yet.

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

* feat(batch): cap-hold rehome adapter into batch admission (lane 8, C11 precondition)

cap_hold_admission.admit_held decodes a claimed, sealed, unspent hold into
one WAV and admits it through the same batch intake as uploads, under a
content id derived from the hold, so a retried sweep re-presents the same
content and the batch ledger guarantees one unit. Enabled only while legacy
sync is draining or dark (cap_hold_mode batch_hold). Holds legacy recovery
already spent on (piece receipts / processed paths) are refused and finish on
the legacy path. Imports nothing from utils.sync.pipeline (C11).

intake.accept_upload gains decode= for server-held audio; capture_decode
exposes its canonicalization as canonical_pcm.

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

* feat(sync): hand eligible cap holds to batch admission in recover_selected

The one hook in #22388's recovery path (driven by /v2/cap-hold-recovery/sweep):
under the existing row claim, an eligible hold in draining/dark is admitted to
batch, marked batch_admitted, and erased; batch projection owns the
conversation and usage, so the hold is never settled as legacy-transcribed.
At legacy_sync 'on' the legacy path is unchanged. File owned by the
Subscription session: needs its agreement before merge.

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

* feat(batch): Firestore outbox for provider_stt (contract (b), lane 8)

One row per provider unit keyed by its batch segment id, in a stage-scoped
collection (dev and prod share a Firestore project). Lease-token fencing on
every post-claim mutation, STALE/BUSY/DEFERRED/DISCARDED claim outcomes,
transactional enqueue in the caller's batch transaction with the wake after
commit, privacy discard at claim and sweep, and a sweep that re-wakes only
lost wakes (older than 600s, no live lease). Wakes are pst- named Cloud Tasks
built in utils/provider_stt_tasks.py, outside the env-ratcheted paths.

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

* feat(outbox): route OutboxKind.PROVIDER_STT to lane 8's Firestore outbox

The one-line selector branches in FirestoreOutbox and firestore_outbox (lead
ruling 10-19: lane 8 owns the provider_stt outbox, lane 9's seam). Lane 9's
selector tests now pin the still-reserved CAP_HOLD_REDRIVE as unserved.
Lane 9's file: flagged for lane 9.

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

* test(firestore): register the provider-STT outbox claim/sweep query drivers

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

* fix(sync): gate cap-hold batch hand-off like legacy dispatch; batch_admitted is terminal

Subscription-session review of #22467 (comment 6264627147):
- The batch branch now runs _new_dispatch_allowed (funded allowance, hard
  restriction, daily audio ceiling) before admit_held; a gated owner's audio
  stays held.
- A batch_admitted row is terminal: re-selecting it never claims, re-admits
  or settles (settlement would bill twice); it only finishes an interrupted
  erase. The adapter treats batch_admitted/completed/retained/purged as
  ineligible.
- Tests pin the summary decrement in checkpoint's own transaction on
  held -> batch_admitted (once, not per retried save) and the re-select no-op.
  The durable sweep's backlog page (held/staging/sealing) and discovery kinds
  already skip batch_admitted rows.

Failure-Class: none

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

---------

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: a743ec1bd5

ℹ️ 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 +419 to +422
summary_policy = (
FirstSummaryPolicy.from_dict(row['first_summary_policy']).first_summary_enabled
if row.get('first_summary_policy') is not None
else summary_enabled(row['uid'], include_admitted_context=False) or preserves_admitted(row)

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 Route snapshotted summaries through the priority pool

When an outbox row was stamped with first_summary_enabled=true and FIRST_SUMMARY_DEADLINE_ENABLED is later rolled back, this branch still treats the row as deadline-bound, but enrichment_response in backend/routers/batch_pipeline.py continues to choose sync_executor solely from the current flag. The accepted summary can therefore queue behind long transcription work and miss its recorded 60–120 second deadline after rollback; carry the recorded decision into executor selection or consistently use the post-processing pool for these batch summary rows.

AGENTS.md reference: backend/AGENTS.md:L274-L275

Useful? React with 👍 / 👎.

Comment on lines +71 to 72
if self.projector and self.projector.has_async_followups:
await self.projector.start_followups()

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 Schedule follow-ups independently of the current sweep page

With mixed recorded projection policies and more than one page of pending results, this gate reflects only the current Projector.discovery page, while ProjectionFollowups advances a separate cursor and filters its own page for async rows. If the follow-up page contains only synchronous or blocked rows, it launches nothing and cannot advance again until the main cursor eventually encounters another async row; sparse async receipts can consequently wait multiple full backlog scans, potentially hours, before client completion. Invoke the follow-up scheduler on every reconciliation once mixed policies are possible, rather than gating its independent cursor on the main page.

Useful? React with 👍 / 👎.

Comment on lines +35 to 37
if policy is None or not policy.projection_timing:
yield
return

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 Preserve read-phase timing under the recorded policy

When a unit's recorded projection policy enables timing, persist() still calls projection_phase('read') without supplying that policy, and project() performs its initial read outside the context manager entirely. Because this new condition disables timing whenever policy is absent, the enabled rollout silently loses all read-phase measurements and under-reports projection latency. Measure the read first and conditionally emit it after the persisted policy has been loaded.

Useful? React with 👍 / 👎.

Comment on lines +394 to +398
if row.get('summary_lane') == 'batch' and row.get('first_summary_policy') is None:
if candidate is None:
candidate = resolve_stage_policy(row['uid'], 'first_summary', obligation=row)
row['first_summary_policy'] = candidate.to_dict()
row['first_summary_policy_source'] = 'fallback'

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 Carry the first-summary policy through redirect custody

When an enabled batch summary is redirected to a canonical conversation, transfer_redirect copies its deadline and lane but not first_summary_policy. The target therefore reaches this fallback branch and is reclassified from the current environment (or retains a dormant target's unrelated policy); after a rollout rollback, an already admitted summary can become disabled and be completed without the promised first summary. Transfer the donor's immutable policy and source alongside its deadline, resolving conflicts according to the earliest obligation.

Useful? React with 👍 / 👎.

Comment on lines +419 to +423
summary_policy = (
FirstSummaryPolicy.from_dict(row['first_summary_policy']).first_summary_enabled
if row.get('first_summary_policy') is not None
else summary_enabled(row['uid'], include_admitted_context=False) or preserves_admitted(row)
)

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 Propagate the recorded summary decision into nested gates

When an admitted row records first_summary_enabled=true but the current first-summary master flag is rolled back, this branch sets only the local summary_policy; ADMITTED_OWNER below is still populated through preserves_admitted(row), which is false after that rollback. Nested processing such as llm_input_dedupe.notes() consequently sees summary_enabled(uid)==false and can reuse a cached server-minimum with no overview instead of generating the promised summary, after which the outer check treats the output as empty. Seed the nested feature context from the recorded policy and allow it to override the mutable master flag.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 4f43b2d into main Oct 19, 2026
58 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/flag-policy-e1 branch October 19, 2026 13:12
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…22450, #22497 sync)

E1 (batch policy snapshot) conflicted with legacy-retire in 7 files; per-owner resolutions:
- lane 8: database/batch_pipeline_intake.py, utils/batch_pipeline/intake.py, live_upload.py
  (E1 policy= + admit enqueue=/adopt= hooks), provider_stt.py (enqueue hook takes policy=).
- lane 9: utils/sync/reprocess.py stays the alias shim; E1's first-summary policy snapshot is
  ported into utils/enrichment/outbox.py (mark_update/run), outbox_firestore claim_key/consumer
  and projection.mark_enrichment; config/policy/guard.py RESOLUTION_EDGES moved to the outbox
  (lead sign-off, Sol FYI).
- lane 6: config/batch_live_preview.py takes E1; config/policy/batch.py reads the _ramp
  runtime percents in resolve_batch_policy when flags is None (lead sign-off; Sol no objection).
  test_runtime_percent.py covers ramp wins/recorded, env fallback, explicit flags never read
  _ramp, retire clamped after runtime batch, and source-blind policy_id.
- lane 1: routers/batch_pipeline.py drops the env read (E1) and keeps the 409 kill switch.

Verified (unit, m5): runtime_percent, batch_unit_policy (E1 guard), batch_stage_policy,
batch_pipeline_serving, quarantine_recovery, batch_provider_stt, outbox_firestore,
enrichment_route, task_target_retry_semantics, app_roles census: 359 passed, 3 xfailed.
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