Skip to content

fix(sync): end backfill sync-job requests before Cloud Run's request timeout - #21932

Merged
Git-on-my-level merged 26 commits into
mainfrom
fix/errfix-1016-gcp-the-request-has-been-terminated-beca
Oct 19, 2026
Merged

Git-on-my-level merged 26 commits into
mainfrom
fix/errfix-1016-gcp-the-request-has-been-terminated-beca

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Error group

{"source": "gcp", "service": "backend-sync-backfill", "group": "The request has been terminated because it has reached the maximum request timeout. To change this limit, see ", "count": 71, "id": "gcp:backend-sync-backfill-the-request-has-been-terminated-because-it-has-reached-the-maximum-request-timeout-to-ch", "fingerprint": "fp:057df70746f2c7c9"}

Root cause

backend-sync-backfill runs each Cloud Tasks sync job inside the /v2/sync-jobs/run request with no in-handler time bound. The only cap is TimeoutMiddleware's route timeout (HTTP_SYNC_JOBS_RUN_TIMEOUT, 1500s), implemented as asyncio.wait_for(call_next(...)) on Starlette 0.49's BaseHTTPMiddleware. When that fires, the middleware returns a 504 but never cancels the downstream pipeline coroutine: in BaseHTTPMiddleware.__call__ the pipeline task (coro, started via task_group.start_soon) is a child of the task group, and the group only exits once it finishes — so the ASGI request stays open while the pipeline keeps running to completion. Any job whose pipeline outlives the service's request timeout is then terminated by Cloud Run at the platform's maximum request timeout — exactly this error group — instead of ending as an orderly app-level retry. Coordinator cancellation itself is an already-designed path (inline lease loss cancels the owner task the same way, and the processed-segment ledger resumes on redelivery).

Fix

