Repository navigation
Wire two-hour Cloud Run hold-back for selected backend deploys - #26438
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eac031e4f7
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4cfa0fc48
ℹ️ 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".
Address the five Codex findings on #26438 (SCA-2225): - cloud_run_split_canary: promote requires a release-floor check and runs verify_backend_release_floor.py for every inverse revision and the candidate before the first traffic move, so a TRIP or error can never restore a pre-floor binary. The workflow step refreshes origin/main and passes --release-floor-check, like the snapshot-recovery steps. - guard_eval: 429 request logs are sampled at 10% in prod; weight them by the new rate_limited_log_weight in request denominators and 4xx counts. - cloud-run-guard.json: drop the blanket 503 refusal exclusion on sync-local-files. Request logs cannot tell designed refusals from sync_dispatch_unavailable failures, so 503s stay in the error population. - serving_has.default_repo falls back to the checkout containing the script. - serving_revision --contains uses git merge-base --is-ancestor in-process instead of the absent contains_commit.py; an exact-equal SHA passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address Luna's two P1s on #26438 (SCA-2225): - The executor's floor check no longer trusts OMI_BACKEND_RELEASE_SHA. It describes the revision, resolves its pinned image digest to the source commit through serving_has (OCI revision label or commit tags), and runs verify_backend_release_floor.py --sha on that commit. A revision whose image source cannot be proven fails closed. - promote() also floor-checks every tagged revision. A 0% tag stays routable through its tag URL and replace() keeps it, so a below-floor tagged revision now refuses the plan before any traffic move. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s 503 (SCA-2225) (#26458) ## What Every handler-level designed 503 refusal on `POST /v2/sync-local-files` now 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`: - The handler calls `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`, outside `custody_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. - The fence cutover is marked only when `SYNC_LEDGER_FENCE_MODE` is explicitly `standby`, so an invalid setting that fails closed is not marked. The existing `backfill_day_cap` line moves onto this mechanism. Failure 503s write no record. Those include `sync_dispatch_unavailable` (staging or sequencer), `sync_batch_unavailable` from 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. The `trace=` 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 carry `trace=projects/based-hardware/traces/<id>`. The existing `sync_upload_refused … status=503` records land in `run.googleapis.com%2Fstdout` with `resource.labels.revision_name`. ### 503 inventory: `POST /v2/sync-local-files` (BasedHardware/omi `origin/main` f628eab) 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_refused` is written only inside `sync_local_files_v2`; no other route or file writes that string. | # | file:line | code | trigger | designed? | record before | record after | |---|---|---|---|---|---|---| | 1 | utils/sync/stage.py:50 (router dependency) | stage unavailable | `OMI_ENV_STAGE` missing or invalid | failure (config) | no | no (counts as error) | | 2 | utils/other/endpoints.py:65 | `directory_routing_unavailable` | directory resolution fails | failure | no | no | | 3 | utils/other/endpoints.py:112 | `account_deletion_state_unavailable` | deletion-fence read raises | failure | no | no | | 4 | utils/account_cutover/access.py:260/262 | `account_cutover_state_unavailable` | cutover state unreadable | failure | no | no | | 5 | live_upload.py:118 via `memoized_record_wait` (sync.py:852) | `record_capture_pending` | cached conversation-level wait | designed | no | **no (gap, see below)** | | 6 | sync.py:873 | `sync_ledger_fence_cutover` | fence mode STANDBY | designed pause only when explicitly configured* | no | **yes, explicit standby only** `sync_ledger_fence_cutover` | | 7 | sync.py:973 | `backfill_capacity` | backfill lane, `SYNC_BACKFILL_ENABLED` off | designed (kill switch) | no | **yes** `backfill_disabled` | | 8 | sync.py:1040 (log at 1038) | `backfill_capacity` | unlimited_v2 backfill day cap | designed | yes, no trace | **yes** `backfill_day_cap`, now with trace | | 9 | utils/sync/record_token_lease.py:120 | custody admission | `record_custody_append.begin` raises | failure (custody) | no | no | | 10 | utils/sync/receipt_clock.py:197 / :204 | `capture_clock_anchor_unavailable` | :197 too many scopes (bounded refusal); :204 read fails | :197 designed, :204 failure | no | no (gap for :197) | | 11 | sync.py:1118 | "Historical recovery is paused" | retained recovery while backfill is off | designed | no | **yes** `retained_recovery_disabled` | | 12 | sync.py:1169 | `capture_clock_identity_required` | future-clock files with no device id | designed | no | **yes** `capture_clock_identity_required` | | 13 | live_upload.py:118 via record router (sync.py:1265, intake.py:750) | `record_capture_pending` | 9 wait reasons are designed; 4 `*_failed` reasons are failures | mixed | no | no (gap for the waits) | | 14 | intake.py:749 | `record_capture_pending` | `record_router` is None | wiring fault, unreachable | no | no | | 15 | utils/batch_pipeline/upload_coalescing.py:242 | `sync_batch_unavailable`, Retry-After 1 | coalescing wait | designed | no | no (gap) | | 16 | intake.py:987 | `sync_batch_unavailable` | decode-failure memo hit | designed repeat | no | no (gap) | | 17 | intake.py:1271 (`FutureCaptureRetry`) | `capture_clock_anchor_pending` / `identity_required` / `anchor_unavailable` | clock anchoring in batch decode | pending and identity designed; unavailable failure | no | no (gap) | | 18 | intake.py:1298 | `sync_batch_unavailable` | any batch-admission exception | failure | no | no | | 19 | sync.py:1421 | `sync_batch_unavailable` | batch declined an estimated or retained-clock upload | designed decline | no | **yes** `repaired_clock_batch_declined` | | 20 | sync.py:1608 | `backfill_capacity` | backfill lane but not Cloud Tasks eligible | failure (config, fail closed) | no | no | | 21 | sync.py:1664 | `dispatch_hold` | staging hit `DestructiveOperationInProgress` | designed pause | no | **yes** `dispatch_hold` | | 22 | sync.py:1675 | `sync_dispatch_unavailable` | GCS staging failed | failure | no | no (counts) | | 23 | sync.py:1758 | `sync_dispatch_unavailable` | sequencer registration failed | failure | no | no (counts) | | 24 | record_token_lease.py:93 (`@custody_upload` finally) | custody | `record_custody_append.finish` raises; can replace any response | failure | no | no | | — | Cloud Run platform | — | no instance, queue full, crash | infra | no app log | no (counts) | \* #6: an invalid fence setting also fails closed to STANDBY (`database/sync_jobs.py:154`) and returns the same 503. Since 61972e1, only `SYNC_LEDGER_FENCE_MODE=standby` is 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 outer `try` also rewrites exceptions into the generic `sync_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_upload` finished, so a finalizer 503 could replace a designed response after its record existed. Now `designed_refusal_outcome`, the innermost layer, captures the handler's own response or exception, and `records_designed_refusals`, outside `custody_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.py` logger propagates to the root handler that `main.py:27` installs through `configure_logging(K_SERVICE, default_format='text', …)`. That handler writes INFO to stdout as `INFO utils.sync.designed_refusal: sync_upload_refused uid=… status=503 reason=… trace=<32 hex>`. Cloud Run ingests stdout as `textPayload` in `run.googleapis.com%2Fstdout` and labels it with `resource.labels.revision_name`. The trace comes from the `X-Cloud-Trace-Context` header the handler already declares. It is the trace id Cloud Run writes into the request log's `trace` field. No PII is added beyond the existing `uid=` pattern. ## Composition and order - This PR touches no guard files, so it has no conflict with #26438 (`lane/holdback-wiring`). The guard change is a separate PR stacked on #26438: #26459. The workspace copy is Git-on-my-level/omi-workspace #586. - **Order:** this PR should be serving on backend-sync before either guard change scores Sync. Before that, a revision's old `backfill_day_cap` record carries no `trace=`, 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. - Rollback: revert this PR. The records are log-only; responses and behavior are unchanged. ## 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.py` 11, `test_logging_entrypoint_guard.py` 51, `test_sync_ledger_fence_cutover.py` 14, `test_sync_capture_time_skew.py` 160: all passed. - The other suites that touch `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: - the record format and trace parsing, and the guard parser reading the shared text format; - a raised designed 503, which is recorded once and still raised; - a mark made without the outer recorder, which writes nothing; - **custody finish failing after a designed refusal**, which gives the finalizer's 503 and no record; a clean finish records once; - a wrapper replacing the response, which writes no record; - the decorator order: recorder, then custody, then observe, then capture, then handler; - **an explicit `standby` fence, which is recorded; an invalid setting (`stanby`, `on`) gives the same 503 with no record and logs `invalid_config`**; - a real over-cap upload, which writes exactly one traced record; - an AST check that the seven marks each sit directly before a designed 503. 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](https://claude.com/claude-code)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37feec356c
ℹ️ 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".
f49c9f8 to
6cd1ddb
Compare
Current head
6cd1ddb581f66c1977af3f203b4d2fa2b81bf709includes current main2bb5e483eade6705f2ef0c7402c5e25262ca388aand addresses two distinct F1 findings from panelsreview-20261128t082952-d563andreview-20261128t083610-60fa.recover-splitdispatch 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 testtest_recover_run_restores_interrupted_move_without_completed_receipt.origin/mainand 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 teststest_promote_enforces_a_floor_published_during_the_guardandtest_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
1c11cd58411204aa061535c5728dd4936dd39018addresses the two repository-rule findings on the previous head. The hold-back executor importsserving_hasat module scope for both package and direct script execution. The test fixture passes its temporary identity viagit -c. All 43 focused Python 3.11 tests passed, along with package import and normal and isolated CLI import checks.Earlier integration with main
37feec356cf0a0a4830f0a8d25af69c1c07705fbmerges main at92e192d8a5ba08153ea011e9df402b2e869933efinto the existing branch. The diff against that main retains the workflow and recovery from #26499 and carries: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. It wires the reviewed hold-back executor into the four named production Cloud Run deploy targets.
prod-trainlock. Bothtrain-digest-v1guards from SCA-3607 Guard digest-promotion dispatch before cloud authentication #26414 are preserved byte for byte.SHA-256 at the PR head (6cd1ddb)
.github/actions/deploy-backend-stack/action.yml8eb5cc3cb7f5056368d0a237f9df533d9a617130351f02500fde97bfa133d894.github/workflows/gcp_backend.yml780a4e47968d7bcc66d667057ca244ceae80d447680c7a16a2bab8c400775c7ebackend/cloud-run-guard.jsone36d5903d712b6fb14461b3e245ec3990d942e7f580c23077fc1a30ddf13281fbackend/scripts/cloud_run_split_canary.py69b1aad0efc6d5f123d64213e6b3f0919eccbd6b2147f77ffed9d945535eaf8dbackend/scripts/guard_eval.pybc6e441b1cafd8af7befac22c86bf7b2cb43456be0a539b1a6a4419183d175afbackend/scripts/serving_revision.py204389ffc2ee6533f5f68f0e5ee034138818d3ea9182a4c50332dd15a106e68dbackend/scripts/verify_backend_release_vector.py27199e31d5a8d7663d1ab6cd88f39d2d5deb11a89d4df6bc95c14e28de0362e1backend/scripts/serving_has.py(vendored guard dependency)394b6bad5ff3ab789c55219311ce86f635395cda90c495d55c1bf08f32f24e7d.github/scripts/verify_backend_release_floor.py(called with--shavia--release-floor-check)985b7956e58645a90c9c6112607da856d75e0d03b8a83f0723851ada81fa871dThe vendored guard includes
serving_has.py, a transitive import throughserving_revision.py. Include that dependency in review of the pin set.Product invariants affected
How it was verified
actionlint .github/workflows/gcp_backend.yml .github/workflows/gcp_backend_auto_dev.ymland 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.yamlfor 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/mainpasses, 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
Review fixes at 0555a10 (five Codex findings)
verify_backend_release_floor.py --revisionbefore any traffic moves.serving_revision --containsusesgit merge-base --is-ancestor.serving_has.default_repo()falls back to the checkout that contains the script.rate_limited_log_weight: 10.Tests: 1,056 passed across 13 offline backend test files, 23 of them new. Each new test fails on the old code.
actionlintwas not re-run.(The 0555a10 hash table is superseded by the head table above.)
Review fixes at 01df1d2 (Luna's two P1s)
verify_backend_release_floor.py --revision, which trusts theOMI_BACKEND_RELEASE_SHAenv stamp. It describes the revision, resolves the pinned image digest to its source commit throughserving_has.image_source(OCI revision label or commit tags), then runsverify_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.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.pyis 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.ymlis clean.