Repository navigation
sync: trace-carrying refusal record for each designed sync-local-files 503 (SCA-2225) - #26458
Merged
Merged
Conversation
… 503 (SCA-2225) The Cloud Run rollout guard needs to tell designed 503 backpressure apart from real 503 failures on POST /v2/sync-local-files. Each handler-level designed refusal now writes one INFO line 'sync_upload_refused uid=%s status=503 reason=%s trace=%s' immediately before its 503, carrying the request's X-Cloud-Trace-Context trace id so the guard can match it to that request's Cloud Run request log. The existing backfill_day_cap line moves onto the helper. Failure 503s (sync_dispatch_unavailable, staging/sequencer/batch errors) write none. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keeps routers/sync.py growth to the seven call sites. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…nce standby (SCA-2225) Luna's review: an invalid fence setting fails closed to STANDBY and was recorded as designed, and the custody finalizer can replace a designed 503 with its own after the record was written. The handler now only marks a designed refusal. records_designed_refusals, outside custody_upload, writes the record after the final outcome is known, and only when it is the very response or exception the handler produced (captured by the innermost designed_refusal_outcome) and a 503. A finalizer-replaced 503 stays unrecorded and counts. The fence mark is emitted only when SYNC_LEDGER_FENCE_MODE is explicitly standby. 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
Nov 28, 2026
## Current head `6cd1ddb581f66c1977af3f203b4d2fa2b81bf709` includes current main `2bb5e483eade6705f2ef0c7402c5e25262ca388a` and addresses two distinct F1 findings from panels `review-20261128t082952-d563` and `review-20261128t083610-60fa`. - **Interrupted promotion.** A bound traffic update stores the run's ownership evidence with the traffic map in the same ETag-conditional write. If the runner disappears before it uploads the completed receipt, the existing prod-approved `recover-split` dispatch can restore the admitted inverse after verifying the original attempt, service identity, generation, tags, requested and observed maps, and published release floor. Completed promotions still use their schema-1 receipt. Regression test `test_recover_run_restores_interrupted_move_without_completed_receipt`. - **Floor advance during a guard.** Before an in-process rollback, the executor refreshes `origin/main` and rechecks every inverse and retained tag target using digest-pinned image source commits. A failed refresh or a below-floor target prevents the write. Regression tests `test_promote_enforces_a_floor_published_during_the_guard` and `test_failed_floor_refresh_prevents_the_inverse_write`. Local verification at this head passed 196 focused Python 3.11 tests with simulated Cloud Run transport, along with actionlint, production-boundary, deployment-concurrency, and CI budget checks. ## Import fixes at 1c11cd5 `1c11cd58411204aa061535c5728dd4936dd39018` addresses the two repository-rule findings on the previous head. The hold-back executor imports `serving_has` at module scope for both package and direct script execution. The test fixture passes its temporary identity via `git -c`. All 43 focused Python 3.11 tests passed, along with package import and normal and isolated CLI import checks. ## Earlier integration with main `37feec356cf0a0a4830f0a8d25af69c1c07705fb` merges main at `92e192d8a5ba08153ea011e9df402b2e869933ef` into the existing branch. The diff against that main retains the workflow and recovery from #26499 and carries: - **Release floor.** Resolve the digest-pinned source for each revision that the move or recovery can leave routable, including zero-percent tag targets. Check the existing release floor against the resolved commit. An unresolved source fails the operation before the traffic write. - **Guard inputs.** Weight sampled 429 logs in the request denominator alongside sampled 2xx and 3xx. Keep main's trace-based 503 matching and Sync page budget. Carry the stacked PR's regression tests here. - **Serving verification.** Carry the admitted candidate traffic share through latest-Ready polling, including split-preserving moves. Focused verification at this head passed 313 tests. Actionlint, the production-boundary check, the deployment-concurrency check, and the CI budget check passed. Release still needs to qualify registry reads under the deploy identity. Sync activation also requires a serving revision that contains #26458 and a read-only same-revision refusal/request trace match. The sections below record the earlier heads and their review history. ## What changed and why This is the Cloud Run workflow and deploy-action change David named in chat on 2026-11-26 at about 20:45Z, as recorded on [SCA-2225](https://multica-01.tail76ea03.ts.net/scaling-forever/issues/01a1d9db-f106-7919-8578-16fbc2299124). It wires the [reviewed hold-back executor](Git-on-my-level/omi-workspace#525) into the four named production Cloud Run deploy targets. - A first-attempt selected deploy on main binds the canonical plan by SHA-256 in its run title and keeps normal source admission, approval, and the `prod-train` lock. Both `train-digest-v1` guards from #26414 are preserved byte for byte. - The action deploys and validates a zero-traffic candidate, checks the snapshot's requested and observed maps against the admitted inverse, then moves 95% to the candidate and keeps 5% on the donor for a two-hour guard window. An existing split receives a guarded initial canary and preserves the other revisions' shares. A full-window PASS transfers the remaining donor share. The action uploads the bound schema-1 promotion receipt before serving verification so recovery can use it if acceptance fails. The serving verifier checks the resulting candidate share. - TRIP restores the exact pre-promotion map while the executor still owns the move. NO_COMPARATOR and INSUFFICIENT_DATA leave the observed partial map in place and suppress snapshot recovery and the success receipt. For a completed bound promotion, acceptance failure can restore the admitted inverse using the promotion receipt. If a bound move is interrupted before completion, Release can run the approved recovery dispatch using the original run ID and the ownership evidence written with the traffic change. ## SHA-256 at the PR head (6cd1ddb) | File | SHA-256 | | --- | --- | | `.github/actions/deploy-backend-stack/action.yml` | `8eb5cc3cb7f5056368d0a237f9df533d9a617130351f02500fde97bfa133d894` | | `.github/workflows/gcp_backend.yml` | `780a4e47968d7bcc66d667057ca244ceae80d447680c7a16a2bab8c400775c7e` | | `backend/cloud-run-guard.json` | `e36d5903d712b6fb14461b3e245ec3990d942e7f580c23077fc1a30ddf13281f` | | `backend/scripts/cloud_run_split_canary.py` | `69b1aad0efc6d5f123d64213e6b3f0919eccbd6b2147f77ffed9d945535eaf8d` | | `backend/scripts/guard_eval.py` | `bc6e441b1cafd8af7befac22c86bf7b2cb43456be0a539b1a6a4419183d175af` | | `backend/scripts/serving_revision.py` | `204389ffc2ee6533f5f68f0e5ee034138818d3ea9182a4c50332dd15a106e68d` | | `backend/scripts/verify_backend_release_vector.py` | `27199e31d5a8d7663d1ab6cd88f39d2d5deb11a89d4df6bc95c14e28de0362e1` | | `backend/scripts/serving_has.py` (vendored guard dependency) | `394b6bad5ff3ab789c55219311ce86f635395cda90c495d55c1bf08f32f24e7d` | | `.github/scripts/verify_backend_release_floor.py` (called with `--sha` via `--release-floor-check`) | `985b7956e58645a90c9c6112607da856d75e0d03b8a83f0723851ada81fa871d` | The vendored guard includes `serving_has.py`, a transitive import through `serving_revision.py`. Include that dependency in review of the pin set. ## Product invariants affected - INV-DATA-1 ## How it was verified - `actionlint .github/workflows/gcp_backend.yml .github/workflows/gcp_backend_auto_dev.yml` and the production boundary, source-admission, and deployment concurrency checks. - The 117 workspace hold-back, guard, custody, and dispatch tests ran against the product copies using offline transports. The five vendored Python files matched the reviewed workspace syntax trees after repository formatting. - Production WIF access for aggregate Monitoring and Logging reads remains for Release qualification. Verification was local and offline. - All 1,679 selected backend and GitHub workflow contract tests passed. The six production-boundary fixtures and twelve rollback-condition cases passed on the final commit. - CI budget: b4cfa0f refreshes `.github/ci-budget.yaml` for the two optional dispatch inputs and applies the existing one-minute p50 dispatch-input allowance per gcp_backend.yml job, with rationale. No event, job, frequency, runner or cap changes. `check_ci_budget.py --base origin/main` passes, and the branch was pushed through the normal pre-push gate with no override. (Origin/main was merged in with a merge commit, not a rebase.) ## Tests The product tests exercise plan and digest admission, per-service executor arguments, held and failed step outputs, restore conditions, and serving-share verification. UI-Evidence: none Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/26438?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26438?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26438&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. --> ## Review fixes at 0555a10 (five Codex findings) - The rollback floor check is now required. Every inverse revision and the candidate run through `verify_backend_release_floor.py --revision` before any traffic moves. - `serving_revision --contains` uses `git merge-base --is-ancestor`. - `serving_has.default_repo()` falls back to the checkout that contains the script. - 429s are reweighted with `rate_limited_log_weight: 10`. - The blanket 503 exclusion on sync-local-files is removed, so 503s count as errors. Tests: 1,056 passed across 13 offline backend test files, 23 of them new. Each new test fails on the old code. `actionlint` was not re-run. (The 0555a10 hash table is superseded by the head table above.) ## Review fixes at 01df1d2 (Luna's two P1s) - **Revision identity.** The executor's floor check no longer uses `verify_backend_release_floor.py --revision`, which trusts the `OMI_BACKEND_RELEASE_SHA` env stamp. It describes the revision, resolves the pinned image digest to its source commit through `serving_has.image_source` (OCI revision label or commit tags), then runs `verify_backend_release_floor.py --sha <image source>`. An unproven source fails closed: identity mismatch, tag-only image, registry without evidence, or a commit that isn't in the checkout. - **Tagged 0% revisions.** `promote()` floor-checks every tagged revision as well as the inverse and the candidate. A below-floor tagged revision refuses the plan before any traffic move. Tests: 1,065 passed across 13 offline backend test files (`test_cloud_run_holdback_scripts.py` is now at 32). One regression test pins a floor-qualified env stamp on a below-floor image source, which must be refused. The other pins a below-floor 0% tagged revision, which must be refused with nothing moved. The floor verifier's own 7 tests pass. `actionlint .github/workflows/gcp_backend.yml .github/workflows/gcp_backend_auto_dev.yml` is clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Every handler-level designed 503 refusal on
POST /v2/sync-local-filesnow writes exactly one INFO record:sync_upload_refused uid=%s status=503 reason=%s trace=<32-hex X-Cloud-Trace-Context id>The mechanism lives in
utils/sync/designed_refusal.py:mark_designed_refusal(...)right before the designed 503.designed_refusal_outcome, the innermost decorator, captures the handler's own response or exception.records_designed_refusals, outsidecustody_upload, writes the record only if the final outcome is that same object and is a 503. A 503 that the custody finalizer substitutes is left unrecorded.SYNC_LEDGER_FENCE_MODEis explicitlystandby, so an invalid setting that fails closed is not marked.The existing
backfill_day_capline moves onto this mechanism. Failure 503s write no record. Those includesync_dispatch_unavailable(staging or sequencer),sync_batch_unavailablefrom batch-admission errors, custody, config and platform 503s.Why
SCA-2225. The Cloud Run rollout guard used to exclude every sync-local-files 503 (
refusal_statuses: [503]), which hid real failures. Removing that exclusion outright flips the labelled trip backtest, because designed backpressure then counts as errors. Luna approved a design on SCA-2225 (2026-11-27T00:09Z): exclude a 503 only when the same revision logged a designed-refusal record for the same request, and hold on anything that cannot be reconciled. Thetrace=field lets the guard match each record to its own request log one-to-one, so window edges do not skew the counts. The guard side of the change is a separate PR stacked on #26438 (linked below).Production shape check (ro-prod
read-only-bot-account, 2026-11-27, projections only, no payloads or uids read): backend-sync 503 request logs for this route carrytrace=projects/based-hardware/traces/<id>. The existingsync_upload_refused … status=503records land inrun.googleapis.com%2Fstdoutwithresource.labels.revision_name.503 inventory:
POST /v2/sync-local-files(BasedHardware/omiorigin/mainf628eab)Line numbers are at f628eab. "Record" means one
sync_upload_refused uid=… status=503 reason=… trace=…line. The handler marks the refusal right before its 503, and the outermost wrapper writes the line only if that same 503 is the final response. Before this change, only #8 wrote a record, and that record had no trace.sync_upload_refusedis written only insidesync_local_files_v2; no other route or file writes that string.OMI_ENV_STAGEmissing or invaliddirectory_routing_unavailableaccount_deletion_state_unavailableaccount_cutover_state_unavailablememoized_record_wait(sync.py:852)record_capture_pendingsync_ledger_fence_cutoversync_ledger_fence_cutoverbackfill_capacitySYNC_BACKFILL_ENABLEDoffbackfill_disabledbackfill_capacitybackfill_day_cap, now with tracerecord_custody_append.beginraisescapture_clock_anchor_unavailableretained_recovery_disabledcapture_clock_identity_requiredcapture_clock_identity_requiredrecord_capture_pending*_failedreasons are failuresrecord_capture_pendingrecord_routeris Nonesync_batch_unavailable, Retry-After 1sync_batch_unavailableFutureCaptureRetry)capture_clock_anchor_pending/identity_required/anchor_unavailablesync_batch_unavailablesync_batch_unavailablerepaired_clock_batch_declinedbackfill_capacitydispatch_holdDestructiveOperationInProgressdispatch_holdsync_dispatch_unavailablesync_dispatch_unavailable@custody_uploadfinally)record_custody_append.finishraises; can replace any response* #6: an invalid fence setting also fails closed to STANDBY (
database/sync_jobs.py:154) and returns the same 503. Since 61972e1, onlySYNC_LEDGER_FENCE_MODE=standbyis marked; an invalid setting stays unrecorded and counts as an error (regression test included).Records gap (designed, but still counted as errors): #5, #10:197, the wait reasons in #13, #15, #16, and #17 pending/identity. These 503s come from below the handler:
live_upload, batch intake,receipt_clock. There the request's trace is not in scope, and the same response code is shared with failure paths. Batch intake's outertryalso rewrites exceptions into the genericsync_batch_unavailable. Recording them needs the trace passed down (for example a contextvar) and its own review. Until then they count as errors on both revisions, which is the conservative direction: a candidate that changes their rate is scored as a 5xx change.Custody finalizer (#24), fixed in 61972e1: the record used to be written before
@custody_uploadfinished, so a finalizer 503 could replace a designed response after its record existed. Nowdesigned_refusal_outcome, the innermost layer, captures the handler's own response or exception, andrecords_designed_refusals, outsidecustody_upload, writes the record only if the final outcome is that same object and is a 503. A finalizer-replaced 503 stays unrecorded and counts (regression test included).Logging path: the
utils/sync/designed_refusal.pylogger propagates to the root handler thatmain.py:27installs throughconfigure_logging(K_SERVICE, default_format='text', …). That handler writes INFO to stdout asINFO utils.sync.designed_refusal: sync_upload_refused uid=… status=503 reason=… trace=<32 hex>. Cloud Run ingests stdout astextPayloadinrun.googleapis.com%2Fstdoutand labels it withresource.labels.revision_name. The trace comes from theX-Cloud-Trace-Contextheader the handler already declares. It is the trace id Cloud Run writes into the request log'stracefield. No PII is added beyond the existinguid=pattern.Composition and order
lane/holdback-wiring). The guard change is a separate PR stacked on Wire two-hour Cloud Run hold-back for selected backend deploys #26438: guard_eval: exclude only Sync 503s matched to a designed-refusal record (SCA-2225, stacked on #26438) #26459. The workspace copy is Git-on-my-level/omi-workspace OTA and Microphone Improvements #586.backfill_day_caprecord carries notrace=, and the guard holds (INSUFFICIENT_DATA refusal_records_unparseable_record) on any window where that revision logged one. The first comparison against a pre-trace inverse can therefore hold once.Verification
Run with
omi-heavy run -- timeout 1800 bash test.sh …(local, hermetic):test_sync_designed_refusal_record.py: 19 passed.test_sync_backfill_day_cap_upload.py11,test_logging_entrypoint_guard.py51,test_sync_ledger_fence_cutover.py14,test_sync_capture_time_skew.py160: all passed.sync_local_files_v2(future-early parity, schema inventory, legacy dark, fair use, mobile standard batch, batch language router, cloud tasks, assignment recovery,test_sync_v2, batch intake outcome, custody admission privacy): 14, 15, 48, 30, 27, 31, 40, 210, 13, 51 and 193 passed.The new tests cover:
standbyfence, which is recorded; an invalid setting (stanby,on) gives the same 503 with no record and logsinvalid_config;Not proven here: that production records carry the trace id. That needs this PR serving, then a READBACK that
sync_upload_refused … trace=lines match request-log traces on the same revision.Line-Count-Exception: backend/routers/sync.py | 4393 -> 4405 | seven designed-refusal marks, the explicit-standby guard and two decorator lines; the mechanism lives in utils/sync/designed_refusal.py
Product invariants affected
none
🤖 Generated with Claude Code