Repository navigation
test(backend): batch-lane scenarios in the emulator gauntlet - #22208
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a93505e0d
ℹ️ 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".
|
PR CI skipped the Sync Cloud Tasks Stack Gauntlet, because the |
Extend testing/sync_cloud_tasks_stack so the real batch pipeline runs end to end across separate processes on the Firestore emulator and a private Redis: admission (real accept_upload, staging, intake/job/ledger rows), a serving process (real main lifespan Serving loop, authorize, reconcile and recover-quarantine routes behind the production OIDC dependency), and a batch worker process (real run_process: signals, Pump/Scheduler/FirestoreStore, heartbeats, spend admission over loopback, PipelineWorker, artifact encryption) with configurable fake words, diarizer and VAD leaves and a counted fake paid STT leaf. Scenarios assert durable emulator state and HTTP codes: happy path, empty ASR -> quarantine -> one paid recovery (duplicate deliveries held), revision replacement via real SIGTERM/SIGKILL of the worker and of the serving process, a privacy fence mid-compute and after recovery prepare, and a small one-owner burst. The no-egress guard now covers every child process; the strict task recorder also validates recovery and enrichment tasks. `run.sh --only batch` runs just these (~70 s locally). Test harness only; no production behavior change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wledgement claims
Address Codex review on the batch-lane gauntlet (all harness-only):
- Assert the projected conversation is the capture named in the manifest
instead of recording the comparison as evidence only.
- Fail the one-owner burst when the worker starts segments out of
admission order or more than once; the scheduler's per-owner FIFO makes
that a real guarantee worth guarding.
- Fail the serving-sigterm scenario when the old revision does not
actually exit, so the replacement can never silently shadow it.
- Require the killed-revision redelivery to return HTTP 200 `held`,
the safe acknowledgement Cloud Tasks depends on.
- Bind the audience into the local OIDC token representation
(local-sync-oidc:{audience}:{identity}) so two routes sharing a
service account can no longer replay one token cross-audience; mint
sites and the verifier share one helper.
- Validate sync_reprocess payload key/token formats (64/32 hex, matching
the production handler's 400 path) and bind the task name to
sr-{key}-{token} plus the sanctioned -repair-{generation} suffix.
5a93505 to
faaf981
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: faaf9814e7
ℹ️ 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".
| location = os.getenv('SYNC_TASKS_LOCATION', '') | ||
| queue = os.getenv('SYNC_TASKS_QUEUE', '') | ||
| audience = os.getenv('BATCH_PIPELINE_RECOVERY_TASK_AUDIENCE', '').strip() | ||
| invoker_sa = os.getenv('SYNC_TASKS_INVOKER_SA', '').strip() | ||
| if not all((project, location, queue, audience, invoker_sa)): | ||
| raise RuntimeError('batch recovery task configuration is incomplete') | ||
| if parent != self.queue_path(project, location, queue): | ||
| raise RuntimeError('batch recovery task used an unexpected queue parent') |
There was a problem hiding this comment.
Validate the configured recovery queue
Production config sets BATCH_PIPELINE_RECOVERY_TASKS_QUEUE to the dedicated batch-quarantine-recovery queue, but the harness omits that setting and validates only SYNC_TASKS_QUEUE. Consequently, these scenarios exercise the fallback sync-jobs binding rather than the deployed route, so a producer regression that ignores or misroutes the dedicated recovery queue remains green; configure and validate the recovery-specific queue here.
Useful? React with 👍 / 👎.
| task_id = str(task.name).rsplit('/', 1)[-1] | ||
| if str(task.name) != self.task_path(project, location, queue, task_id) or not _RECOVERY_TASK_ID.fullmatch( | ||
| task_id | ||
| ): |
There was a problem hiding this comment.
Bind recovery task names to their payload
When the producer emits a syntactically valid task name containing the wrong stage or an unrelated 64-hex segment hash, this check still accepts it because _RECOVERY_TASK_ID validates only the shape. Production constructs the name from current_stage() and sha256(segment_id), so the gauntlet can pass while deterministic deduplication is no longer scoped to the recovery payload; extract and compare those name components with body['stage'] and segment_id.
Useful? React with 👍 / 👎.
| meter = stack.fair_use_meter_ms(upload.uid) | ||
| if meter <= 0: | ||
| raise StackFailure('batch projection did not meter fair-use speech') |
There was a problem hiding this comment.
Assert the initial fair-use amount
If the first projection double-charges or undercharges this single four-second upload, the scenario still passes because it checks only that the meter is positive and then remains unchanged. That does not establish the advertised exactly-once accounting behavior; compare the initial meter with the expected milliseconds from the upload's full-speech fake VAD result before testing subsequent reconciles.
Useful? React with 👍 / 👎.
| for _ in range(2): | ||
| stack.reconcile() |
There was a problem hiding this comment.
Require duplicate reconcile calls to succeed
When both explicit /reconcile requests return an error or cannot reach the serving process, their status values are ignored, and _drive_to_status immediately succeeds from the already-completed status without issuing another reconcile. The duplicate-projection assertions therefore pass without exercising a repeated sweep at all; require successful reconcile responses before checking that transcript and metering remain unchanged.
Useful? React with 👍 / 👎.
| if role == 'batch-serving': | ||
| return { | ||
| 'BATCH_PIPELINE_SERVING_ENABLED': 'true', | ||
| 'BATCH_PIPELINE_RECOVERY_MODE': 'on', | ||
| 'BATCH_PIPELINE_RECOVERY_ALL_ADMITTED': 'true', |
There was a problem hiding this comment.
Exercise the deployed async projection mode
The checked backend/deploy/runtime_env.yaml and production overlay enable BATCH_PIPELINE_ASYNC_PROJECTION_ENABLED, but this allowlisted serving environment omits it, so the flag defaults to false and every scenario uses the synchronous projection branch without start_followups(). Regressions in the currently deployed async follow-up path can therefore pass this new gauntlet; enable the production-on projection mode in the serving role.
Useful? React with 👍 / 👎.
| Java 21+ for the Firestore emulator. Run one scenario family with | ||
| `backend/testing/sync_cloud_tasks_stack/run.sh --only sync` or | ||
| `--only batch` (the default, `--only all`, runs both; CI runs both). The runner gives Firebase a fresh |
There was a problem hiding this comment.
Trigger the batch gauntlet for batch-pipeline changes
On pull requests that change only backend/utils/batch_pipeline/**, backend/database/batch_pipeline_*, or backend/diarizer/batch_pipeline*, the run_sync predicate in .github/workflows/backend-hermetic-e2e.yml does not match those paths, so the job containing this new batch suite is skipped despite this documentation saying CI runs it. Extend that predicate to the batch implementation paths so regressions are caught on the PR rather than only on a later merge-group or push run.
Useful? React with 👍 / 👎.
|
Monitor follow-up on this PR (both review rounds): Round 1 (threads from 10-18, resolved ✅): all six Codex findings were addressed in Round 2 (threads from 10-19 02:23Z): five of six are legitimate and were fixed + verified locally (dedicated |
Why
The emulator gauntlet in
testing/sync_cloud_tasks_stackproved the legacy Sync v2 path across real process boundaries. The batch lane, which carries the two-lane rollout, had no such coverage. Revision replacement, duplicate task delivery and the privacy fence were only exercised in production.What
run.sh(and the existingnpm run test:sync-cloud-tasks-stack:emulator) now also runs batch-lane scenarios across three separate processes on the Firestore emulator and a private Redis.--only {all,sync,batch}picks the family./v2/sync-capture-manifest,/v2/sync-local-files→accept_upload, decode, AES-GCM staging, intake/job/ledger rows, status routemainlifespanServingloop,authorize-compute,reconcile,recover-quarantinebehind the production OIDC dependency, projection,enqueue_named_task, lease recoverybatch_pipeline_runtime.run_process: signals, Pump/Scheduler/FirestoreStore, heartbeats, spend admission over loopback, merge,PipelineWorker, artifact encryptionEvery child process installs the shared no-egress guard (
isolation.py). The strict task recorder now also validates recovery andsync_reprocesstasks.Scenarios (assertions read emulator/Redis state and HTTP codes)
heldwith no further paid call.runninguntil the 900 s abandoned rule (see below).advance_privacy_generation):cancelled, zero paid calls.Behavior found (real code, not changed here)
status: failedwithpoll_after_ms: 0. Seeutils/batch_pipeline/intake.pydurable_status, where anyquarantinedjob meansfailed, whatever itsrecovery_state. A polling client stops before recovery completes.GET /v2/sync-local-files/{job_id}returns 500 after the privacy fence.BatchPrivacyBlockedfromtx.check_privacyescapesget_durable_job_statusand the route. The fenced job also staysleaseduntil its lease expires.recovery_state: running, and redelivery is correctlyheld. The 900 sabandoned_runningrule then settles it as a failure rather than retrying. This is the shape of the 2026-10-18 Modulate incident.run_syncpath filter doesn't matchbackend/utils/batch_pipeline/**orbackend/diarizer/**. A batch-only PR therefore doesn't run this gauntlet until push or merge group. Fixing that is a workflow change and isn't made here.Verification
Local, m5,
nice -n 19, onorigin/mainecd1f40:tests/unit/test_sync_cloud_tasks_stack_ci_wiring.py: 2 passed.Test harness only. No production behavior change, no workflow change.
🤖 Generated with Claude Code