Skip to content

fix: quarantine exhausted batch worker items - #21823

Merged
Git-on-my-level merged 2 commits into
mainfrom
batch-worker-quarantine
Oct 16, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
batch-worker-quarantine

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

A permanently failing GPU item keeps retrying and blocks all later results for its owner. Bound explicit failures at BATCH_PIPELINE_MAX_ATTEMPTS (default 5, valid 1–20). At the ceiling, atomically quarantine the item, revoke its lease, remove it from ordered pending work and retain the closed worker_failed reason. Never invent successful silence or a result URI. Content-free quarantine/recovery-held counters and events are best effort after the transaction; stale fail calls do not emit again.

Later successful captures keep normal predecessor and assignment fences. Ready successful siblings of a quarantined upload move out of the bounded projection sweep into quarantine_held, retaining their receipts/cursor. The durable upload status reports failure. Existing transcript words remain; a span without existing words remains a transcript gap. Audio, ownership, incomplete upload-wide usage and retention obligations stay held.

Scope explicitly permitted by the task: quarantine + skip only. No legacy recovery dispatch. Existing legacy claim/run entry points own the entire upload, and clearing that claim could duplicate already projected siblings. The runbook describes a per-unit recovery intent, token/privacy fence, existing prerecorded STT client reuse, stable assignment identity, late-capture handling and held-sibling resumption. Recovery is not implemented or claimed as tested. This PR tests retained legacy fencing and repeated-call safety instead. worker_failed is the closed scheduler reason; #21821 independently adds more specific content-safe model diagnostics.

Based directly on fresh origin/main at 8dc5b8b0a875; no dependency on or stack atop #21821. No production reads/writes, runtime flag changes, merge or deployment.

Product invariants affected

none

How it was verified

  • taskpolicy -b backend/.venv/bin/python -m pytest -q backend/tests/unit/test_batch_pipeline_scheduler.py backend/tests/unit/test_batch_pipeline_quarantine.py backend/tests/unit/test_batch_pipeline_intake.py backend/tests/unit/test_batch_pipeline_pump.py backend/tests/unit/test_batch_pipeline_metrics.py backend/tests/unit/test_batch_pipeline_projection.py backend/tests/unit/test_batch_pipeline_serving.py — 107 passed, entirely synthetic and hermetic.
  • taskpolicy -b backend/.venv/bin/python backend/scripts/scan_async_blockers.py --dirs backend/utils/batch_pipeline — no blocking findings.
  • taskpolicy -b python3 .github/scripts/check_deployment_secret_boundary.py --base origin/main — passed.
  • StrictFirestore tests execute actual transaction read-before-write, privacy, immutable binding, ledger ownership and predecessor guards. They do not model Firestore contention or live production acceptance.
  • Fully enabled serial publication hooks passed: backend typecheck 0 errors / 33,574 warnings, runtime source closure for 17 images, and the two changed test files (19 + 22 passed). A private Bash environment constrains the existing file runner to one worker even where the Firestore guard hard-codes two; no check or hook is skipped.
  • Full standalone preflight intentionally not run; the integration lead owns it. Publication uses the enabled repository hooks and targeted test selection.

Tests

Regression coverage: default/configured/invalid ceiling; terminal state without result; earlier unfinished success still blocks; later results commit past quarantine; immediate pump drain; later projection accepts the persisted predecessor; held sibling does not release ledger or report success; stale completion/heartbeat/redrive/poll/duplicate intake cannot revive the item; existing legacy run binding refuses twice; quarantine/recovery-held counters emit once; strict transaction ordering; privacy/replacement-ledger/binding revocation; throwing metrics/logger cannot undo quarantine; policy deferrals refund attempts.

UI evidence

UI-Evidence: none -- backend scheduler/projection change; documented transcript gap, no UI rendering change.

Failure class (fixes)

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

View guided diff Turn on auto-fix

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T09:09:27.212011Z f59d4b3 PR opened
ℹ️ 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: f59d4b3860

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

'result': result if completed else None,
'poll_after_ms': 0 if completed else 3000,
'failed_segments': failed,
'errors': ['batch_worker_quarantined'] if failed else [],

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 Expose the quarantine error through the response model

When a quarantined job is polled through GET /v2/sync-local-files/{job_id}, the route validates this dictionary against SyncJobStatusResponse, which has error but no errors field. FastAPI therefore strips the newly added errors: ["batch_worker_quarantined"] value from the actual HTTP response, so clients never receive the documented quarantine reason even though the direct helper test passes. Add the field to the response model or populate an existing declared field.

Useful? React with 👍 / 👎.

