Repository navigation
feat(deploy): lane 7 slice 1: ops file + config-train (B4), prod-train lock (B5), worker digest promotion, OMI_ROLE map (B8) - #22430
Conversation
…ease-tree check
B4: backend/deploy/ops/{prod,staging}.yaml hold the ops-owned values the
trains must not touch: the sync-jobs-fresh / sync-backfill-fresh re-points
from the 10-18 and 10-19 queue stalls, recovery queue 16/8, the fresh queues'
rates and retries, and service-level scaling (backfill as bounds only while
redis_guard owns it). backend/scripts/ops_train.py plans against the serving
revision (status.traffic, never spec.template), refuses when the template
differs from the serving revision outside ops keys, routes every env change to
its new named revision explicitly (backend-sync-backfill pins traffic) and
verifies it serves. config_train.yml runs plan/apply behind the prod approval
gate. Live ro-prod plan of the Cloud Run half is zero-diff.
B5: every prod deploy writer (backend, listen, LLM gateway, pusher, diarizer
/batch worker, parakeet, config-train) takes the prod-train concurrency group;
break_glass_lock falls back to the pre-B5 per-target lock. The deployment
concurrency policy evaluates the group expressions and enforces both.
backend/scripts/prod_train_lock.py reads the lock from active runs plus their
deployment environment for the ramp controller (fail closed on unknown).
Promotion identity (contract (i)): check_release_tree.py asserts the main merge
tree equals the staging-qualified OMI_RELEASE_TREE read from serving revisions.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (B7) gcp_diarizer.yml labels every image with org.opencontainers.image.revision and omi.release.tree, and accepts image_digest for batch-pipeline-worker: an already-built registry digest deploys without the 4.7 GB rebuild only when check_release_tree.py image confirms its tree equals the admitted source tree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
app_roles.py lists every router in today's mount order with its roles (api, workers, realtime; default all is behaviour-neutral). The census test pins the all role to main.py's include order, requires every TaskEdge and backend Scheduler target to be mounted by workers and every websocket router by realtime. main.py switches to mount_routers once #22388's main.py edit reaches integration (frozen until then). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2b1dade8c
ℹ️ 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".
| for key in ('image', 'command', 'args', 'resources'): | ||
| if _digest(a.get(key)) != _digest(b.get(key)): | ||
| drift.append(f'{name}.{key}') | ||
| env_a = {k: v for k, v in _env_map(a).items() if k not in ops_keys} | ||
| env_b = {k: v for k, v in _env_map(b).items() if k not in ops_keys} | ||
| for key in sorted(set(env_a) | set(env_b)): | ||
| if _digest(env_a.get(key)) != _digest(env_b.get(key)): | ||
| drift.append(f'{name}.env.{key}') |
There was a problem hiding this comment.
Compare the full revision template before promoting
When a failed no-traffic deployment changes a revision-level field outside this small allowlist—such as serviceAccountName, timeoutSeconds, volumes, probes, or VPC/execution annotations—template_drift reports no blocker. A subsequent ops env change therefore creates a revision from that unqualified template and routes 100% traffic to it, defeating the config train's stated safety boundary. Compare the complete template and revision metadata/spec after removing only the explicitly ops-owned env keys.
Useful? React with 👍 / 👎.
| args.append('--update-env-vars=' + ','.join(f'{k}={v}' for k, v in sorted(full.items()))) | ||
| args.append(f'--revision-suffix={revision_suffix}') |
There was a problem hiding this comment.
Create config revisions with no traffic
When a managed service currently routes traffic via latestRevision: true, this update creates the config revision without --no-traffic, so Cloud Run can move traffic to it during this command, before the explicit update-traffic call and final verification. If the workflow is interrupted afterward, the new revision remains live despite the config train failing. Cloud Run documents that subsequent deployments retain the current traffic pattern and recommends --no-traffic for staged revisions in its traffic rollout guidance; add that flag before the explicit promotion.
Useful? React with 👍 / 👎.
| value = int(value) | ||
| flags.append(f'{QUEUE_FIELDS[key][2]}={value}') |
There was a problem hiding this comment.
Pass numeric -1 for unlimited Cloud Tasks attempts
Applying staging, where staging-enrichment is enabled with max_attempts: -1, rewrites the value to the literal --max-attempts=unlimited. The gcloud command defines this as a numeric MAX_ATTEMPTS argument, while the Cloud Tasks RetryConfig specifies numeric -1 as unlimited (gcloud reference, API reference); the literal is rejected, potentially after earlier plan mutations have already succeeded. Emit --max-attempts=-1 instead.
Useful? React with 👍 / 👎.
| for run in payload.get('workflow_runs') or []: | ||
| # Prod is reachable only through workflow_dispatch (environment input); push and | ||
| # workflow_run entry points always target development. | ||
| if run.get('path') in PROD_TRAIN_WORKFLOWS and run.get('event') == 'workflow_dispatch': |
There was a problem hiding this comment.
Normalize workflow paths before matching lock holders
GitHub's workflow-runs response can include the workflow ref in path—for example, the official response schema shows .github/workflows/build.yml@main—but this membership test compares it directly with bare .yml paths (GitHub workflow-runs API). Such active runs are discarded, allowing read_status to return FREE while the prod-train group is actually held, so the ramp controller can mutate production concurrently. Strip the @... suffix or match by workflow ID.
Useful? React with 👍 / 👎.
| # B5: every prod deploy writer shares one prod-train lock. Break-glass falls back to | ||
| # this workflow's own target lock so an urgent ops fix never waits behind a train. | ||
| concurrency: | ||
| group: ${{ github.event.inputs.environment == 'prod' && github.event.inputs.break_glass_lock != 'true' && 'prod-train' || format('config-train-{0}', github.event.inputs.environment) }} |
There was a problem hiding this comment.
Keep read-only plans out of the prod mutation queue
When a production mutation is running and another deploy is pending, dispatching the default mode=plan workflow joins the same prod-train group even though it is read-only; GitHub retains only one pending run, so the plan can cancel and replace the queued deployment. Restrict the shared group to mode=apply and give plans a separate read-only group so routine inspection cannot silently discard production work.
AGENTS.md reference: .github/AGENTS.md:L19-L21
Useful? React with 👍 / 👎.
… (shrink-only) Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 298bacfdfd
ℹ️ 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".
|
|
||
| runs: dict[int, Mapping[str, Any]] = {} | ||
| for state in ACTIVE_RUN_STATES: | ||
| payload = api(f'/repos/{REPO}/actions/runs', {'status': state, 'per_page': 100}) or {} |
There was a problem hiding this comment.
Paginate active workflow runs before declaring the lock free
When more than 100 repository runs share an active status, this query examines only the first page. If an older prod-train holder falls beyond those 100 runs and no holder appears on the first page, runs remains empty and read_status reports FREE, allowing the ramp controller to mutate production concurrently. Follow the pagination links/pages, or query each audited workflow directly, before concluding that no holder exists.
Useful? React with 👍 / 👎.
| applied.append(f'cloud_run/{name}') | ||
| if env: | ||
| revision = f'{name}-{revision_suffix}' | ||
| gcloud.run(['run', 'services', 'update-traffic', name, *_location(spec), f'--to-revisions={revision}=100']) |
There was a problem hiding this comment.
Configure queues before routing services to them
When one plan both re-points a service's queue environment variable and creates or updates that target queue, this sends 100% traffic to the new revision before the queue mutations that begin later in apply_plan. The service can therefore enqueue against a missing or incorrectly throttled queue, and if the subsequent queue command fails it remains permanently routed to that bad state. Apply and verify queue changes before promoting any service revisions.
Useful? React with 👍 / 👎.
| # Break-glass keeps the pre-B5 per-target lock. Development groups are unchanged. | ||
| concurrency: | ||
| group: deploy-backend-stack-${{ github.event.inputs.environment }} | ||
| group: ${{ github.event.inputs.environment == 'prod' && github.event.inputs.break_glass_lock != 'true' && 'prod-train' || format('deploy-backend-stack-{0}', github.event.inputs.environment) }} |
There was a problem hiding this comment.
Keep break-glass runs serialized with their target
When an ordinary production backend deployment is already running in prod-train, a second dispatch with break_glass_lock=true resolves to deploy-backend-stack-prod; because these are different concurrency groups, GitHub can run both against the same Cloud Run, Helm, traffic, and secrets targets at once. Falling back to the old per-target name therefore does not provide the promised target serialization unless ordinary runs also participate in that mutex; use a separate target lock or otherwise prevent same-target overlap.
AGENTS.md reference: .github/AGENTS.md:L7-L10
Useful? React with 👍 / 👎.
## Summary M3: land the legacy-sync retirement integration branch (`integration/legacy-retire`, swarm plan `omi-knowledge-base/projects/backend-target-architecture/swarm-plan.md`, contracts in `contracts.md`) on main. **Merge with `--merge` (never squash)**; the lead runs the train from the main merge SHA. **Prod behaviour after this merge:** prod `legacy_sync` stays `on`. Every new legacy-retirement path is gated: the ramp document, default-off flags or kill switches, and the `DRAINING_PRECONDITIONS` that `ramp_set` enforces before leaving `on`. With the mode `on`, intake, sync and enrichment keep today's routes. ## M3 gates (lead ruling 6702cc; David authorized the merge, 10-21) 1. **Prep landed:** - #23068: main b859b78, the ci-budget bump and the dead-code stub removal; - review fixes #23082 and #23086; - final main merges #23096 (main 34ce402) and #23133 (main 5406315). 2. **Staging tree equality:** `OMI_RELEASE_TREE` on all four `*-staging` services equals `integration/legacy-retire^{tree}` at this head (see the evidence section below). 3. **M2 review (GLM, which replaced Grok; ruling 43bd53):** - CHANGES: 1 P1, fixed in #23082 (provider-STT outbox sweep plus draining gates). - The 2 P2s are recorded below. - The M1 blocker closure table is in `data/run-2026-10-19-legacy-retire/review/M3/m1-blocker-closure.md` (omi-workspace). 4. **Workflows:** all green on this head. 5. **Luna:** - Round 1: CHANGES, 2 majors, fixed in #23082. - Round 2: 4 majors. Two lock fixes are in #23086 (Luna SHIP); two were routed to dark-step gates. - Final-merge resolution: SHIP. ## Dark-step gates and follow-ups (none block M3; prod stays `on`) - **`provider_stt_live`** (`DRAINING_PRECONDITIONS`): before leaving `on`, prod needs: - the provider-stt queue; - the `PROVIDER_STT_TASKS_*` env; - the maintenance job; - pagination or a due-cursor for the provider-STT outbox sweep (Luna round 2 #4). - **`legacy_final_pass_rehomed`** (`DRAINING_PRECONDITIONS`, lead ruling b209a5): conversations still owned by `legacy_final_pass_v1` with no live legacy job must be re-homed to batch first, and new final-pass ownership must stop outside `on` (Luna round 2 #3). The final-pass-rehome lane owns this. - **GLM P2s:** - the router's stranded-row 409 loop without `batch_adopts_stranded` is lane 10 debt; - BYOK uploads route to batch even with legacy sync `on` (David, 10-19). This is a release-note item. ## `.github` changes in this PR and David's naming Source of the naming: swarm-plan.md, lane 7: "B4 and B5 are named .github changes (fourth round, #9)" (2026-10-19); the checkout-stall bound (2026-10-20, main 1b07e5e); #22758 build-only mode; lead ruling 209335 (David named B7 and B8 items, 2026-10-21 ~06:05Z). | File | Change | Named item | | --- | --- | --- | | `.github/workflows/config_train.yml` (new) | Config-train: plan/apply of `backend/deploy/ops`, manual dispatch, prod-train lock; workflow-level `GIT_HTTP_LOW_SPEED_*` | B4 (+ checkout-stall bound for the two env lines) | | `.github/actions/sync-backfill-lifecycle/action.yml` | Prod backfill queue names come from the ops file; the train no longer reconciles the prod queue (#22455, #22480) | B4 | | `.github/workflows/gcp_backend.yml` | `break_glass_lock` input; prod concurrency group `prod-train` | B5 | | `.github/workflows/gcp_backend_listen_helm.yml` | same | B5 | | `.github/workflows/gcp_backend_pusher.yml` | same | B5 | | `.github/workflows/gcp_parakeet.yml` | same | B5 | | `.github/workflows/gcp_llm_gateway.yml` | same (every prod deploy writer shares the lock) | B5 | | `.github/workflows/gcp_diarizer.yml` | B5 lock lines **plus** B7: OCI revision/`omi.release.tree` image labels and a batch-worker `image_digest` promotion path (verified by `check_release_tree.py`) | B5; B7 (David, ruling 209335) | | `.github/scripts/check-deployment-concurrency.py` | Guard that evaluates the new prod-train group expressions | B5 | | `.github/ci-budget.yaml` | config-train entry (B4); 1 run/day on the six deploy workflows with `break_glass_lock` (B5); 1.1/day on three build-only jobs (sync 11, #22758 base) | B4, B5, #22758 | | `.github/checks-manifest.yaml` | Registers `backend/scripts/check_release_tree.py` (the B7 promotion gate) | B7 (David, ruling 209335) | | `.github/scripts/check_duplicate_routes.py` | Counts routers mounted through `app_roles.mount_routers` (B8 OMI_ROLE map) as mounted | B8 (David, ruling 209335) | | `.github/scripts/test_pre_push_ci_verified.py` | Test hygiene: `clean_env` also pops `PRE_PUSH_BASE_BRANCH` and `OMI_PR_BODY_FILE`, so lane pushes with a non-main base do not leak into the hermetic hook runs | lead authority, ruling 66dba9 (edits an existing test script; no workflow added) | | `.github/scripts/dead_code/backend.allowlist.json` | The 7 swarm contract-stub entries are removed (L01-4); every file now has importers | allowlist hygiene (CI script data) | | `.github/workflows/sync_ledger_fence_cutover.yml` | Prod takes the `prod-train` lock, with a `break_glass_lock` input that falls back to the backend stack lock (M3 Luna review) | B5, completing it on a file that must share the backend mutation domain (lead ruling 5f60b3) | | `.github/workflows/config_train.yml` (break-glass fallback) | Break-glass shares `deploy-backend-stack-<env>` with `gcp_backend.yml` (M3 Luna review) | B4/B5 (lead ruling 5f60b3) | ## Staging tree evidence Verified 23:33-23:4xZ 10-21, on tier ro-dev: - **Services:** all four `*-staging` services (`backend-staging`, `backend-sync-staging`, `backend-sync-backfill-staging`, `backend-integration-staging`) serve `8d062ad3cfacf8b7eb26dea737a2969423548e64` at 100%. - **Tree:** `OMI_RELEASE_TREE=5c398832bc4487066abbf2d49bcf8c6f9a700818` == `8d062ad3^{tree}`. - **Image:** `us-central1-docker.pkg.dev/based-hardware-dev/staging/backend@sha256:18b8cf414566743aaee20bd2559695ec7b4536a75ec609fbc139f008bbf7ecf9`. - **Batch worker:** `sha256:0954c71c87f5`, 0 replicas. Staging is plain (no warm instances or overrides). - **Deploy log:** `data/run-2026-10-19-legacy-retire/lane01/m3/deploy-final2.log` (omi-workspace). ## Product invariants affected INV-DATA-1: integration carries lane 7's (#22430) edits to `.github/workflows/gcp_*.yml`. They add the `prod-train` concurrency/lock lines (B5) and, in `gcp_diarizer.yml`, the worker-digest promotion. No Firebase or Firestore project, auth authority or serving endpoint changes. Production-family artifacts stay on `based-hardware`. ## Line-count exceptions Line-Count-Exception: backend/routers/sync.py | 3881 -> 3966 | lane 10 legacy-dark fence wiring at the legacy call sites (#22495) plus the M3 review fixes (off-loop mode read, final-pass ACK); the file shrinks with the C6/C11 deletions Line-Count-Exception: backend/database/firestore_index_registry.py | 2196 -> 2200 | the legacy-dark zero-lost census index (sync_content_ledger created_at, lost_recordings.py soak check 5) ## Failure class Integration carries fix commits, and each declares its own class. For this merge: Failure-Class: none UI-Evidence: none -- backend/CI retirement work plus sync merges; the UI changes are main PRs that carried their own evidence 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Lane 7 slice 1 (legacy-retire swarm): B4 ops file + config-train, B5 prod-train lock, promotion tree check. Targets
integration/legacy-retire.What
B4: ops file and config-train (named
.githubchange, David 2026-10-19 fourth round #9)backend/deploy/ops/prod.yamlandstaging.yamlhold the values the trains must not touch:SYNC_TASKS_QUEUE=sync-jobs-fresh(10-18 18:59Z) on backend-sync and backend-integration;SYNC_BACKFILL_TASKS_QUEUE/ backfillSYNC_TASKS_QUEUE=sync-backfill-fresh(10-19 04:52Z);sync-jobs-fresh(160, 25/s, 10 attempts, 60–300s) andsync-backfill-fresh(90, 15/s, 5–60s) queue specs;redis_guard.showns the value until C10.enrichmentqueue declaredenabled: falseuntil M3.backend/scripts/ops_train.py validate|plan|apply|render-env:status.traffic, neverspec.template(10-18 23:48Z non-serving revision);--revision-suffix) and an explicitupdate-traffic --to-revisions=<rev>=100(backend-sync-backfill pins traffic, 04:52Z), then re-plans and requires zero diff with the new revision serving;.github/workflows/config_train.yml: dispatch-only,plandefault, prod job on theprodapproval environment, prod source must be on main. No build.B5: prod-train lock (named
.githubchange)gcp_backend,gcp_backend_listen_helm,gcp_llm_gateway,gcp_backend_pusher,gcp_diarizer(diarizer + batch worker),gcp_parakeetandconfig_traintake concurrency groupprod-trainin prod. Development groups are unchanged.break_glass_lockinput falls back to the pre-B5 per-target group (still serialized on its own target)..github/scripts/check-deployment-concurrency.pynow evaluates the GitHub expression subset groups use and enforces: prod resolves toprod-train, break-glass resolves to the per-target lock, dev never takes it, no other workflow takes it.gcp_llm_gateway.ymlis included because it shareddeploy-backend-stack-prodwith backend/listen; leaving it out would have un-serialized it.backend/scripts/prod_train_lock.py statusreads the lock (active dispatch runs of those workflows whose deployment environment is prod; unknown env fails closed) for lane 6's ramp controller (contract (g)).Worker digest promotion + B7 image identity (prod train path, assigned by the lead)
gcp_diarizer.ymllabels every built image withorg.opencontainers.image.revisionandomi.release.tree.image_digestinput (batch-pipeline-worker only): skips the 4.7 GB rebuild and deploys an existing registry digest only aftercheck_release_tree.py imageconfirms its tree equals the admitted source tree. Unlabelled (pre-B7) images are refused.B8 role map (M1):
backend/app_roles.py(OMI_ROLE, defaultall, unknown value fails startup) lists every router in today's mount order with provisional roles.test_app_roles_route_census.pypinsallto main.py's include order, requires every TaskEdge and backend Scheduler target to be mounted byworkersand every websocket router byrealtime. main.py switches tomount_routersafter #22388's main.py edit reaches integration (frozen).Promotion identity (contract (i)):
backend/scripts/check_release_tree.py verify --sha <main-merge> --qualified-tree <t> | --from-stagingasserts tree equality, readingOMI_RELEASE_TREEfrom the staging serving revisions.Not in this PR (frozen until #22233 / #22388 reach integration): the train applying ops values (
render-env) insidedeploy-backend-stack/action.ymlandsync-backfill-lifecycle, removing the 4/4 and 90/15 literals,OMI_RELEASE_SHA/OMI_RELEASE_TREEon every Cloud Run service, and main.py mounting throughapp_roles.Verification
ops_train.py plan --env prodonro-prod(Cloud Run half): serving backend-integration-01088-zck, backend-sync-01258-q8n, backend-sync-backfill-00534-mwt, no changes. Queue half blocked by design on ro-prod (nocloudtasks.queues.list); the first CI plan reads it.prod_train_lock.py statusagainst live GitHub: FREE (a push-triggered dev listen run is correctly excluded).pytest tests/unit/test_config_train.py test_prod_train_lock.py test_check_release_tree.py test_llm_gateway_deploy_contract.py: 72 passed;test_check_release_tree.py test_batch_pipeline_chart.py: 27 passed;test_app_roles_route_census.py: 18 passed;test_workflow_contracts.py -k 'diarizer or firestore': 51 passed.dead-code-ratchet,feature-flag-registry,test_run_checks.py(manifest contract): pass.check-deployment-concurrency.py --self-testand full: OK (29 writers).actionlint -shellcheck ""on all touched workflows: clean.check_ci_budget.py: passed.Product invariants affected
.github/workflows/gcp_*.yml). The edits change only the workflow-level concurrency group and add a boolean dispatch input; no project, endpoint, authority or data plane changes.Rollback
Revert this PR. The config-train never ran in prod yet; reverting the group lines restores the per-target locks.
🤖 Generated with Claude Code