_run_sync_job_body is now a thin wrapper that runs one attempt (_run_sync_job_attempt) inside asyncio.timeout(SYNC_JOB_HANDLER_BUDGET_SECONDS) anchored at handler entry, so payload parsing, lock admission, staged-file downloads, and the pipeline share one deadline instead of the budget starting only after pre-pipeline I/O. On expiry the coordinator is cancelled exactly like a lost lease — an executor leaf that cancellation cannot stop may still be mutating state under the run-lock token, so the wrapper preserves the run lock, the job's Redis state, and staged audio. Because that lock outlives every queue-level Cloud Tasks retry (documented five-attempt contract, seconds-to-minutes backoff), answering 409 would spend all remaining attempts deferring against the held lock and exhaust the task before any delivery could reacquire it; the expired attempt therefore acks and schedules one delayed replacement named task for past the lock's TTL (enqueue_sync_job_budget_replacement; the -rb{schedule} name escapes the completing task's Cloud Tasks tombstone and dedupes concurrent expiries), so a replacement attempt can never overlap the detached leaf while never burning the queue's retry budget. The 409 remains only as the fallback when no replacement can be scheduled (dispatch disabled, unusable payload, or create-task failure) so the ack can never drop a job, and the sequenced-delivery wrapper passes the deferral through instead of converting it into a retry-burning nonterminal_ack 500 or finishing the epoch that still owns the job. The budget defaults to the configured HTTP_SYNC_JOBS_RUN_TIMEOUT minus a fixed 120s response margin (explicit SYNC_JOB_HANDLER_BUDGET_SECONDS overrides still win — the hermetic sync stack and replay harness set 20s beside their 30s route timeout), and a budget that is not strictly below the route cap fails at startup instead of letting the middleware 504 fire first.

This revision repairs the branch's red CI and closes the four open review findings on the deferral path:

  • CI (Backend unit shard 1/6): tests/unit/test_sync_transcription_prefs.py builds its own utils.cloud_tasks stub module, which lacked the new enqueue_sync_job_budget_replacement name, so every test in that file errored at routers.sync import. The stub now carries it.
  • Deferred jobs stayed exposed to stale finalization (P1): the preserved run lock (acquired near handler entry, not renewed in task mode) expires up to ~24 minutes before the replacement is due, and is_sync_job_stale treats a processing job as stale after 600s, so a status poll in that unlocked gap could acquire the lock and terminally fail a job whose continuation was already scheduled. The deferral now writes a deferred_until marker (replacement time plus STALE_THRESHOLD_SECONDS) through the atomic update_sync_job CAS before enqueueing, and is_sync_job_stale excludes a processing job until that instant; a lost replacement still self-heals once the marker lapses, and the marker is written first so an enqueue failure only delays stale detection to the same instant.
  • Unbounded replacement chain (P1): each replacement is a fresh named task whose queue retry count restarts at zero, so a job that never fits one budget chained replacements until its staged audio expired. The replacement payload now carries budget_deferrals (an optional key in the durable payload schema); once the original delivery plus replacements have spent get_sync_tasks_max_attempts() whole-budget attempts, no further replacement is scheduled: the attempt answers 409 with the lock still preserved for any live leaf, the queue finishes the task, and the existing stale self-heal finalizes the job through the owned finalizer once that lock expires (no deferred_until marker is written on this path, so it stays eligible).
  • Silent 409 fallback (P1): every switch from the replacement to queue-owned retries now goes through _budget_deferral_fallback, which calls record_fallback(component='sync_dispatch', from_mode='budget_replacement', to_mode='queue_retry', ...) with reason dispatch_disabled / malformed / enqueue_failed (degraded) or deferrals_exhausted (exhausted; new entry in ALLOWED_REASONS).
  • Enqueue time outside the route margin (P2): the replacement-enqueue bound was a fixed 120 / 2 = 60s, so an explicit budget override within 60s of the route cap could let the middleware 504 fire before the deferral response. _resolve_sync_job_replacement_enqueue_timeout now derives it from the margin the configured budget actually leaves ((route_timeout - budget) / 2, the other half being response headroom): 60s for the default 1380/1500, 5s for the local stacks' 20/30. The marker write and the enqueue share that one bound.

This revision closes the final two review threads, both about executor leaves that outlive the deadline cancellation of their await:

  • Clear raced the timed-out marker write (P2): the marker clear after a marker_timeout/enqueue_failed fallback could complete while the marker's CAS was still running in db_executor and then be overwritten by the late-applied marker, suppressing stale recovery until the marker horizon with no replacement scheduled. The marker write now runs as a retained, shielded task and the clear is ordered behind it within the shared post-attempt cleanup deadline; a write that never settles skips the clear (logged as handler_budget_deferral_marker_drain_failed) rather than race it.
  • Replacement delay anchored to an unconfirmed acquisition (P2): a budget expiry mid-acquire cancelled only the await while the executor thread could still land the 1,800s SET minutes later, so a schedule fixed at expiry + 1,860s could come due under that late lock and exhaust the replacement's short-backoff attempts on 409s. The acquire runs as a retained, shielded task stashed on the attempt state; the deferral drains it inside the shared post-budget deadline and anchors schedule_at to the drained completion (which upper-bounds when Redis started the TTL). An acquire that cannot be settled returns the queue-owned 409 with the new allowlisted acquire_unsettled reason instead of guessing.

Verification

$ python3 -m py_compile routers/sync.py database/sync_jobs.py utils/cloud_tasks.py \
    utils/observability/fallback.py tests/unit/test_sync_transcription_prefs.py \
    tests/unit/test_sync_cloud_tasks.py
py_compile OK

$ pytest tests/unit/test_sync_transcription_prefs.py -q
69 passed, 2 warnings in 7.30s

$ pytest tests/unit/test_sync_cloud_tasks.py -q
162 passed, 100 warnings in 12.12s

$ pytest tests/unit/test_sync_job_stale_self_heal.py -q
4 passed in 0.50s
$ pytest tests/unit/test_sync_dead_letters.py -q
43 passed, 10 warnings in 33.46s
$ pytest tests/unit/test_sync_ledger_fence_cutover.py -q
13 passed in 0.31s
$ pytest tests/unit/test_sync_cloud_tasks_stack_ci_wiring.py -q
2 passed in 0.35s
$ pytest tests/unit/test_sync_v2.py -q
182 passed, 61 warnings in 13.93s

test_sync_task_pipeline_budget_ends_attempt_before_platform_timeout drives the handler with a pipeline that never finishes and a 0.05s budget: it asserts a 200 deferral ack with one replacement scheduled past the run-lock TTL carrying budget_deferrals == 1, the deferred_until marker written for the replacement time plus the queued-dispatch stale threshold (and retired by the delivery's own queued->processing transition), no fallback recorded, no queued-reset, no terminal failure, no staged-blob delete, and no run-lock release. test_sync_task_budget_deferral_chain_ends_at_queue_attempt_contract delivers a replacement that has already spent the attempt contract and asserts a 409 with no further replacement, no marker, no lock release, and the deferrals_exhausted/exhausted fallback. test_deferred_processing_job_is_not_stale_until_its_replacement_is_due pins is_sync_job_stale against the real module: not stale while deferred_until is ahead, stale again from that instant, and unaffected by a non-numeric marker or the sequenced/queued-retry exclusions. test_sync_task_replacement_enqueue_timeout_fits_inside_route_margin pins the margin derivation (60s default, 5s for the local stacks) and that budget plus enqueue bound stays below the route cap. test_sync_task_budget_expiry_falls_back_to_409_when_replacement_not_schedulable and test_sync_task_budget_expiry_keeps_409_when_cloud_tasks_dispatch_disabled now also assert the recorded fallback reasons. test_sync_task_budget_counts_pre_pipeline_io_from_handler_entry, test_sequenced_budget_deferral_acks_without_finishing_sequencer_owner, and test_sync_task_handler_budget_derives_from_route_timeout are unchanged and still pass. test_sync_task_budget_expiry_during_lock_acquire_still_defers now lands the acquire past the expiry inside the post-budget drain and asserts the schedule is anchored to that confirmed acquisition; test_sync_task_budget_deferral_unsettleable_acquire_keeps_queue_retry asserts an acquire that never settles returns the 409 acquire_unsettled fallback with no marker and no replacement. test_sync_task_budget_deferral_timeout_during_marker_is_not_uncertain_enqueue now settles the marker just past the deadline and asserts the clear runs strictly after the drained write; test_sync_task_budget_deferral_marker_drain_failure_skips_clear asserts a write that never settles skips the clear entirely.

Product invariants affected

none

Line-Count-Exception: backend/routers/sync.py | 2952 -> 3784 | handler-budget wrapper and budget-expiry deferral: bounded replacements, required marker, shared post-budget deadline, route-entry budget anchor, bounded completion drain, confirmed terminal-expiry lock release, acquire-fenced capped-chain handoff, terminal-cleanup replacement without the impossible marker, owner-count write drained and rescued, terminal-cleanup deferral inheriting the recovery deadline and cap-exempt; no natural split from the frozen handler

Failure-Class: none

UI-Evidence: none -- this PR changes backend sync code and deploy config only; the UI-source delta in this push comes solely from merging origin/main

@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-19T10:34:22.529963Z a4bf8e5 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: 1690624431

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
@Git-on-my-level
Git-on-my-level force-pushed the fix/errfix-1016-gcp-the-request-has-been-terminated-beca branch from 1690624 to 108dcd3 Compare October 17, 2026 01:48
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Addressed all three review threads in 108dcd3.

P1 — preserve the run lock after cancelling executor work (r4299373131): Correct catch. wait_for expiry was surfacing as a generic retryable TimeoutError, which queued-reset the job and released the run lock while a detached executor leaf could still be mutating state under that token (the pipeline's own cancellation path preserves retry material for exactly that reason; the PR comment claimed lease-loss semantics the code didn't have). The whole attempt now runs inside asyncio.timeout(...) in _run_sync_job_body; expiry answers 409 {'status': 'locked'} with the run lock, job state, and staged audio preserved until the lease TTL — the exact lease-loss shape — so a redelivery can never overlap the detached leaf, and no final attempt can terminalize/delete underneath it.

P2 — start the deadline before pre-pipeline I/O (r4299373136): The budget now anchors at handler entry, so payload parsing, lock admission, and staged-file downloads share the same deadline the middleware measures; expiry during download ends the attempt with ownership preserved before the pipeline starts.

P2 — derive the budget from the configured route timeout (r4299373143): The default is now HTTP_SYNC_JOBS_RUN_TIMEOUT − 120s; an explicit SYNC_JOB_HANDLER_BUDGET_SECONDS override still wins (local stacks: 20s under 30s), and any budget not strictly below the route cap fails at startup instead of letting the middleware 504 fire first.

Verification: test_sync_cloud_tasks.py 133 passed; sync dead-letters/stale-self-heal/ledger-fence/cross-job/corrupt-blob suites 113 passed; stack-wiring + fence-transition 13 passed. New regression tests cover the pipeline-expiry 409-with-preserved-ownership contract, expiry during pre-pipeline download, and the budget derivation/startup validation.

@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: 108dcd3a43

ℹ️ 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 thread backend/routers/sync.py Resolved
Git-on-my-level added a commit that referenced this pull request Oct 17, 2026
Review follow-up (chatgpt-codex-connector):

- P1: a budget-expired attempt preserved the run lock for its full
  1800s TTL but still answered 409, so every queue-level Cloud Tasks
  retry (five-attempt contract, seconds-to-minutes backoff) arrived
  under the held lock, burned an attempt on another 409, and exhausted
  the task before any delivery could reacquire the lock — leaving
  non-sequenced jobs nonterminal with staged data and sequenced jobs
  waiting on a later sweep redrive. The expired attempt now acks and
  schedules one delayed replacement named task for past the lock's TTL
  (enqueue_sync_job_budget_replacement; the -rb{schedule} name escapes
  the completing task's Cloud Tasks tombstone and dedupes concurrent
  expiries). The 409 remains only when no replacement can be scheduled
  (dispatch disabled, payload unusable, create-task failure), so the
  deferred ack can never drop a job. The sequenced wrapper passes the
  deferral through instead of converting it into a retry-burning
  nonterminal_ack 500 or finishing the epoch that still owns the job.

@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: 31be425ac6

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member Author

errfix finisher: CI red on Backend unit shard 1/6. Failing log tail:

Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4193634Z tests/unit/test_voiceprint_authority.py::test_live_plan_changes_are_observed_on_rotation_once PASSED [ 19%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4207275Z tests/unit/test_voiceprint_authority.py::test_sync_empty_paid_cache_keeps_text_permission_without_rereading PASSED [ 22%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4224163Z tests/unit/test_voiceprint_authority.py::test_delayed_owner_job_cannot_consume_newer_optout[None] PASSED [ 25%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4238792Z tests/unit/test_voiceprint_authority.py::test_delayed_owner_job_cannot_consume_newer_optout[1] PASSED [ 27%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4248474Z tests/unit/test_voiceprint_authority.py::test_card_permission_is_bound_to_its_exact_decision PASSED [ 30%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4291448Z tests/unit/test_voiceprint_authority.py::test_owner_correction_rebuilds_profile_in_assignment_transaction[False-correction] PASSED [ 33%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4313089Z tests/unit/test_voiceprint_authority.py::test_owner_correction_rebuilds_profile_in_assignment_transaction[False-reject] PASSED [ 36%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4334133Z tests/unit/test_voiceprint_authority.py::test_owner_correction_rebuilds_profile_in_assignment_transaction[False-optout] PASSED [ 38%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4361287Z tests/unit/test_voiceprint_authority.py::test_owner_correction_rebuilds_profile_in_assignment_transaction[True-correction] PASSED [ 41%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4390676Z tests/unit/test_voiceprint_authority.py::test_owner_correction_rebuilds_profile_in_assignment_transaction[True-reject] PASSED [ 44%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4415773Z tests/unit/test_voiceprint_authority.py::test_owner_correction_rebuilds_profile_in_assignment_transaction[True-optout] PASSED [ 47%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4434615Z tests/unit/test_voiceprint_authority.py::test_duplicate_owner_delivery_has_one_contribution_and_correction_clears_cold_start PASSED [ 50%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4446583Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[unchanged] PASSED [ 52%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4457868Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[legacy] PASSED [ 55%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4469500Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[other_voice_edit] PASSED [ 58%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4479680Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[delete] PASSED [ 61%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4490218Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[tombstone] PASSED [ 63%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4501008Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[older_receipt] PASSED [ 66%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4511373Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[optout] PASSED [ 69%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4522310Z tests/unit/test_voiceprint_authority.py::test_person_publication_rechecks_source_in_transaction[identity] PASSED [ 72%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4536063Z tests/unit/test_voiceprint_authority.py::test_owner_clip_coordinator_borrows_sync_pool PASSED [ 75%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4546452Z tests/unit/test_voiceprint_authority.py::test_inflight_owner_publication_cannot_cross_a_correction PASSED [ 77%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4559097Z tests/unit/test_voiceprint_authority.py::test_live_entitlement_read_cannot_restore_old_conversation_permission PASSED [ 80%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4574265Z tests/unit/test_voiceprint_authority.py::test_live_entitlement_read_failure_stays_closed_and_is_retried PASSED [ 83%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4586816Z tests/unit/test_voiceprint_authority.py::test_carried_label_teaches_only_inside_its_capture_scope[scope-a-True] PASSED [ 86%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4598149Z tests/unit/test_voiceprint_authority.py::test_carried_label_teaches_only_inside_its_capture_scope[scope-b-False] PASSED [ 88%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4623355Z tests/unit/test_voiceprint_authority.py::test_owner_teaching_survives_a_later_tag_on_another_voice PASSED [ 91%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4650951Z tests/unit/test_voiceprint_authority.py::test_owner_teaching_stops_when_its_own_segment_is_revoked[decision0-False] ============================= test session starts ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4652774Z platform linux -- Python 3.11.15, pytest-8.4.1, pluggy-1.6.0 -- /home/runner/work/omi/omi/backend/.venv/bin/python
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4653964Z cachedir: .pytest_cache
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4654643Z rootdir: /home/runner/work/omi/omi/backend
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4655316Z configfile: pyproject.toml
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4656170Z plugins: anyio-4.4.0, asyncio-1.4.0, langsmith-0.8.5, pytest_httpserver-1.1.5, xdist-3.8.0
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4657463Z asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4658501Z collecting ... PASSED [ 94%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.4659573Z tests/unit/test_voiceprint_authority.py::test_owner_teaching_stops_when_its_own_segment_is_revoked[decision1-True] PASSED [ 97%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6812360Z tests/unit/test_voiceprint_authority.py::test_owner_teaching_stops_when_its_own_segment_is_revoked[decision2-False] PASSED [100%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6813813Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6814329Z =============================== warnings summary ===============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6815301Z utils/other/raw_audio.py:4
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6816795Z   /home/runner/work/omi/omi/backend/utils/other/raw_audio.py:4: DeprecationWarning: 'audioop' is deprecated and slated for removal in Python 3.13
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6818596Z     import audioop
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6819016Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6819618Z -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.6820697Z ======================== 36 passed, 1 warning in 1.63s =========================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9012604Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9109573Z ##[group]tests/unit/test_workstream_association.py
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9213848Z PASSED [ 92%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9244447Z tests/unit/test_vertex_reservation_state.py::test_every_operator_pin_suppresses_synthetic_discovery[gemini-2.5-flash] PASSED [ 93%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9291262Z tests/unit/test_vertex_reservation_state.py::test_every_operator_pin_suppresses_synthetic_discovery[gemini-3.8-flash] PASSED [ 94%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9317274Z tests/unit/test_vertex_reservation_state.py::test_every_operator_pin_suppresses_synthetic_discovery[gemini-2.5-flash-lite] PASSED [ 95%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9378002Z tests/unit/test_vertex_reservation_state.py::test_every_operator_pin_suppresses_synthetic_discovery[invalid] PASSED [ 95%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9433922Z tests/unit/test_vertex_reservation_state.py::test_probe_shutdown_cancels_owned_background_work PASSED [ 96%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9464242Z tests/unit/test_vertex_reservation_state.py::test_per_model_override_suppresses_only_its_discovery[{"gemini-2.5-flash":"inactive"}-gemini-3.8-flash] PASSED [ 97%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9488122Z tests/unit/test_vertex_reservation_state.py::test_per_model_override_suppresses_only_its_discovery[{"gemini-2.5-flash":"unknown"}-gemini-3.8-flash] PASSED [ 97%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9544395Z tests/unit/test_vertex_reservation_state.py::test_per_model_override_suppresses_only_its_discovery[{"gemini-2.5-flash":"auto","gemini-3.8-flash":"active"}-gemini-2.5-flash] PASSED [ 98%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:44.9564987Z tests/unit/test_vertex_reservation_state.py::test_per_model_override_suppresses_only_its_discovery[invalid-None] PASSED [ 99%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2622461Z tests/unit/test_vertex_reservation_state.py::test_pin_during_probe_prevents_stale_publication PASSED [100%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2624289Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2654090Z ============================= 142 passed in 4.02s ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2869963Z collected 7 items
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2883300Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2906900Z tests/unit/test_what_matters_now_smoke_fixture.py::test_fixture_identity_is_code_owned_and_requires_explicit_dev_runtime PASSED [ 14%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2934193Z tests/unit/test_what_matters_now_smoke_fixture.py::test_fixture_setup_create_only_writes_the_minimal_control_document PASSED [ 28%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2962509Z tests/unit/test_what_matters_now_smoke_fixture.py::test_fixture_setup_is_idempotent_when_expected_control_already_exists PASSED [ 42%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2994225Z tests/unit/test_what_matters_now_smoke_fixture.py::test_fixture_setup_treats_a_legacy_control_without_the_ui_flag_as_the_default_off_state PASSED [ 57%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.2996144Z tests/unit/test_what_matters_now_smoke_fixture.py::test_fixture_setup_preserves_differing_existing_control_and_fails_smoke PASSED [ 71%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.3021239Z tests/unit/test_what_matters_now_smoke_fixture.py::test_fixture_setup_treats_malformed_existing_control_as_differing_without_overwrite PASSED [ 85%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.4804701Z tests/unit/test_what_matters_now_smoke_fixture.py::test_fixture_setup_fails_closed_without_a_development_runtime PASSED [100%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.4863291Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.4893877Z ============================== 7 passed in 0.85s ===============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.5796164Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.5851448Z ##[group]tests/unit/test_wrapped_error_sanitization.py
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.6474311Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.6744412Z ##[group]tests/unit/test_ws_b_short_term_lifecycle.py
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.7584196Z ============================= test session starts ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.7604054Z platform linux -- Python 3.11.15, pytest-8.4.1, pluggy-1.6.0 -- /home/runner/work/omi/omi/backend/.venv/bin/python
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.7633791Z cachedir: .pytest_cache
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.7663624Z rootdir: /home/runner/work/omi/omi/backend
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.7673517Z configfile: pyproject.toml
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.7694096Z plugins: anyio-4.4.0, asyncio-1.4.0, langsmith-0.8.5, pytest_httpserver-1.1.5, xdist-3.8.0
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:45.7724187Z asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.4784384Z collecting ... ============================= test session starts ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.4844219Z platform linux -- Python 3.11.15, pytest-8.4.1, pluggy-1.6.0 -- /home/runner/work/omi/omi/backend/.venv/bin/python
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.4893733Z cachedir: .pytest_cache
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.4894368Z rootdir: /home/runner/work/omi/omi/backend
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.4933692Z configfile: pyproject.toml
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.4954087Z plugins: anyio-4.4.0, asyncio-1.4.0, langsmith-0.8.5, pytest_httpserver-1.1.5, xdist-3.8.0
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.4974350Z asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.5153760Z collecting ... ============================= test session starts ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.5173723Z platform linux -- Python 3.11.15, pytest-8.4.1, pluggy-1.6.0 -- /home/runner/work/omi/omi/backend/.venv/bin/python
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.5193621Z cachedir: .pytest_cache
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.5223650Z rootdir: /home/runner/work/omi/omi/backend
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.5233647Z configfile: pyproject.toml
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.5253785Z plugins: anyio-4.4.0, asyncio-1.4.0, langsmith-0.8.5, pytest_httpserver-1.1.5, xdist-3.8.0
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.5284241Z asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.8110008Z collecting ... collected 3 items
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.8143871Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:46.8184323Z tests/unit/test_wrapped_error_sanitization.py::WrappedErrorSanitizationTests::test_generate_wrapped_2025_sanitizes_errors PASSED [ 33%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.3194123Z tests/unit/test_wrapped_error_sanitization.py::WrappedErrorSanitizationTests::test_get_wrapped_status_allowlist_behavior collected 1 item
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.3236604Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.3934413Z tests/unit/test_wear_device_reminder.py::test_daily_wear_reminder_is_disabled PASSED [100%]PASSED [ 66%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.5645274Z tests/unit/test_wrapped_error_sanitization.py::WrappedErrorSanitizationTests::test_run_wrapped_generation_sanitizes_errors PASSED [100%]============= Backend fast unit duration guard warnings (CPU time) =============
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.5654779Z    0.56s > 0.10s  tests/unit/test_wrapped_error_sanitization.py::WrappedErrorSanitizationTests::test_get_wrapped_status_allowlist_behavior
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.5703794Z (CPU time, call phase only; warn limit = 0.10s, fail limit = 1.00s.)
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.5733846Z Allow intentional exceptions in tests/fast_unit_duration_allowlist.txt.
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.5763186Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.5793216Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.5823679Z ============================== 3 passed in 0.93s ===============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.7344564Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.7511806Z collected 20 items
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.7512349Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:47.7614449Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_submission_is_visible_pending_short_term_but_not_default_memory ::group::tests/unit/test_ws_m_atom_keyword_index.py
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0203008Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0223429Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0253801Z =============================== warnings summary ===============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0254611Z utils/other/raw_audio.py:4
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0284299Z   /home/runner/work/omi/omi/backend/utils/other/raw_audio.py:4: DeprecationWarning: 'audioop' is deprecated and slated for removal in Python 3.13
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0313777Z     import audioop
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0343318Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0344130Z -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.0373859Z ========================= 1 passed, 1 warning in 3.77s =========================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6044736Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6154576Z ##[group]tests/unit/test_x_oauth_callback_store_tokens_offload.py
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6234106Z ============================= test session starts ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6263971Z platform linux -- Python 3.11.15, pytest-8.4.1, pluggy-1.6.0 -- /home/runner/work/omi/omi/backend/.venv/bin/python
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6293614Z cachedir: .pytest_cache
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6294347Z rootdir: /home/runner/work/omi/omi/backend
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6323782Z configfile: pyproject.toml
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6353781Z plugins: anyio-4.4.0, asyncio-1.4.0, langsmith-0.8.5, pytest_httpserver-1.1.5, xdist-3.8.0
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:48.6355620Z asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4648492Z collecting ... ============================= test session starts ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4664346Z platform linux -- Python 3.11.15, pytest-8.4.1, pluggy-1.6.0 -- /home/runner/work/omi/omi/backend/.venv/bin/python
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4674586Z cachedir: .pytest_cache
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4703580Z rootdir: /home/runner/work/omi/omi/backend
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4733523Z configfile: pyproject.toml
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4744029Z plugins: anyio-4.4.0, asyncio-1.4.0, langsmith-0.8.5, pytest_httpserver-1.1.5, xdist-3.8.0
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4764334Z asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4793801Z collecting ... collected 17 items
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4823305Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4834246Z tests/unit/test_workstream_association.py::test_golden_association_fixtures_append_only_material_intent_match PASSED [  5%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4854278Z tests/unit/test_workstream_association.py::test_retrieval_hydrates_authority_and_purges_missing_or_closed_hits PASSED [ 11%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4883920Z tests/unit/test_workstream_association.py::test_retry_coalesces_same_evidence_into_one_event_key PASSED [ 17%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4914119Z tests/unit/test_workstream_association.py::test_material_event_uses_minimized_adjudicator_summary_not_memory_content PASSED [ 23%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4915705Z tests/unit/test_workstream_association.py::test_persisted_shadow_mode_cannot_suppress_canonical_association PASSED [ 29%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4944054Z tests/unit/test_workstream_association.py::test_verbatim_material_summary_fails_closed_without_append PASSED [ 35%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.4974061Z tests/unit/test_workstream_association.py::test_adjudication_reason_requires_consistent_selection_shape PASSED [ 41%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5004045Z tests/unit/test_workstream_association.py::test_universal_user_executes_retrieval_and_recurrence_mutation PASSED [ 47%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5005547Z tests/unit/test_workstream_association.py::test_recurrence_requires_multiple_days_and_is_idempotent_across_retries PASSED [ 52%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5007062Z tests/unit/test_workstream_association.py::test_persisted_shadow_mode_cannot_suppress_canonical_recurrence_candidate PASSED [ 58%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5008561Z tests/unit/test_workstream_association.py::test_durable_recurrence_inbox_retries_failures_and_continues PASSED [ 64%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5009950Z tests/unit/test_workstream_association.py::test_recurrence_identity_is_stable_across_independent_evolving_signals PASSED [ 70%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5011321Z tests/unit/test_workstream_association.py::test_recurrence_contract_rejects_impossible_temporal_counts PASSED [ 76%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5012719Z tests/unit/test_workstream_association.py::test_index_rebuild_resets_and_indexes_only_open_authoritative_workstreams PASSED [ 82%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5014464Z tests/unit/test_workstream_association.py::test_index_refresh_upserts_open_deletes_closed_for_every_authenticated_user PASSED [ 88%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.5030295Z tests/unit/test_workstream_association.py::test_derived_vector_index_returns_ids_only_and_uses_versioned_namespace PASSED [ 94%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.8404447Z tests/unit/test_workstream_association.py::test_memory_domain_does_not_import_workflow_writers PASSED [100%]PASSED [  5%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.8434134Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processing_preserves_integration_attribution PASSED [ 10%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.8494078Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processor_resolves_unknown_api_subject_and_infers_person_kind PASSED [ 15%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.8574043Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processor_normalizes_but_does_not_bypass_l2 PASSED [ 20%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.8634221Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processor_cannot_replace_known_manual_third_party_subject PASSED [ 25%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.8723538Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processing_failures_back_off_then_quarantine_and_new_revision_escapes PASSED [ 30%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.8805203Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processing_flex_deferral_releases_lease_without_spending_quality_attempt PASSED [ 35%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9494519Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processing_scan_skips_backoff_rows_without_exceeding_call_budget PASSED [ 40%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9524347Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processing_lease_blocks_overlapping_llm_invocation collected 48 items
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9543359Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9574273Z tests/unit/test_ws_m_atom_keyword_index.py::test_user_rejected_long_term_item_is_not_rebuild_or_vector_eligible PASSED [ 45%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9614164Z tests/unit/test_ws_b_short_term_lifecycle.py::test_required_processing_preserves_original_expiry_and_receipt_time PASSED [ 50%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9704417Z tests/unit/test_ws_b_short_term_lifecycle.py::test_inflight_processor_cannot_overwrite_newer_user_edit PASSED [ 55%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9760288Z tests/unit/test_ws_b_short_term_lifecycle.py::test_negative_user_review_is_authoritative_during_processing_race PASSED [ 60%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9874195Z tests/unit/test_ws_b_short_term_lifecycle.py::test_belief_enabled_user_review_preserves_authority_across_writer_modes[True-compatibility] PASSED [ 65%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9933492Z tests/unit/test_ws_b_short_term_lifecycle.py::test_belief_enabled_user_review_preserves_authority_across_writer_modes[True-ledger] PASSED [ 70%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9964339Z tests/unit/test_ws_b_short_term_lifecycle.py::test_belief_enabled_user_review_preserves_authority_across_writer_modes[False-compatibility] PASSED [  2%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:49.9974136Z tests/unit/test_ws_m_atom_keyword_index.py::TestIndexability::test_long_term_active_processed_is_indexable PASSED [  4%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0003874Z tests/unit/test_ws_m_atom_keyword_index.py::TestIndexability::test_short_term_excluded PASSED [  6%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0005039Z tests/unit/test_ws_m_atom_keyword_index.py::TestIndexability::test_archive_excluded PASSED [ 75%]PASSED [  8%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0033892Z tests/unit/test_ws_b_short_term_lifecycle.py::test_belief_enabled_user_review_preserves_authority_across_writer_modes[False-ledger] 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0063829Z tests/unit/test_ws_m_atom_keyword_index.py::TestIndexability::test_tombstoned_excluded PASSED [ 10%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0093889Z tests/unit/test_ws_m_atom_keyword_index.py::TestIndexability::test_restricted_sensitivity_excluded PASSED [ 12%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0095179Z tests/unit/test_ws_m_atom_keyword_index.py::TestIndexability::test_inactive_source_excluded PASSED [ 14%]PASSED [ 80%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0096278Z tests/unit/test_ws_m_atom_keyword_index.py::TestMergeMemorySearchIds::test_keyword_first_deduplicated 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0097905Z tests/unit/test_ws_b_short_term_lifecycle.py::test_identical_belief_review_is_idempotent_without_corroboration_inflation[compatibility] PASSED [ 16%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0099456Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_canonical_atoms_use_isolated_collection_by_default PASSED [ 85%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0154040Z tests/unit/test_ws_b_short_term_lifecycle.py::test_identical_belief_review_is_idempotent_without_corroboration_inflation[ledger] PASSED [ 90%]PASSED [ 18%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0173975Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_e2ee_user_skips_index_using_explicit_db_client 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0213966Z tests/unit/test_ws_b_short_term_lifecycle.py::test_expired_short_term_remains_visible_until_ttl_disposition_is_applied PASSED [ 95%]PASSED [ 20%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0234100Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_existing_wrong_typesense_schema_does_not_index 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0303338Z tests/unit/test_ws_b_short_term_lifecycle.py::test_expired_short_term_is_not_rejected_on_age_alone_when_belief_flag_on PASSED [100%]PASSED [ 22%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0333982Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_upsert_fails_closed_when_legacy_identity_cleanup_fails PASSED [ 25%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0424062Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_canonical_keyword_search_returns_exact_needle PASSED [ 27%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0484447Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_same_memory_id_isolated_by_uid_across_typesense_upsert_search_and_delete PASSED [ 29%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0544053Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_arbitrary_user_uses_the_same_keyword_index PASSED [ 31%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0603962Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_literal_needle_found_with_vector_disabled PASSED [ 33%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0694418Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_temporal_search_reaches_retained_history_without_leaking_it_into_useful_now PASSED [ 35%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0754357Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_ledger_search_hydrates_only_candidate_and_lineage_ids PASSED [ 37%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0784389Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_ledger_search_omits_candidate_with_missing_lineage_target PASSED [ 39%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0814461Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_ledger_search_preserves_closed_cycle_lineage_behavior PASSED [ 41%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0844464Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_ledger_search_omits_candidate_with_cross_owner_lineage_target PASSED [ 43%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0874527Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_ledger_search_omits_candidate_with_payload_id_mismatch_lineage_target PASSED [ 45%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0876937Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_ledger_search_omits_candidate_when_lineage_exceeds_bounded_hops PASSED [ 47%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0933919Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_search_excludes_superseded_long_term_items 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0934643Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0963730Z ============================== 17 passed in 3.77s ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.0993593Z PASSED [ 50%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1024302Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_search_includes_processed_visible_short_term_and_long_term PASSED [ 52%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1034261Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_search_applies_item_filter_before_result_limit PASSED [ 54%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1094253Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_search_prefers_long_term_canonical_survivor_and_keeps_unique_short_term PASSED [ 56%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1144128Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_temporal_empty_search_uses_bounded_scan_and_filters_negative_rows PASSED [ 58%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1194324Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_product_search_follows_lineage_pointers_without_full_scan PASSED [ 60%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1294056Z tests/unit/test_ws_m_atom_keyword_index.py::TestKeywordSearchAndHybrid::test_memory_service_search_hybrid_for_canonical PASSED [ 62%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1364131Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_sync_deletes_existing_keyword_doc_when_user_policy_is_revoked PASSED [ 64%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1383967Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_sync_does_not_acknowledge_revocation_when_exact_delete_fails PASSED [ 66%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1424291Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_delete_attempts_exact_remote_removal_even_after_index_eligibility_is_revoked PASSED [ 68%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1484430Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_delete_missing_keyword_doc_is_idempotent_success PASSED [ 70%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1503999Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_strict_keyword_purge_raises_on_typesense_failure PASSED [ 72%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1613902Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_account_delete_purges_keyword_index PASSED [ 75%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1864083Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_conversation_cascade_deletes_keyword_doc PASSED [ 77%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1924234Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_rebuild_reconstructs_index_count_verified PASSED [ 79%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.1954272Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_rebuild_never_sends_restricted_or_inactive_source_content PASSED [ 81%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2004445Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_rebuild_fails_closed_when_provider_purge_fails PASSED [ 83%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2074436Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_rebuild_purges_prior_docs_after_user_becomes_ineligible PASSED [ 85%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2144072Z tests/unit/test_ws_m_atom_keyword_index.py::TestPurgeAndRebuild::test_sync_removes_short_term_from_index PASSED [ 87%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2153907Z tests/unit/test_ws_m_atom_keyword_index.py::TestDocumentShape::test_build_document_uses_long_term_layer PASSED [ 89%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2174235Z tests/unit/test_ws_m_atom_keyword_index.py::TestDocumentShape::test_build_document_indexes_flat_subject_predicate_arguments PASSED [ 91%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2204208Z tests/unit/test_ws_m_atom_keyword_index.py::TestLedgerKeywordSchemaAdoption::test_pre_ledger_collection_adopts_the_missing_fields PASSED [ 93%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2234154Z tests/unit/test_ws_m_atom_keyword_index.py::TestLedgerKeywordSchemaAdoption::test_complete_schema_is_never_altered PASSED [ 95%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.2244137Z tests/unit/test_ws_m_atom_keyword_index.py::TestLedgerKeywordSchemaAdoption::test_failed_adoption_still_fails_closed PASSED [ 97%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.4902021Z tests/unit/test_ws_m_atom_keyword_index.py::TestLedgerKeywordSchemaAdoption::test_losing_the_adoption_race_is_success PASSED [100%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.4913335Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.4934148Z ============================== 48 passed in 1.62s ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.6803409Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.6833537Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.6844101Z ============================== 20 passed in 3.52s ==============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.7164420Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:50.7218953Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:51.0489525Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.1641801Z collected 1 item
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.1642410Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6748048Z tests/unit/test_x_oauth_callback_store_tokens_offload.py::test_oauth_callback_offloads_store_tokens PASSED [100%]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6748612Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6748790Z =============================== warnings summary ===============================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6749272Z .venv/lib/python3.11/site-packages/pydantic/_internal/_config.py:323
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6750627Z   /home/runner/work/omi/omi/backend/.venv/lib/python3.11/site-packages/pydantic/_internal/_config.py:323: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6751877Z     warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6752109Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6752317Z .venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6752788Z .venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6753408Z .venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6754072Z .venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6754529Z .venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6754977Z .venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6755436Z .venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6756816Z   /home/runner/work/omi/omi/backend/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:298: PydanticDeprecatedSince20: `json_encoders` is deprecated. See https://docs.pydantic.dev/2.11/concepts/serialization/#custom-serializers for alternatives. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6758093Z     warnings.warn(
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6758230Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6758511Z -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:53.6758946Z ======================== 1 passed, 8 warnings in 3.71s =========================
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2324284Z ##[endgroup]
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2431998Z Backend unit test file failed: tests/unit/test_sync_transcription_prefs.py (status 1)
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2449284Z 
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2449848Z Backend unit suite failed.
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2450583Z Reproduce only the failed file(s) with the same test.sh runner and timing guard:
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2451293Z   : > /tmp/omi-backend-unit-failures.txt
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2451845Z   echo tests/unit/test_sync_transcription_prefs.py >> /tmp/omi-backend-unit-failures.txt
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2452768Z   BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-backend-unit-failures.txt bash test.sh
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2453693Z Do not use bare pytest for fast-unit timing failures; it omits test.sh's guard settings.
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.2944143Z ##[error]Process completed with exit code 1.
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3053352Z Post job cleanup.
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3896768Z [command]/usr/bin/git version
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3929317Z git version 2.55.0
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3956916Z Temporarily overriding HOME='/home/runner/work/_temp/d9906926-69a7-41ca-89e0-48f4832307db' before making global git config changes
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3957672Z Adding repository directory to the temporary git global config as a safe directory
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3961660Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/omi/omi
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3988686Z Removing SSH command configuration
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.3994657Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4025330Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4223134Z Removing HTTP extra header
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4227887Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4256380Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4446687Z Removing includeIf entries pointing to credentials config files
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4451712Z [command]/usr/bin/git config --local --name-only --get-regexp ^includeIf\.gitdir:
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4474307Z includeif.gitdir:/home/runner/work/omi/omi/.git.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4475022Z includeif.gitdir:/home/runner/work/omi/omi/.git/worktrees/*.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4475639Z includeif.gitdir:/github/workspace/.git.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4476142Z includeif.gitdir:/github/workspace/.git/worktrees/*.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4481314Z [command]/usr/bin/git config --local --get-all includeif.gitdir:/home/runner/work/omi/omi/.git.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4499555Z /home/runner/work/_temp/git-credentials-09d702d4-2ad6-4d8e-8128-92df95c250a6.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4507490Z [command]/usr/bin/git config --local --unset includeif.gitdir:/home/runner/work/omi/omi/.git.path \/home\/runner\/work\/_temp\/git\-credentials\-09d702d4\-2ad6\-4d8e\-8128\-92df95c250a6\.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4543079Z [command]/usr/bin/git config --local --get-all includeif.gitdir:/home/runner/work/omi/omi/.git/worktrees/*.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4562147Z /home/runner/work/_temp/git-credentials-09d702d4-2ad6-4d8e-8128-92df95c250a6.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4569780Z [command]/usr/bin/git config --local --unset includeif.gitdir:/home/runner/work/omi/omi/.git/worktrees/*.path \/home\/runner\/work\/_temp\/git\-credentials\-09d702d4\-2ad6\-4d8e\-8128\-92df95c250a6\.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4598248Z [command]/usr/bin/git config --local --get-all includeif.gitdir:/github/workspace/.git.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4616813Z /github/runner_temp/git-credentials-09d702d4-2ad6-4d8e-8128-92df95c250a6.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4623315Z [command]/usr/bin/git config --local --unset includeif.gitdir:/github/workspace/.git.path \/github\/runner_temp\/git\-credentials\-09d702d4\-2ad6\-4d8e\-8128\-92df95c250a6\.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4652681Z [command]/usr/bin/git config --local --get-all includeif.gitdir:/github/workspace/.git/worktrees/*.path
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4671262Z /github/runner_temp/git-credentials-09d702d4-2ad6-4d8e-8128-92df95c250a6.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4677524Z [command]/usr/bin/git config --local --unset includeif.gitdir:/github/workspace/.git/worktrees/*.path \/github\/runner_temp\/git\-credentials\-09d702d4\-2ad6\-4d8e\-8128\-92df95c250a6\.config
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4725319Z [command]/usr/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.4914563Z Removing credentials config '/home/runner/work/_temp/git-credentials-09d702d4-2ad6-4d8e-8128-92df95c250a6.config'
Backend unit shard 1/6	UNKNOWN STEP	2026-10-17T03:12:54.5054678Z Cleaning up orphan processes

Git-on-my-level added a commit that referenced this pull request Oct 17, 2026
…alization, record the 409 fallback

Repairs PR #21932's red CI (the utils.cloud_tasks stub in
test_sync_transcription_prefs.py lacked enqueue_sync_job_budget_replacement)
and closes the open review findings on the handler-budget deferral path:

- is_sync_job_stale excludes a processing job until its deferred_until
  marker, written through the atomic update_sync_job CAS before the
  replacement is enqueued, so a status poll in the gap between the
  preserved run lock's expiry and the replacement's schedule cannot
  terminally fail a job whose continuation is already scheduled.
- The replacement payload carries budget_deferrals; once the original
  delivery plus replacements have spent the queue's attempt contract, no
  further replacement is scheduled and the queue ends the task with the
  lock preserved, leaving the stale self-heal to finalize the job.
- Every switch back to queue-owned retries records a fallback
  (sync_dispatch budget_replacement -> queue_retry) instead of only a log.
- The replacement-enqueue bound derives from the margin the configured
  budget leaves below the route cap instead of a fixed 60s.

@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: 469db9f650

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Autonomous repair exhausted (fixup lane launch failed); 2 fixup rounds, attempt 3/3. PR left OPEN for human triage.\n\nLast findings excerpt:\nBLOCKED: 2 unresolved non-outdated review thread(s) at head 469db9f:

  • backend/routers/sync.py:2132 [chatgpt-codex-connector] P1 Badge Require the deferred marker before acknowledging the task When the Re
  • backend/routers/sync.py:2170 [chatgpt-codex-connector] P1 Badge Persist the deferral count in the sequencer owner For a sequ

@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: ad9b798e6e

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Addressed the remaining budget-deferral review findings in ad9b798; all checks green and merge CLEAN on that head.

P1 — Require the deferred marker before acknowledging the task (#discussion_r4301337009): the deferred_until marker write is now a prerequisite for the 200 ack, not best-effort. A failed marker write aborts the deferral before the replacement enqueue and falls back to the queue-owned 409 with a new marker_failed fallback reason (added to ALLOWED_REASONS), so an ack can never leave the unlocked poll window (lock expiry → replacement due) unprotected against stale finalization. Pinned by test_sync_task_budget_deferral_requires_marker_before_ack.

P1 — Persist the deferral count in the sequencer owner (#discussion_r4301337017): sequenced deferrals now persist the chain count on the owner via sync_backfill_sequencer.note_budget_deferral (epoch-fenced, best-effort, bounded by the margin-derived enqueue timeout), and redrive_job re-attaches active_budget_deferrals to the outgoing payload — so a lease that expires before the delayed replacement begins can no longer restart budget_deferrals at zero and defer forever. The stored active_payload itself is untouched, and _release_owner's full-document replace keeps the field from leaking to the next job. Pinned by test_sequenced_budget_deferral_persists_chain_count_on_owner, test_budget_deferral_count_survives_lease_expiry_redrive, and test_note_budget_deferral_is_inert_for_released_or_mismatched_owner.

P1 — Prevent budget expiry from burning the task retry budget (#discussion_r4300804140): resolved as already addressed by the 469db9f replacement design (ack + one delayed replacement past the preserved lock's TTL, 409 only as fallback), which ad9b798 completes and hardens on both failure edges above.

Verification: test_sync_cloud_tasks.py 141 passed, test_sync_backfill_uid_sequencer.py 95 passed, test_live_health_reason_reconciliation.py 159 passed (touched ALLOWED_REASONS), scripts/backend-python-format --check clean, repo pre-push gate 33 checks passed; CI on ad9b798 green (all backend unit shards, guardrails, hermetic E2E, formatting, hygiene). PR body Line-Count-Exception updated for the new sync.py size (2849 → 3069).

@Git-on-my-level

Copy link
Copy Markdown
Member Author

errfix review BLOCKED this PR. Findings:

BLOCK:

Git-on-my-level added a commit that referenced this pull request Oct 17, 2026

@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: d8cbb0bdfc

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Git-on-my-level added a commit that referenced this pull request Oct 17, 2026
The five open review threads on the handler-budget deferral path were
fixed by d8cbb0b (marker sentinel, shared post-budget deadline,
owner-write fallback telemetry, queue max-attempts provisioning, and the
budget bound by the earliest attempt wall). This closes the remaining
follow-up on that batch: _resolve_sync_job_replacement_enqueue_timeout
now measures the post-budget margin below the same minimum of route
timeout, dispatch deadline, and run lock TTL that caps the budget, so a
route timeout configured above the 1500s dispatch deadline can no longer
let marker/enqueue/owner work cross the wall Cloud Tasks ends the
attempt at.

@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: ec0b28f337

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
Git-on-my-level added a commit that referenced this pull request Oct 17, 2026
Pre-lock budget expiry keeps queue-owned retry semantics instead of the
lock-sized replacement delay; the sequencer heartbeat join after an
attempt is bounded and falls back to cancellation; a failed replacement
enqueue clears the deferred marker so stale self-heal stays armed.

@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: cb6aaefe78

ℹ️ 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 thread backend/routers/sync.py Resolved
Git-on-my-level added a commit that referenced this pull request Oct 17, 2026
Three follow-up threads on the handler-budget deferral path:

- A budget expiry during the read-only setup before run-lock admission now
  keeps the queue-owned 409 retry (recorded as the pre_lock_expiry
  fallback): there is no preserved lock whose TTL the 1,860s replacement
  delay must outlive, so that delay would only stall the job and suppress
  stale recovery. The marker is set before the acquire is issued, so an
  expiry landing mid-acquire still takes the preserved-lock deferral.
- The sequencer heartbeat join between the attempt's response and its
  return is bounded (and the heartbeat cancelled past the bound): a renewal
  blocked inside its Firestore run_blocking can no longer hold the request
  open past the walls the budget exists to stay under.
- A failed replacement enqueue now clears the deferred_until marker before
  returning the 409 fallback: with no replacement scheduled, the marker's
  stale-suppression window outlasting the preserved lock was an unnecessary
  nonterminal stall.

@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: d00e61b637

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member Author

errfix review BLOCKED this PR. Findings:

BLOCK:

  • backend/database/sync_backfill_sequencer.py:575-601 () + :630-637 (): is written on deferral and attached by whenever positive, but nothing in this diff ever clears it — // are untouched and no test covers a written count being reset at job end or next-job activation ( only exercises inert writes). Any job that deferred at least once leaves the count behind after completion (the path also never clears it), so a later job on the same uid owner whose attempt dies uncleanly before its own deferral (instance kill — exactly this error class) is redriven with the predecessor's count and has its whole-budget chain prematurely cut (worst case one attempt → stale-finalized ), persisting per-uid until some later deferral overwrites. Reset the field in / or fence the attach to the epoch/job that wrote it.
  • backend/routers/sync.py:2417-2425 (, lock acquisition): is set twice with two near-duplicate comments — a merge artifact of the revision rounds; collapse to one.
  • backend/routers/sync.py (post-expiry budget arithmetic): the enqueue-failure path can spend the full margin — enqueue bound 60s () + fresh 30s marker-clear () + 30s heartbeat drain in = 120s = the entire , leaving zero slack under the route cap the budget exists to beat; the clear should share the post-budget deadline (like the owner write) rather than get a fresh timeout.

@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: b900060767

ℹ️ 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 thread backend/routers/sync.py Resolved
Comment thread backend/database/sync_jobs.py Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Autonomous repair exhausted (unresolved review threads (repair budget exhausted)); 1 fixup rounds, attempt 3/3. PR left OPEN for human triage.\n\nLast findings excerpt:\nmerge conflicts with current main

Git-on-my-level added a commit that referenced this pull request Oct 17, 2026
- Stop redriving sequenced jobs at the budget-deferral cap: the sweep
  releases the owner through a new deadline-fenced finish_expired_job and
  kicks the next pending capture instead of copying the maxed count into
  another full-budget attempt (one in-flight job per UID was stuck).
- Keep the deferred marker after an uncertain replacement enqueue
  (transport/deadline/timeout failures): the named task may exist, so the
  poll window stays guarded; recorded as enqueue_uncertain.
- Share one absolute cleanup deadline between the marker clear and the
  sequencer heartbeat drain, carried through the attempt state.
- Recover terminal jobs canceled during cleanup: re-read after a budget
  expiry, release the run lock, and return the established
  terminal_cleanup_retry 500 so the redelivery only retries cleanup.
@Git-on-my-level
Git-on-my-level force-pushed the fix/errfix-1016-gcp-the-request-has-been-terminated-beca branch from b900060 to d65fff7 Compare October 17, 2026 17:39
Git-on-my-level added a commit that referenced this pull request Oct 17, 2026
- Stop redriving sequenced jobs at the budget-deferral cap: the sweep
  releases the owner through a new deadline-fenced finish_expired_job and
  kicks the next pending capture instead of copying the maxed count into
  another full-budget attempt (one in-flight job per UID was stuck).
- Keep the deferred marker after an uncertain replacement enqueue
  (transport/deadline/timeout failures): the named task may exist, so the
  poll window stays guarded; recorded as enqueue_uncertain.
- Share one absolute cleanup deadline between the marker clear and the
  sequencer heartbeat drain, carried through the attempt state.
- Recover terminal jobs canceled during cleanup: re-read after a budget
  expiry, release the run lock, and return the established
  terminal_cleanup_retry 500 so the redelivery only retries cleanup.
@Git-on-my-level
Git-on-my-level force-pushed the fix/errfix-1016-gcp-the-request-has-been-terminated-beca branch from d65fff7 to da3762c Compare October 17, 2026 17:44

@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: da3762c84e

ℹ️ 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 thread backend/utils/sync/uid_sequencer.py Resolved
Comment thread backend/routers/sync.py Resolved
Comment thread backend/routers/sync.py Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor run summary (context 20261019T025042Z):

  • Pushed 9409af08e5 — fixes the last three unresolved review threads on the budget-deferral chain:
    • attempt-cap bypass at deferrals_exhausted for the terminal-cleanup deferral (its replacement only redelivers retry-only cleanup; a direct backfill job has no sequencer sweep to fail the job later),
    • owner-count write retained as a shielded task and drained past its await deadline, with a settled True rescuing the deferral and the rescued chain re-walled (deadline + one cleanup allowance) so the marker/enqueue no longer time out against the already-expired deadline,
    • terminal-cleanup deferral now inherits the recovery's absolute deadline instead of minting a fresh enqueue allowance.
  • Verified against current code and resolved all 10 open threads (OIDC-in-budget via the middleware request-start stamp, module-scope ledger_completion import, preamble_timeout in ALLOWED_REASONS, sync-jobs queue --max-attempts=5 reconciliation in the lifecycle action, finalizer lock released on lease-recheck exits, acquire-fenced capped-chain handoff, terminal cleanup replacement without the impossible marker, plus the three above).
  • backend/tests/unit/test_sync_cloud_tasks.py through the repo runner: 173 passed. PR-body line-count exception updated for the new head (2903 -> 3713). CI pending on the new head at posting time.

@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: 9409af08e5

ℹ️ 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 thread backend/routers/sync.py
Comment on lines +2844 to +2846
return await _defer_sync_job_after_handler_budget_expiry(
request, state, terminal_cleanup=True, deadline=recovery_deadline
)

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 Reserve time to enqueue the terminal cleanup replacement

When the strict lock-release call times out, it consumes recovery_deadline, and this call passes that already-expired deadline into the terminal-cleanup deferral. Its asyncio.timeout_at(post_budget_deadline) therefore expires before enqueue_sync_job_budget_replacement can run, returning 409; the queue's short retries can then exhaust against the surviving 30-minute lock, leaving a completed direct backfill job's one-in-flight UID slot held until its TTL. Fresh evidence after the terminal-cleanup change is that the replacement path now exists but inherits the same deadline that the preceding release just exhausted; reserve a bounded enqueue slice before waiting out the release.

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

Useful? React with 👍 / 👎.

Comment thread backend/routers/sync.py
Comment on lines +2546 to +2548
post_budget_deadline += SYNC_JOB_POST_ATTEMPT_CLEANUP_TIMEOUT_SECONDS
if attempt_state is not None:
attempt_state['post_budget_deadline'] = post_budget_deadline

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 Keep rescued owner writes within the shared response wall

When the owner-count write first times out but settles during its cleanup allowance, this extends post_budget_deadline from budget+60s to budget+90s; the sequenced wrapper then adds another cleanup allowance at line 2141, allowing the heartbeat drain to run until budget+120s. With the defaults, that is exactly the 1,500-second middleware and Cloud Tasks wall, leaving no response headroom and recreating the request termination this change is intended to prevent. Fresh evidence after the shared-deadline fix is this rescue-only deadline extension; use one fixed outer response deadline rather than extending the value that later drains extend again.

Useful? React with 👍 / 👎.

Comment thread backend/routers/sync.py
Comment on lines +2656 to +2657
await _clear_deferral_marker_after_failed_replacement(marker_write, job_id, post_budget_deadline)
return _budget_deferral_fallback('marker_failed', 'degraded')

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 Roll back the owner count when no replacement exists

When a sequenced delivery with budget_deferrals == 3 successfully persists active_budget_deferrals=4 but the subsequent marker write or a definitive enqueue fails, these fallback paths clear only the Redis marker and return 409; the owner still claims that the fifth attempt was scheduled even though it never existed. The short queue retries then exhaust against the preserved lock, and the sweep evaluates deferrals + 1 >= 5 and terminally fails the job after only four whole-budget runs. Fresh evidence after the earlier late-owner-write drain is that even a normally settled count write is not compensated when later creation definitively fails; restore the prior count with an epoch-fenced CAS on proven non-creation paths, while retaining it for uncertain enqueues.

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

Useful? React with 👍 / 👎.

@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: 3998b720df

ℹ️ 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 thread backend/routers/sync.py
Comment on lines +2571 to +2574
_consume_detached_outcome(owner_count_write)
logger.warning('event=sync_transcription_job outcome=handler_budget_owner_deferral_drain_failed')
if rescued is None:
return _budget_deferral_fallback('owner_write_failed', 'degraded')

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 Fence owner writes that outlive the drain

When the Firestore owner-count transaction remains blocked beyond this bounded drain, the code detaches it and returns 409 without creating a marker or replacement, but note_budget_deferral can still commit later because its transaction checks only the unchanged job/epoch. At budget_deferrals == 3, that late write records active_budget_deferrals=4; the short queue retries exhaust against the preserved lock, and the sequencer sweep then mistakes the unscheduled fifth attempt for an exhausted chain and fails the job after only four whole-budget runs, blocking the UID lane until cleanup. Fresh evidence after the earlier owner-write comment is that the new bounded-drain path explicitly leaves the transaction running while its claimed sweep fence is absent from the transaction predicate; cancel/fence the write or durably roll back a late commit before falling back.

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

Useful? React with 👍 / 👎.

Comment on lines +589 to +594
if (
outcome == 'lease_expired'
and isinstance(deferrals, int)
and not isinstance(deferrals, bool)
and deferrals + 1 >= get_sync_tasks_max_attempts()
):

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 Preserve queued retries at the deferral cap

When the final-generation task encounters a retryable pipeline error, the handler deliberately calls fenced_mark_job_queued_for_retry and returns 500, so a queued job with attempt/started_at still has a Cloud Tasks retry owed. If backfill congestion delays that retry past the 30-minute owner lease, this condition uses only active_budget_deferrals=4 and terminally fails the job as sync_budget_chain_exhausted. This is distinct from the already-handled delayed-replacement case: the final replacement has begun, cleared its marker, and requested an ordinary queue retry that has not exhausted; exclude that queued-retry state from capped finalization or redrive it while preserving the effective attempt count.

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

Useful? React with 👍 / 👎.

Comment thread backend/routers/sync.py
Comment on lines +2095 to +2098
async with asyncio.timeout_at(route_deadline):
marked = await run_blocking(
db_executor, update_sync_job, payload['job_id'], {'dispatch_mode': 'sequenced'}
)

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 Prevent timed-out migration writes from orphaning the job

When this Redis CAS applies but its executor call does not return before route_deadline, asyncio.timeout_at cancels only the await; the handler returns 409 before register_job, while the worker can later persist dispatch_mode='sequenced'. If the bounded queue retries exhaust during the same Redis/executor outage, no sequencer owner was ever registered, yet status polling permanently refuses stale recovery for every job marked sequenced, leaving the job nonterminal and its per-UID backfill slot occupied until TTL. Retain and drain/fence this mutation, or establish sequencer custody atomically before changing the dispatch mode.

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

Useful? React with 👍 / 👎.

Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
… 9, C2 slices 2-3; absorbs #21968) (#22444)

* refactor(enrichment): move the sr- outbox into utils/enrichment (C2 slice 1)

Plan C2, swarm lane 9. Pure move, no behaviour change:

- utils/sync/reprocess.py        -> utils/enrichment/outbox.py
- utils/sync/enrichment_custody.py -> utils/enrichment/custody.py
- utils/sync/enrichment_scan.py  -> utils/enrichment/scan.py

The old paths become sys.modules aliases of the new modules, so every
importer, mock.patch target and monkeypatch keeps reaching the same module
object. A star import gives pyright the public names. Batch projection
imports the new path; the frozen prod-track files (serving.py,
routers/batch_pipeline.py, batch_pipeline/enrichment.py) keep the shim until
their PRs reach integration.

Collection, document ids, field names and the sr- task prefix are unchanged
(contract (b) invariant 7). The query-shape driver and background-task
baseline follow the moved function.

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

* refactor(enrichment): drop the test-only custody and scan aliases

Only tests imported utils.sync.enrichment_custody and enrichment_scan, so the
dead-code ratchet counts the aliases as new dead files. The tests now import
utils.enrichment.scan directly; utils.sync.reprocess keeps its alias for the
production importers.

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

* test(enrichment): import the probe modules at collection time

The fast-unit CPU guard charged utils.cloud_tasks' first import to the probe
test's call phase (0.53s > 0.30s) once this file was selected. Module-level
imports keep the assertions unchanged and the call phase cheap.

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

* fix(enrichment): own the sr- callback and absorb lifecycle fences (C2 slice 3)

Plan C2, swarm lane 9. Batch enrichment no longer imports legacy
transcription (utils/sync/pipeline.py):

- utils/enrichment/callback.py: enrich_conversation, extracted verbatim from
  pipeline._reprocess_conversation_after_update with its webhook helper,
  persistence fence and lineage sentinel. pipeline.py is frozen behind
  #21932/#20662 and keeps its copy for the non-coalescing direct path, so
  test_enrichment_callback_parity.py (a static tripwire, labelled as such)
  keeps the two bodies identical until C11 deletes the legacy one. The new
  copy logs no conversation id.
- utils/enrichment/custody.py now owns discard_blocked. The batch adapter
  re-exports it for its existing importers.
- Absorbs #21968 (lead ruling 10-19): a SyncConversationPersistenceFenced
  from the callback settles the claim as superseded. The obligation is
  retired when no newer mark landed and re-armed when one did, and the
  handler ACKs 200 instead of answering 500 to a delivery that can never win.
  Other errors keep their taxonomy. #21968's conversation_id log line is not
  carried; the event is logged without identifiers.

Failure-Class: none

Verification (local unit, serial, nice 19):
- test_enrichment_callback_fence 4 passed (fenced+unchanged -> retired;
  fenced+newer mark -> re-armed; ValueError propagates; the default callback
  is the package)
- test_enrichment_callback_parity 3 passed
- test_batch_pipeline_serving 31 passed
- test_listen_finalization_cloud_tasks 278 passed
- test_sync_reprocess_coalesce 88 passed
- test_sync_enrichment_custody 10 passed
- test_background_task_ratchet, test_llm_gateway_coverage_guardrails and
  test_generated_compute_inventory_guardrails passed
- pyright 0 errors
- test_sync_reprocess_emulator now patches the package callback (CI emulator lane)

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

* feat(enrichment): Firestore Outbox for OutboxKind.ENRICHMENT (C2 slice 2)

Plan C2 / contract (b), swarm lane 9. database/outbox_firestore.py
implements the Outbox protocol over sync_reprocess_outbox, row-compatible
with mark/run: same collection, document ids, field names and sr- names.
Additive fields: policy_id, claim_attempts, a transient summary_seen_by.

- lease_token is the per-claim owner uuid and wake_token is task_token.
  heartbeat/ack/defer/release are fenced on both (invariant 1).
- claim_key: privacy discard first (invariant 6), then demand admission,
  a stale or busy check, and a not-due re-arm that wakes itself and returns
  DEFERRED. Wake ownership follows the lead's 10-19 ruling: this
  implementation creates the tasks through the existing _enqueue.
- ack keeps today's finish rules: retire when unchanged, a dormant receipt
  when record_summary marked the lease, re-arm when the version moved.
- enqueue shares mark's CAS operation (mark_update), with explicit
  available_at and min/max coalescing (invariant 3). With tx= it writes in
  the caller's transaction and returns the wake token; the caller calls
  wake() after commit (invariants 4-5). wake() is idempotent per token.
- sweep delegates to the existing sweep with a privacy discard hook. Pull
  claim() goes through the new utils.enrichment.outbox.due_rows
  (single-field due_at index), registered in the query-shape drivers.

Batch projection's mark_enrichment now calls enqueue(tx=...) and then
wake(), using its own client for both. A backfill binding is still resolved
only for a new row (new_dispatch callable), so a coalesced append never
raises on a missing backfill env, as before.

database.outbox.outbox_for is lane 1's stub; firestore_outbox(kind) is the
implementation it should return (wiring requested from the captain).

Verification (local unit, serial, nice 19):
- test_outbox_firestore 13 passed
- test_batch_pipeline_projection 40 passed
- test_sync_reprocess_coalesce 88 passed
- test_firestore_query_shapes 481 passed
- the outside-query, runtime-witness and index-oracle suites passed
- test_listen_finalization_cloud_tasks 278 passed
- pyright 0 errors
The emulator conformance suite is lane 12's and has not landed yet.

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

* feat(enrichment): outbox_for selects the Firestore enrichment outbox

Lane 1 signed off on this one-function edit of its stub (10-19): in this
window the selector always returns the Firestore implementation; the
BATCH_JOBSTORE_MODE switch is lane 12's.

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

* fix(enrichment): match moved retry classes so callback-pending stays 409

#22371 classifies expected enrichment retries by (defining module, class
name). #22431 moved FirstSummaryCallbackPending to utils.enrichment.outbox,
so on integration a callback-pending delivery fell through to the
unexpected branch and answered 500. That is the fast-5xx shape that
throttled the queues on 10-18 and 10-19. Match the new defining modules,
and keep the legacy pipeline fence until pipeline.py is deleted.

Failure-Class: none

Verification: test_batch_pipeline_serving 38 passed (it failed with
500 != 409 before this change on the merged integration tree).

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

* feat(enrichment): FirestoreOutbox factory with injected client, privacy check and wake

For lane 12's outbox conformance suite (build_outbox_backend('emulator')):
FirestoreOutbox(kind, client=, privacy_blocked=, create_wake=) binds every
CAS, the sweep and every wake to the injected seams. The default instance
keeps the production paths (discard_blocked, _enqueue, the shared client).
outbox._cas is the client-explicit CAS behind _mutate, and sweep takes
client=/wake= for the same purpose.

A not-due claim_key deferral leaves claim_attempts untouched (attempt stays
1 on the first real claim), as reprocess does today; there is a test for it.

Verification: test_outbox_firestore 16 passed, test_batch_pipeline_projection
40, test_sync_reprocess_coalesce 88, test_firestore_query_shapes 481,
test_sync_enrichment_custody 10; pyright 0 errors.

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: 6f7c09fc02

ℹ️ 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 +278 to +279
if not isinstance(job, dict):
return 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 Retain custody when the Redis job vanishes

If the job reaches its 24-hour Redis expiry after reconcile_uid reads it as nonterminal but before this second read, returning True lets finish_expired_job release the owner without running _cleanup_capped_chain_job_side_effects or the normal expired_job_cleanup redelivery. For a migrated backfill job that still owns the Redis per-UID slot, later historical uploads can then remain blocked until the slot's two-day TTL; retain the owner so the next sweep takes the missing-job redrive path, or clean up from the owner's persisted payload before reporting a completed handoff.

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

Useful? React with 👍 / 👎.

Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
… retries (lane 9, C3) (#22462)

* refactor(enrichment): move the sr- outbox into utils/enrichment (C2 slice 1)

Plan C2, swarm lane 9. Pure move, no behaviour change:

- utils/sync/reprocess.py        -> utils/enrichment/outbox.py
- utils/sync/enrichment_custody.py -> utils/enrichment/custody.py
- utils/sync/enrichment_scan.py  -> utils/enrichment/scan.py

The old paths become sys.modules aliases of the new modules, so every
importer, mock.patch target and monkeypatch keeps reaching the same module
object. A star import gives pyright the public names. Batch projection
imports the new path; the frozen prod-track files (serving.py,
routers/batch_pipeline.py, batch_pipeline/enrichment.py) keep the shim until
their PRs reach integration.

Collection, document ids, field names and the sr- task prefix are unchanged
(contract (b) invariant 7). The query-shape driver and background-task
baseline follow the moved function.

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

* refactor(enrichment): drop the test-only custody and scan aliases

Only tests imported utils.sync.enrichment_custody and enrichment_scan, so the
dead-code ratchet counts the aliases as new dead files. The tests now import
utils.enrichment.scan directly; utils.sync.reprocess keeps its alias for the
production importers.

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

* test(enrichment): import the probe modules at collection time

The fast-unit CPU guard charged utils.cloud_tasks' first import to the probe
test's call phase (0.53s > 0.30s) once this file was selected. Module-level
imports keep the assertions unchanged and the call phase cheap.

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

* fix(enrichment): own the sr- callback and absorb lifecycle fences (C2 slice 3)

Plan C2, swarm lane 9. Batch enrichment no longer imports legacy
transcription (utils/sync/pipeline.py):

- utils/enrichment/callback.py: enrich_conversation, extracted verbatim from
  pipeline._reprocess_conversation_after_update with its webhook helper,
  persistence fence and lineage sentinel. pipeline.py is frozen behind
  #21932/#20662 and keeps its copy for the non-coalescing direct path, so
  test_enrichment_callback_parity.py (a static tripwire, labelled as such)
  keeps the two bodies identical until C11 deletes the legacy one. The new
  copy logs no conversation id.
- utils/enrichment/custody.py now owns discard_blocked. The batch adapter
  re-exports it for its existing importers.
- Absorbs #21968 (lead ruling 10-19): a SyncConversationPersistenceFenced
  from the callback settles the claim as superseded. The obligation is
  retired when no newer mark landed and re-armed when one did, and the
  handler ACKs 200 instead of answering 500 to a delivery that can never win.
  Other errors keep their taxonomy. #21968's conversation_id log line is not
  carried; the event is logged without identifiers.

Failure-Class: none

Verification (local unit, serial, nice 19):
- test_enrichment_callback_fence 4 passed (fenced+unchanged -> retired;
  fenced+newer mark -> re-armed; ValueError propagates; the default callback
  is the package)
- test_enrichment_callback_parity 3 passed
- test_batch_pipeline_serving 31 passed
- test_listen_finalization_cloud_tasks 278 passed
- test_sync_reprocess_coalesce 88 passed
- test_sync_enrichment_custody 10 passed
- test_background_task_ratchet, test_llm_gateway_coverage_guardrails and
  test_generated_compute_inventory_guardrails passed
- pyright 0 errors
- test_sync_reprocess_emulator now patches the package callback (CI emulator lane)

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

* feat(enrichment): Firestore Outbox for OutboxKind.ENRICHMENT (C2 slice 2)

Plan C2 / contract (b), swarm lane 9. database/outbox_firestore.py
implements the Outbox protocol over sync_reprocess_outbox, row-compatible
with mark/run: same collection, document ids, field names and sr- names.
Additive fields: policy_id, claim_attempts, a transient summary_seen_by.

- lease_token is the per-claim owner uuid and wake_token is task_token.
  heartbeat/ack/defer/release are fenced on both (invariant 1).
- claim_key: privacy discard first (invariant 6), then demand admission,
  a stale or busy check, and a not-due re-arm that wakes itself and returns
  DEFERRED. Wake ownership follows the lead's 10-19 ruling: this
  implementation creates the tasks through the existing _enqueue.
- ack keeps today's finish rules: retire when unchanged, a dormant receipt
  when record_summary marked the lease, re-arm when the version moved.
- enqueue shares mark's CAS operation (mark_update), with explicit
  available_at and min/max coalescing (invariant 3). With tx= it writes in
  the caller's transaction and returns the wake token; the caller calls
  wake() after commit (invariants 4-5). wake() is idempotent per token.
- sweep delegates to the existing sweep with a privacy discard hook. Pull
  claim() goes through the new utils.enrichment.outbox.due_rows
  (single-field due_at index), registered in the query-shape drivers.

Batch projection's mark_enrichment now calls enqueue(tx=...) and then
wake(), using its own client for both. A backfill binding is still resolved
only for a new row (new_dispatch callable), so a coalesced append never
raises on a missing backfill env, as before.

database.outbox.outbox_for is lane 1's stub; firestore_outbox(kind) is the
implementation it should return (wiring requested from the captain).

Verification (local unit, serial, nice 19):
- test_outbox_firestore 13 passed
- test_batch_pipeline_projection 40 passed
- test_sync_reprocess_coalesce 88 passed
- test_firestore_query_shapes 481 passed
- the outside-query, runtime-witness and index-oracle suites passed
- test_listen_finalization_cloud_tasks 278 passed
- pyright 0 errors
The emulator conformance suite is lane 12's and has not landed yet.

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

* feat(enrichment): outbox_for selects the Firestore enrichment outbox

Lane 1 signed off on this one-function edit of its stub (10-19): in this
window the selector always returns the Firestore implementation; the
BATCH_JOBSTORE_MODE switch is lane 12's.

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

* feat(enrichment): /v2/enrichment/run on the outbox consumer, 409-only retries (C3)

Plan C3 / contracts (a) and (d), swarm lane 9.

- utils/enrichment/consumer.py: EnrichmentConsumer, a QueueConsumer for
  OutboxKind.ENRICHMENT (workers role; 120s lease, 30s heartbeat on every
  lease). It mirrors reprocess.run outcome for outcome, with settlement
  through the Outbox calls:
  - processed -> DONE (ack; a dormant receipt via record_summary);
  - superseded or lifecycle fence -> DISCARDED;
  - repair race -> outbox.repair;
  - live target or missing conversation -> DEFERRED +120s;
  - redirect -> custody transfer;
  - empty budget spent -> retired;
  - callback pending or empty output -> RETRY callback_pending (409; release
    keeps the wake for the queue retry).
- routers/enrichment.py: POST /v2/enrichment/run with OIDC for the
  enrichment queue (TaskEdge enrichment). It accepts the legacy
  {"kind":"sync_reprocess",...} payload, so rows bound to either handler
  drain. 400 for a malformed task; 500 only for unexpected exceptions.
- config/enrichment.py: ENRICHMENT_ROUTE (sync_handler | enrichment_queue,
  default sync_handler) is the deployment default for the policy field
  enrichment_route until E1 records it per unit. ENRICHMENT_TASKS_* is the
  queue binding. An incomplete binding falls back to the sync handler and
  is counted through record_fallback.
- valid_dispatch_binding and _enqueue accept both handler paths (contract
  (b) invariant 7).

The router mount in main.py is lane 1's. Queue spec for lane 7: enrichment,
max-concurrent 50, 25/s, backoff 10-300s, unlimited attempts.

Verification (local unit, serial, nice 19):
- test_enrichment_route 12 passed (409 callback_pending keeps the wake;
  fence -> superseded; live defer -> new wake; 400s; stale wake -> 200;
  unexpected -> 5xx with the lease kept; route binding with fallback)
- test_outbox_firestore 14 passed
- test_sync_reprocess_coalesce 88 passed
- test_cross_service_deploy_contract and test_background_task_ratchet passed
- pyright 0 errors

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

* fix(enrichment): match moved retry classes so callback-pending stays 409

#22371 classifies expected enrichment retries by (defining module, class
name). #22431 moved FirstSummaryCallbackPending to utils.enrichment.outbox,
so on integration a callback-pending delivery fell through to the
unexpected branch and answered 500. That is the fast-5xx shape that
throttled the queues on 10-18 and 10-19. Match the new defining modules,
and keep the legacy pipeline fence until pipeline.py is deleted.

Failure-Class: none

Verification: test_batch_pipeline_serving 38 passed (it failed with
500 != 409 before this change on the merged integration tree).

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

* feat(enrichment): FirestoreOutbox factory with injected client, privacy check and wake

For lane 12's outbox conformance suite (build_outbox_backend('emulator')):
FirestoreOutbox(kind, client=, privacy_blocked=, create_wake=) binds every
CAS, the sweep and every wake to the injected seams. The default instance
keeps the production paths (discard_blocked, _enqueue, the shared client).
outbox._cas is the client-explicit CAS behind _mutate, and sweep takes
client=/wake= for the same purpose.

A not-due claim_key deferral leaves claim_attempts untouched (attempt stays
1 on the first real claim), as reprocess does today; there is a test for it.

Verification: test_outbox_firestore 16 passed, test_batch_pipeline_projection
40, test_sync_reprocess_coalesce 88, test_firestore_query_shapes 481,
test_sync_enrichment_custody 10; pyright 0 errors.

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

* test(enrichment): a not-due wake re-arms and answers 200 not_due

Exercises #22437's claim_key DEFERRED mapping end to end through
/v2/enrichment/run: the outbox re-arms with a new wake and the delivery is
consumed, not retried.

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

* test(enrichment): load the callback at collection time in the route tests

The fast-unit CPU guard charged process_conversation's first import to the
first route test (6.8s > 0.30s).

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

ℹ️ 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 +304 to +308
if gcloud tasks queues describe sync-jobs --location=${{ inputs.region }} --project=${{ inputs.project_id }} >/dev/null 2>&1; then
gcloud tasks queues update sync-jobs \
--location=${{ inputs.region }} \
--project=${{ inputs.project_id }} \
--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.

P1 Badge Reconcile the configured fresh sync queue

Fresh evidence beyond the earlier main-queue finding is that production config routes backend-sync through SYNC_TASKS_QUEUE=sync-jobs-fresh (backend/deploy/runtime_env/prod.overlay.yaml), while this step updates only the retired/hard-coded sync-jobs queue. Consequently the queue receiving fresh jobs retains its prior/default attempt limit, so a final budget-chain 409 can be redelivered after the run lock expires and start another whole-budget run despite the code assuming five attempts. Resolve and update the configured SYNC_TASKS_QUEUE; the gcloud contract applies --max-attempts only to the positional queue being updated.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 8d7778a into main Oct 19, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/errfix-1016-gcp-the-request-has-been-terminated-beca branch October 19, 2026 10:50
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…legates to the consumer (lane 9) (#22476)

* refactor(enrichment): move the sr- outbox into utils/enrichment (C2 slice 1)

Plan C2, swarm lane 9. Pure move, no behaviour change:

- utils/sync/reprocess.py        -> utils/enrichment/outbox.py
- utils/sync/enrichment_custody.py -> utils/enrichment/custody.py
- utils/sync/enrichment_scan.py  -> utils/enrichment/scan.py

The old paths become sys.modules aliases of the new modules, so every
importer, mock.patch target and monkeypatch keeps reaching the same module
object. A star import gives pyright the public names. Batch projection
imports the new path; the frozen prod-track files (serving.py,
routers/batch_pipeline.py, batch_pipeline/enrichment.py) keep the shim until
their PRs reach integration.

Collection, document ids, field names and the sr- task prefix are unchanged
(contract (b) invariant 7). The query-shape driver and background-task
baseline follow the moved function.

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

* refactor(enrichment): drop the test-only custody and scan aliases

Only tests imported utils.sync.enrichment_custody and enrichment_scan, so the
dead-code ratchet counts the aliases as new dead files. The tests now import
utils.enrichment.scan directly; utils.sync.reprocess keeps its alias for the
production importers.

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

* test(enrichment): import the probe modules at collection time

The fast-unit CPU guard charged utils.cloud_tasks' first import to the probe
test's call phase (0.53s > 0.30s) once this file was selected. Module-level
imports keep the assertions unchanged and the call phase cheap.

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

* fix(enrichment): own the sr- callback and absorb lifecycle fences (C2 slice 3)

Plan C2, swarm lane 9. Batch enrichment no longer imports legacy
transcription (utils/sync/pipeline.py):

- utils/enrichment/callback.py: enrich_conversation, extracted verbatim from
  pipeline._reprocess_conversation_after_update with its webhook helper,
  persistence fence and lineage sentinel. pipeline.py is frozen behind
  #21932/#20662 and keeps its copy for the non-coalescing direct path, so
  test_enrichment_callback_parity.py (a static tripwire, labelled as such)
  keeps the two bodies identical until C11 deletes the legacy one. The new
  copy logs no conversation id.
- utils/enrichment/custody.py now owns discard_blocked. The batch adapter
  re-exports it for its existing importers.
- Absorbs #21968 (lead ruling 10-19): a SyncConversationPersistenceFenced
  from the callback settles the claim as superseded. The obligation is
  retired when no newer mark landed and re-armed when one did, and the
  handler ACKs 200 instead of answering 500 to a delivery that can never win.
  Other errors keep their taxonomy. #21968's conversation_id log line is not
  carried; the event is logged without identifiers.

Failure-Class: none

Verification (local unit, serial, nice 19):
- test_enrichment_callback_fence 4 passed (fenced+unchanged -> retired;
  fenced+newer mark -> re-armed; ValueError propagates; the default callback
  is the package)
- test_enrichment_callback_parity 3 passed
- test_batch_pipeline_serving 31 passed
- test_listen_finalization_cloud_tasks 278 passed
- test_sync_reprocess_coalesce 88 passed
- test_sync_enrichment_custody 10 passed
- test_background_task_ratchet, test_llm_gateway_coverage_guardrails and
  test_generated_compute_inventory_guardrails passed
- pyright 0 errors
- test_sync_reprocess_emulator now patches the package callback (CI emulator lane)

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

* feat(enrichment): Firestore Outbox for OutboxKind.ENRICHMENT (C2 slice 2)

Plan C2 / contract (b), swarm lane 9. database/outbox_firestore.py
implements the Outbox protocol over sync_reprocess_outbox, row-compatible
with mark/run: same collection, document ids, field names and sr- names.
Additive fields: policy_id, claim_attempts, a transient summary_seen_by.

- lease_token is the per-claim owner uuid and wake_token is task_token.
  heartbeat/ack/defer/release are fenced on both (invariant 1).
- claim_key: privacy discard first (invariant 6), then demand admission,
  a stale or busy check, and a not-due re-arm that wakes itself and returns
  DEFERRED. Wake ownership follows the lead's 10-19 ruling: this
  implementation creates the tasks through the existing _enqueue.
- ack keeps today's finish rules: retire when unchanged, a dormant receipt
  when record_summary marked the lease, re-arm when the version moved.
- enqueue shares mark's CAS operation (mark_update), with explicit
  available_at and min/max coalescing (invariant 3). With tx= it writes in
  the caller's transaction and returns the wake token; the caller calls
  wake() after commit (invariants 4-5). wake() is idempotent per token.
- sweep delegates to the existing sweep with a privacy discard hook. Pull
  claim() goes through the new utils.enrichment.outbox.due_rows
  (single-field due_at index), registered in the query-shape drivers.

Batch projection's mark_enrichment now calls enqueue(tx=...) and then
wake(), using its own client for both. A backfill binding is still resolved
only for a new row (new_dispatch callable), so a coalesced append never
raises on a missing backfill env, as before.

database.outbox.outbox_for is lane 1's stub; firestore_outbox(kind) is the
implementation it should return (wiring requested from the captain).

Verification (local unit, serial, nice 19):
- test_outbox_firestore 13 passed
- test_batch_pipeline_projection 40 passed
- test_sync_reprocess_coalesce 88 passed
- test_firestore_query_shapes 481 passed
- the outside-query, runtime-witness and index-oracle suites passed
- test_listen_finalization_cloud_tasks 278 passed
- pyright 0 errors
The emulator conformance suite is lane 12's and has not landed yet.

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

* feat(enrichment): outbox_for selects the Firestore enrichment outbox

Lane 1 signed off on this one-function edit of its stub (10-19): in this
window the selector always returns the Firestore implementation; the
BATCH_JOBSTORE_MODE switch is lane 12's.

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

* feat(enrichment): /v2/enrichment/run on the outbox consumer, 409-only retries (C3)

Plan C3 / contracts (a) and (d), swarm lane 9.

- utils/enrichment/consumer.py: EnrichmentConsumer, a QueueConsumer for
  OutboxKind.ENRICHMENT (workers role; 120s lease, 30s heartbeat on every
  lease). It mirrors reprocess.run outcome for outcome, with settlement
  through the Outbox calls:
  - processed -> DONE (ack; a dormant receipt via record_summary);
  - superseded or lifecycle fence -> DISCARDED;
  - repair race -> outbox.repair;
  - live target or missing conversation -> DEFERRED +120s;
  - redirect -> custody transfer;
  - empty budget spent -> retired;
  - callback pending or empty output -> RETRY callback_pending (409; release
    keeps the wake for the queue retry).
- routers/enrichment.py: POST /v2/enrichment/run with OIDC for the
  enrichment queue (TaskEdge enrichment). It accepts the legacy
  {"kind":"sync_reprocess",...} payload, so rows bound to either handler
  drain. 400 for a malformed task; 500 only for unexpected exceptions.
- config/enrichment.py: ENRICHMENT_ROUTE (sync_handler | enrichment_queue,
  default sync_handler) is the deployment default for the policy field
  enrichment_route until E1 records it per unit. ENRICHMENT_TASKS_* is the
  queue binding. An incomplete binding falls back to the sync handler and
  is counted through record_fallback.
- valid_dispatch_binding and _enqueue accept both handler paths (contract
  (b) invariant 7).

The router mount in main.py is lane 1's. Queue spec for lane 7: enrichment,
max-concurrent 50, 25/s, backoff 10-300s, unlimited attempts.

Verification (local unit, serial, nice 19):
- test_enrichment_route 12 passed (409 callback_pending keeps the wake;
  fence -> superseded; live defer -> new wake; 400s; stale wake -> 200;
  unexpected -> 5xx with the lease kept; route binding with fallback)
- test_outbox_firestore 14 passed
- test_sync_reprocess_coalesce 88 passed
- test_cross_service_deploy_contract and test_background_task_ratchet passed
- pyright 0 errors

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

* fix(enrichment): match moved retry classes so callback-pending stays 409

#22371 classifies expected enrichment retries by (defining module, class
name). #22431 moved FirstSummaryCallbackPending to utils.enrichment.outbox,
so on integration a callback-pending delivery fell through to the
unexpected branch and answered 500. That is the fast-5xx shape that
throttled the queues on 10-18 and 10-19. Match the new defining modules,
and keep the legacy pipeline fence until pipeline.py is deleted.

Failure-Class: none

Verification: test_batch_pipeline_serving 38 passed (it failed with
500 != 409 before this change on the merged integration tree).

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

* feat(enrichment): FirestoreOutbox factory with injected client, privacy check and wake

For lane 12's outbox conformance suite (build_outbox_backend('emulator')):
FirestoreOutbox(kind, client=, privacy_blocked=, create_wake=) binds every
CAS, the sweep and every wake to the injected seams. The default instance
keeps the production paths (discard_blocked, _enqueue, the shared client).
outbox._cas is the client-explicit CAS behind _mutate, and sweep takes
client=/wake= for the same purpose.

A not-due claim_key deferral leaves claim_attempts untouched (attempt stays
1 on the first real claim), as reprocess does today; there is a test for it.

Verification: test_outbox_firestore 16 passed, test_batch_pipeline_projection
40, test_sync_reprocess_coalesce 88, test_firestore_query_shapes 481,
test_sync_enrichment_custody 10; pyright 0 errors.

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

* test(enrichment): a not-due wake re-arms and answers 200 not_due

Exercises #22437's claim_key DEFERRED mapping end to end through
/v2/enrichment/run: the outbox re-arms with a new wake and the delivery is
consumed, not retried.

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

* test(enrichment): load the callback at collection time in the route tests

The fast-unit CPU guard charged process_conversation's first import to the
first route test (6.8s > 0.30s).

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

* fix(batch): recover-quarantine kill switch answers 409; legacy sr- delegates to the consumer

Contract (d), swarm lane 9:
- /v2/batch-pipeline/recover-quarantine returned 503 for "recovery
  disabled" (host or owner). Cloud Tasks system-throttles a queue that
  sees fast 5xx/503 (10-18 18:14Z, 10-19 04:52Z stalls). A switched-off
  target now answers 409 {"status":"retry","reason":"kill_switch_off"}.
  Behaviour is otherwise unchanged: the intent stays prepared, nothing is
  spent, and the queue retries.
- enrichment_response (the legacy /v2/sync-jobs/run sync_reprocess
  delivery) runs through the C3 EnrichmentConsumer when
  ENRICHMENT_ROUTE=enrichment_queue, so one lever moves new rows onto the
  enrichment queue and drains old bindings through the same state
  machine. Default sync_handler keeps today's reprocess.run path.

Failure-Class: none

Verification (local unit, serial, nice 19):
- test_batch_pipeline_quarantine_recovery 67 passed (the disabled-host,
  -cohort and -missing cases assert 409 kill_switch_off)
- test_enrichment_route 14 passed (incl. legacy-handler delegation)
- test_batch_pipeline_serving 39 passed
- test_revision_drain_harness 7 passed
- test_cross_service_deploy_contract 18 passed

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
, #22362, #22461, #22471 sync)

- config/feature-flags.yaml: kept both new rows (LISTEN_LOOP_METRICS_ENABLED from main,
  ENRICHMENT_ROUTE from integration); rendered doc regenerated.
- #21932 moved the legacy sync runner's 500/503 into _run_sync_job_attempt: known gaps and the
  task-target KNOWN set gain the four _run_sync_job_attempt keys (legacy, leave with C11), drop
  the _run_sync_job_body/503 keys and recover_quarantine/503 (fixed by #22476).
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…kReason (#21932 landed)

Adds the nine reasons #21932 introduced; set unchanged (65 values).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…weep (lane 9, C4) (#22517)

* refactor(enrichment): move the sr- outbox into utils/enrichment (C2 slice 1)

Plan C2, swarm lane 9. Pure move, no behaviour change:

- utils/sync/reprocess.py        -> utils/enrichment/outbox.py
- utils/sync/enrichment_custody.py -> utils/enrichment/custody.py
- utils/sync/enrichment_scan.py  -> utils/enrichment/scan.py

The old paths become sys.modules aliases of the new modules, so every
importer, mock.patch target and monkeypatch keeps reaching the same module
object. A star import gives pyright the public names. Batch projection
imports the new path; the frozen prod-track files (serving.py,
routers/batch_pipeline.py, batch_pipeline/enrichment.py) keep the shim until
their PRs reach integration.

Collection, document ids, field names and the sr- task prefix are unchanged
(contract (b) invariant 7). The query-shape driver and background-task
baseline follow the moved function.

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

* refactor(enrichment): drop the test-only custody and scan aliases

Only tests imported utils.sync.enrichment_custody and enrichment_scan, so the
dead-code ratchet counts the aliases as new dead files. The tests now import
utils.enrichment.scan directly; utils.sync.reprocess keeps its alias for the
production importers.

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

* test(enrichment): import the probe modules at collection time

The fast-unit CPU guard charged utils.cloud_tasks' first import to the probe
test's call phase (0.53s > 0.30s) once this file was selected. Module-level
imports keep the assertions unchanged and the call phase cheap.

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

* fix(enrichment): own the sr- callback and absorb lifecycle fences (C2 slice 3)

Plan C2, swarm lane 9. Batch enrichment no longer imports legacy
transcription (utils/sync/pipeline.py):

- utils/enrichment/callback.py: enrich_conversation, extracted verbatim from
  pipeline._reprocess_conversation_after_update with its webhook helper,
  persistence fence and lineage sentinel. pipeline.py is frozen behind
  #21932/#20662 and keeps its copy for the non-coalescing direct path, so
  test_enrichment_callback_parity.py (a static tripwire, labelled as such)
  keeps the two bodies identical until C11 deletes the legacy one. The new
  copy logs no conversation id.
- utils/enrichment/custody.py now owns discard_blocked. The batch adapter
  re-exports it for its existing importers.
- Absorbs #21968 (lead ruling 10-19): a SyncConversationPersistenceFenced
  from the callback settles the claim as superseded. The obligation is
  retired when no newer mark landed and re-armed when one did, and the
  handler ACKs 200 instead of answering 500 to a delivery that can never win.
  Other errors keep their taxonomy. #21968's conversation_id log line is not
  carried; the event is logged without identifiers.

Failure-Class: none

Verification (local unit, serial, nice 19):
- test_enrichment_callback_fence 4 passed (fenced+unchanged -> retired;
  fenced+newer mark -> re-armed; ValueError propagates; the default callback
  is the package)
- test_enrichment_callback_parity 3 passed
- test_batch_pipeline_serving 31 passed
- test_listen_finalization_cloud_tasks 278 passed
- test_sync_reprocess_coalesce 88 passed
- test_sync_enrichment_custody 10 passed
- test_background_task_ratchet, test_llm_gateway_coverage_guardrails and
  test_generated_compute_inventory_guardrails passed
- pyright 0 errors
- test_sync_reprocess_emulator now patches the package callback (CI emulator lane)

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

* feat(enrichment): Firestore Outbox for OutboxKind.ENRICHMENT (C2 slice 2)

Plan C2 / contract (b), swarm lane 9. database/outbox_firestore.py
implements the Outbox protocol over sync_reprocess_outbox, row-compatible
with mark/run: same collection, document ids, field names and sr- names.
Additive fields: policy_id, claim_attempts, a transient summary_seen_by.

- lease_token is the per-claim owner uuid and wake_token is task_token.
  heartbeat/ack/defer/release are fenced on both (invariant 1).
- claim_key: privacy discard first (invariant 6), then demand admission,
  a stale or busy check, and a not-due re-arm that wakes itself and returns
  DEFERRED. Wake ownership follows the lead's 10-19 ruling: this
  implementation creates the tasks through the existing _enqueue.
- ack keeps today's finish rules: retire when unchanged, a dormant receipt
  when record_summary marked the lease, re-arm when the version moved.
- enqueue shares mark's CAS operation (mark_update), with explicit
  available_at and min/max coalescing (invariant 3). With tx= it writes in
  the caller's transaction and returns the wake token; the caller calls
  wake() after commit (invariants 4-5). wake() is idempotent per token.
- sweep delegates to the existing sweep with a privacy discard hook. Pull
  claim() goes through the new utils.enrichment.outbox.due_rows
  (single-field due_at index), registered in the query-shape drivers.

Batch projection's mark_enrichment now calls enqueue(tx=...) and then
wake(), using its own client for both. A backfill binding is still resolved
only for a new row (new_dispatch callable), so a coalesced append never
raises on a missing backfill env, as before.

database.outbox.outbox_for is lane 1's stub; firestore_outbox(kind) is the
implementation it should return (wiring requested from the captain).

Verification (local unit, serial, nice 19):
- test_outbox_firestore 13 passed
- test_batch_pipeline_projection 40 passed
- test_sync_reprocess_coalesce 88 passed
- test_firestore_query_shapes 481 passed
- the outside-query, runtime-witness and index-oracle suites passed
- test_listen_finalization_cloud_tasks 278 passed
- pyright 0 errors
The emulator conformance suite is lane 12's and has not landed yet.

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

* feat(enrichment): outbox_for selects the Firestore enrichment outbox

Lane 1 signed off on this one-function edit of its stub (10-19): in this
window the selector always returns the Firestore implementation; the
BATCH_JOBSTORE_MODE switch is lane 12's.

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

* feat(enrichment): /v2/enrichment/run on the outbox consumer, 409-only retries (C3)

Plan C3 / contracts (a) and (d), swarm lane 9.

- utils/enrichment/consumer.py: EnrichmentConsumer, a QueueConsumer for
  OutboxKind.ENRICHMENT (workers role; 120s lease, 30s heartbeat on every
  lease). It mirrors reprocess.run outcome for outcome, with settlement
  through the Outbox calls:
  - processed -> DONE (ack; a dormant receipt via record_summary);
  - superseded or lifecycle fence -> DISCARDED;
  - repair race -> outbox.repair;
  - live target or missing conversation -> DEFERRED +120s;
  - redirect -> custody transfer;
  - empty budget spent -> retired;
  - callback pending or empty output -> RETRY callback_pending (409; release
    keeps the wake for the queue retry).
- routers/enrichment.py: POST /v2/enrichment/run with OIDC for the
  enrichment queue (TaskEdge enrichment). It accepts the legacy
  {"kind":"sync_reprocess",...} payload, so rows bound to either handler
  drain. 400 for a malformed task; 500 only for unexpected exceptions.
- config/enrichment.py: ENRICHMENT_ROUTE (sync_handler | enrichment_queue,
  default sync_handler) is the deployment default for the policy field
  enrichment_route until E1 records it per unit. ENRICHMENT_TASKS_* is the
  queue binding. An incomplete binding falls back to the sync handler and
  is counted through record_fallback.
- valid_dispatch_binding and _enqueue accept both handler paths (contract
  (b) invariant 7).

The router mount in main.py is lane 1's. Queue spec for lane 7: enrichment,
max-concurrent 50, 25/s, backoff 10-300s, unlimited attempts.

Verification (local unit, serial, nice 19):
- test_enrichment_route 12 passed (409 callback_pending keeps the wake;
  fence -> superseded; live defer -> new wake; 400s; stale wake -> 200;
  unexpected -> 5xx with the lease kept; route binding with fallback)
- test_outbox_firestore 14 passed
- test_sync_reprocess_coalesce 88 passed
- test_cross_service_deploy_contract and test_background_task_ratchet passed
- pyright 0 errors

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

* fix(enrichment): match moved retry classes so callback-pending stays 409

#22371 classifies expected enrichment retries by (defining module, class
name). #22431 moved FirstSummaryCallbackPending to utils.enrichment.outbox,
so on integration a callback-pending delivery fell through to the
unexpected branch and answered 500. That is the fast-5xx shape that
throttled the queues on 10-18 and 10-19. Match the new defining modules,
and keep the legacy pipeline fence until pipeline.py is deleted.

Failure-Class: none

Verification: test_batch_pipeline_serving 38 passed (it failed with
500 != 409 before this change on the merged integration tree).

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

* feat(enrichment): FirestoreOutbox factory with injected client, privacy check and wake

For lane 12's outbox conformance suite (build_outbox_backend('emulator')):
FirestoreOutbox(kind, client=, privacy_blocked=, create_wake=) binds every
CAS, the sweep and every wake to the injected seams. The default instance
keeps the production paths (discard_blocked, _enqueue, the shared client).
outbox._cas is the client-explicit CAS behind _mutate, and sweep takes
client=/wake= for the same purpose.

A not-due claim_key deferral leaves claim_attempts untouched (attempt stays
1 on the first real claim), as reprocess does today; there is a test for it.

Verification: test_outbox_firestore 16 passed, test_batch_pipeline_projection
40, test_sync_reprocess_coalesce 88, test_firestore_query_shapes 481,
test_sync_enrichment_custody 10; pyright 0 errors.

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

* test(enrichment): a not-due wake re-arms and answers 200 not_due

Exercises #22437's claim_key DEFERRED mapping end to end through
/v2/enrichment/run: the outbox re-arms with a new wake and the delivery is
consumed, not retried.

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

* test(enrichment): load the callback at collection time in the route tests

The fast-unit CPU guard charged process_conversation's first import to the
first route test (6.8s > 0.30s).

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

* fix(batch): recover-quarantine kill switch answers 409; legacy sr- delegates to the consumer

Contract (d), swarm lane 9:
- /v2/batch-pipeline/recover-quarantine returned 503 for "recovery
  disabled" (host or owner). Cloud Tasks system-throttles a queue that
  sees fast 5xx/503 (10-18 18:14Z, 10-19 04:52Z stalls). A switched-off
  target now answers 409 {"status":"retry","reason":"kill_switch_off"}.
  Behaviour is otherwise unchanged: the intent stays prepared, nothing is
  spent, and the queue retries.
- enrichment_response (the legacy /v2/sync-jobs/run sync_reprocess
  delivery) runs through the C3 EnrichmentConsumer when
  ENRICHMENT_ROUTE=enrichment_queue, so one lever moves new rows onto the
  enrichment queue and drains old bindings through the same state
  machine. Default sync_handler keeps today's reprocess.run path.

Failure-Class: none

Verification (local unit, serial, nice 19):
- test_batch_pipeline_quarantine_recovery 67 passed (the disabled-host,
  -cohort and -missing cases assert 409 kill_switch_off)
- test_enrichment_route 14 passed (incl. legacy-handler delegation)
- test_batch_pipeline_serving 39 passed
- test_revision_drain_harness 7 passed
- test_cross_service_deploy_contract 18 passed

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

* feat(enrichment): enrichment-maintenance scheduler + /v2/enrichment/sweep (C4)

Plan C4, swarm lane 9. One maintenance owner for the enrichment outbox
on the workers role:

- POST /v2/enrichment/sweep (OIDC as /v2/enrichment/run) runs the outbox
  sweep (lost-wake repair, privacy discard), then summary_debt_repair.tick.
  It answers 200 with counts; a summary-debt failure is counted, never 5xx.
- deploy/scheduler/jobs.yaml: enrichment-maintenance (*/2) against
  backend-integration, lifecycle: planned until the route serves there.
  Prod ENABLED; dev PAUSED (dev shares prod Firestore, as the sequencer).

Both halves are safe beside the legacy sequencer sweep: the outbox sweep
is per-row CAS and the summary-debt tick holds its own cursor lease. The
sequencer sweep's reprocess.sweep and summary_debt_repair.tick calls
(routers/sync.py:1958) are deleted by lane 10's slice. Summary-debt
repair on backend-integration needs SUMMARY_DEBT_REPAIR_ENABLED in lane
7's ops file (today it is set on backend-sync only).

Verification: test_enrichment_route 16 passed; test_scheduler_reconcile
24 passed (job sets plus lifecycle/state pinned).

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

* refactor(outbox): selector returns the Outbox protocol; one shared provider-STT instance

Follow-up nits from lane 9's sign-off on #22467: FirestoreOutbox and
firestore_outbox are annotated as returning the Outbox protocol, which drops
the type-ignore (both implementations satisfy it under pyright), and the
provider-STT branch caches one lazily built instance like enrichment's
module singleton.

Verification: pyright 0 errors; test_outbox_firestore 16,
test_provider_stt_outbox 11, test_enrichment_route 16,
test_batch_pipeline_projection 40, test_scheduler_reconcile 24 passed.

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

* chore(enrichment): route policy for /v2/enrichment/sweep

Mirrors /v2/enrichment/run: service OIDC, internal task surface, no rate
limit, sync_job timeout class, conversations data domain.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…atchet (lane 14 M1) (#22422)

* feat(observability): reason enums, label AST check and batch-stage env ratchet (lane 14 M1)

Contract (e): utils/observability/reasons.py with ReasonFamily, per-family
enums, reason_label() and omi_reason_unknown_total. live_reason and
recovery_disposition now derive their frozensets from the enums
(behaviour-neutral; misses are also counted). Adds the shrink-only
label-argument AST check and the batch-stage env-read ratchet.

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

* refactor(batch): derive worker validation constants from the reason enums (lane 14)

Values unchanged.

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

* Hold recovery_disposition.py until #22368; adopt stub counter name; debt list for workers/consumer.py

recovery_disposition.py is reverted to integration's version (freeze table);
re-add the enum-derived constants after #22368 lands. REASON_UNKNOWN_TOTAL
keeps the stub's name and both counters are pre-initialised per family.

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

* env ratchet: pending allowances for reads lane 9 moves (C2)

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

* reason-label debt: lane 10 legacy_dark sites (closed via own enum helper)

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

* Re-add enum-derived recovery_disposition constants after #22368; refresh ratchet baselines

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

* Drop the pending alert-metric allowances now that reasons.py produces both counters

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

* feat(listen): populate app_build on omi_listen_accepted_total from X-App-Version (lane 14)

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

* refactor(observability): derive fallback ALLOWED_REASONS from FallbackReason (#21932 landed)

Adds the nine reasons #21932 introduced; set unchanged (65 values).

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

* reasons: add ShadowParityOutcome (lane 12); debt entry for external_list_reads

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

* refactor(batch): WorkResult/RecoveryWork closed sets from WorkOutcome and WorkerValidationReason (values unchanged)

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

* chore(changelog): none fragment (integration carries app edits relative to main; lane 14 is backend-only)

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

* Restore app/ from integration (formatter collateral); drop none changelog fragment

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

* Restore app/ exactly from integration (undo formatter collateral)

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

* fix(listen): read app_version fail-safe so partial device contexts cannot break session start

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

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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