def max_worker_attempts() -> int:
"""Bound charged worker failures; malformed configuration keeps the safe default."""
try:
value = int(os.getenv('BATCH_PIPELINE_MAX_ATTEMPTS', '5'))

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 Wire the retry ceiling into deployed runtimes

The new ceiling reads BATCH_PIPELINE_MAX_ATTEMPTS, but that variable is absent from both the canonical backend/deploy/runtime_env.yaml contract and the explicit environment list in backend/charts/batch-pipeline-worker/templates/deployment.yaml. Consequently deployed serving hosts and, critically, the GPU worker that calls Scheduler.fail cannot receive the documented configurable value and always use 5; attempting to tune the ceiling through the deployment configuration has no effect. Add the setting to both runtime surfaces so they remain aligned.

AGENTS.md reference: backend/AGENTS.md:L153-L153

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit e99cb66 into main Oct 16, 2026
68 of 69 checks passed
@Git-on-my-level
Git-on-my-level deleted the batch-worker-quarantine branch October 16, 2026 09:23
aryanorastar added a commit that referenced this pull request Oct 16, 2026
…io (#21829)

## What changed and why

Bound a ring-buffer download that becomes silent after READ_BEGIN or
DATA. The
initial five-second timeout was cancelled on BEGIN, leaving only a
30-minute
overall deadline. A connected, stalled read therefore kept the transfer
owner
busy instead of yielding to normal capture/retry orchestration.

- Reset a 15-second idle deadline on the first valid BEGIN and nonempty
DATA,
matching the existing legacy SD idle bound. Repeated BEGIN, empty DATA
and
  control chatter are not progress.
- Observe arrival before queued custody/disk work. On timeout, stop
admitting
notifications, send STOP on the original connection epoch, drain already
received bytes and flush complete records through the existing durable
WAL
owner. Do not acknowledge an unfinished source or advance an unproven
frontier.
- Cancel idle timers on completion/error and put read-command failures
through
the same cleanup. A valid DONE arrival cancels the radio idle deadline
even
while its validation waits behind custody I/O. Healthy DONE and existing
  custody capability gates remain.
- Make the ring custody fixtures wait for read/status admission rather
than
  fixed startup sleeps, keeping the original durable-advance assertions.
- Preserve the saved cause, original stack and phase when a read-command
  failure goes through cleanup; keep catch-and-continue behavior.

Related: #21279 (uploaded jobs queued/429), #21387 (merged polling
backoff),
#21319 (merged short-WAL batching), #21755 (merged backfill
dispatcher-owner
repair), #21823 (merged batch-worker quarantine), and #21362
(retained-upload
recovery). These are separate stages.
This PR does not close the customer case or assert that the reported 1.4
KB/s,
capture interruption, cloud worker state or missing recaps share this
cause.
No firmware version or diagnostic export was supplied for the Discord
0/127
report, and no production repair, storage deletion or deployment is
performed.

Why isn't this a shared primitive instead? The existing ring reader
already
owns read admission, STOP, notification ordering, durable flush and
frontier
validation. Its watchdog belongs inside that owner, not in a parallel
recovery
actor. The injectable timer tests the real owner without waiting 15
seconds.

## Product invariants affected

- INV-CAP-1 — complete received records still use existing durable
file/index
  registration. Timeout leaves the source pending and sends no unproven
advance. Legacy firmware may reclaim on BLE delivery before app
durability;
this does not repair or conceal that existing risk or promise recovery
of
  incomplete records.

## Verification

- Production ring-owner regression: 14 tests passed, including idle
BEGIN,
partial audio, ignored chatter, cancelled deadlines, healthy DONE and
bytes
queued behind a deliberately blocked custody check, with and without
DONE.
- Capture interruption/reconnect journey (`mobile-verify fast --paths
app/lib/services/wals/ring_storage_sync.dart`): 3 checks passed, no
skips.
- Full app analyzer ratchet: passed. `make preflight`: 25 checks passed.
- Broader ring/custody/capture regression suites: all 129 passed on the
final
code, including the diagnostic guard and the 14 ring-owner tests above.
- Diagnostic guard: confirmed red without the transfer failure's saved
error,
then green with its original stack, cause and phase preserved.
Changed-file
  analyzer: no issues found.
- Physical BLE throughput, microphone behavior, customer-account
processing
and released-app retest: not performed; require hardware/account
evidence.

Architecture and implementation/release checklist:
`app/docs/offline-sync-stall-recovery.md`. The listen/pusher pipeline
map is
updated. This needs a mobile release after merge, not a backend
deployment.

## UI evidence

UI-Evidence: none -- transfer lifecycle only; no UI, copy or layout
changes

## Failure class

Failure-Class: FC-sync-failure-records-drop-cause
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