Repository navigation
feat(backend): host bounded jobstore retirement in serving maintenance - #25630
Conversation
Failure-Class: none
Failure-Class: none
Failure-Class: none
Failure-Class: none
Codex Review Summary: ❌ FailedThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…ions Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, align tests Retirement on backend-integration needs the production context check to pass on a Cloud Run service that does not set OMI_FIRESTORE_DATA_PLANE_PROJECT; a present value must still name based-hardware. Cursor statements no longer build SQL with f-strings. Page ValueErrors are reported as operation failures. Strict mock assertions now expect the new retire_copies/supervised/request arguments; review findings F1-F3 and F6-F8 from panel review-20261117t191629-b508. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ent deploy test The pure-Python loader took 1.05s CPU on CI, over the fast-unit guard. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Primary-source pages read Firestore; schedule them only when the production mirror is configured and shadow mode and shadow writes are on. Page errors log the exception type and SQLSTATE, never values. A future cursor timestamp reports unknown (NaN) lag. The statement floor admits a one-row page. Review review-20261117t201455-d221 F1-F3, F6, F7. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Status at Deploy ordering (do not deploy before this): with
Mirror and index reads stay off in this PR ( |
|
Deploy gate met (2026-11-18T06:16Z): backend-listen-runtime@ now has roles/cloudsql.client + instanceUser, an IAM DB user on prod-jobs, and full DML on all 6 jobstore tables plus default privileges (read back as the owner batch-pipeline-worker@). After merge, migration 0010 must be applied as batch-pipeline-worker@ so the default privileges cover the new cursor table. Remaining before merge: batch-custody lane owner ack; merge by the release owner. |
# Conflicts: # backend/deploy/runtime_env.yaml # backend/deploy/runtime_env/prod.overlay.yaml
…rsor remediation 0010 adds (namespace, key COLLATE "C") indexes on jobs, results and control and (namespace, tbl, key COLLATE "C") on docs, matching reconcile._copy_keys order. The stuck-cursor comment no longer claims automatic clearing; the mirror doc gives the operator step. Review review-20261118t064740-ffd1 F1, F3. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # backend/deploy/runtime_env.yaml # backend/deploy/runtime_env/prod.overlay.yaml
Panel review-20261118t200019-ac88 F1: the cursor table's tbl CHECK is an independent copy of MIRRORED_TABLES; a mirrored table added in Python without a migration would make that scope's cursor INSERT fail. Parse the CHECK from the migration and require set equality. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # backend/deploy/runtime_env/prod.overlay.yaml
|
TRIAGE review-20261118t204901-23ff (exact head 86b03f3): SHIP (luna + glm-flash). Deferred follow-ups, none change behaviour while retirement is unconfigured in prod: F1 stable metric labels for schema/config refusal reasons; F2 tests pinning INVALID_CONFIG vs OPERATION_FAILED per refusal gate and a ValueError page case; F3 treat the post-commit deadline check as advisory so a committed page is not reported as timeout; F4 share the 20 s interval floor as a named constant. Earlier panel review-20261118t200019-ac88 F1 (0010 tbl CHECK == MIRRORED_TABLES) is fixed in db8cdd0. |
|
Correction to the triage comment for review-20261118t204901-23ff: retirement is not inert after this PR. It configures the PG target, the prod worker matches the production context, and |
# Conflicts: # backend/scripts/verify_pusher_cohost_env_diff.py
…d-integration (#25744) ## Summary Stage the #25630 roll with jobstore copy retirement off. This sets `JOBSTORE_RETIREMENT_ENABLED=off` on the **backend-integration** Cloud Run service only. That is the one prod service where retirement ticks run (`BATCH_PIPELINE_SERVING_ENABLED=true`). Why: #25630 (merged f159cce) adds the jobstore PG target env to all four Cloud Run services. With the target set, retirement defaults on, so a roll before migration 0010 would tick `schema_missing` on backend-integration. lead2 holds the roll (b592a8) and ruled this staging delta (a392ec). It lets the roll carry no retirement work. Release applies and reads back 0010 inside the canary. A separate later config step removes this line. Unchanged: the PG target, mode `firestore`, mirror `off`, and erasure. `purge_jobstore_owner` still reaches the target, because erasure does not read this switch. ## Rendered role-env diff (prod, `render_backend_runtime_env.py --env prod`, origin/main 7c7b491 vs this head) ``` backend_integration_env_vars + JOBSTORE_RETIREMENT_ENABLED=off ``` No other service, secret, flag or identity output changes. The entry uses `category: ops_kill`, matching the flag's lifecycle. Staging composes the prod overlay before its own, so the staging overlay pins `JOBSTORE_RETIREMENT_ENABLED: 'on'` in `env_all`. Staging keeps its current default behavior (panel review-20261119t021451-a721 F2). ## Rollback Revert this PR, or delete the one overlay line. Retirement then returns to default on. ## Product invariants affected - INV-MEM-4: path match only (`runtime_env.yaml`). The change adds one jobstore retirement switch on backend-integration and touches no memory intake, promotion or projection behavior. ## Checks - `compose_runtime_env.py --check`: up to date. `check_runtime_env_compose.sh`: OK. - `check_feature_flag_registry.py`: OK (registry re-rendered). - Deploy contract: `test_prod_retirement_stays_off_on_the_serving_leader_until_0010_readback` pins the staged value (delete it with the overlay line). - Unit tests: 961 passed, 3 skipped across 22 files, including staging and compose. Files include: render_backend_runtime_env, check_cloud_run_env_drift, runtime_env_sources, runtime_env_manifest_compat, backend_runtime_env_validator, jobstore_retirement{,_cursor,_deploy}, cross_service_deploy_contract, jobstore_production_copy, jobstore_shadow_seams. Not a roll GO. Release on SCA-2283 admits the runtime. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…off on backend-integration Sets JOBSTORE_RETIREMENT_ENABLED=off on backend-integration only, so the roll carries no copy-retirement ticks before migration 0010 is read back (lead2 a392ec). Target, mode, mirror and erasure unchanged. Re-enable by deleting the overlay line in a separate config step. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
The revert of #25630 also removed 172.25.29.2/32 from PROD_NETWORKS and its regression cases. The instance still exists and staging still configures the job-store shadow path, so staging must keep refusing that address. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… so trains from main are clean (#25778) ## What Reverts two merged, not-yet-serving changes: - #25744 `deploy(jobstore): stage the #25630 roll with retirement off on backend-integration` - #25630 jobstore retained-copy retirement, migration `0010_retirement_cursor.sql`, and the Postgres target env on all four Cloud Run services and the listen and worker charts Both are plain `git revert -m 1` of the merge commits (`d5329c70597d`, `f159cceccac0`). They applied with no conflicts, and no reference to the removed modules, env keys or migration remains on the branch. One deliberate deviation from a pure revert (commit `214a8955`): the `prod-jobs` private address `172.25.29.2/32` stays in the staging isolation fence (`PROD_NETWORKS`) with its regression cases. The instance still exists and staging still configures the job-store shadow path, so staging must keep refusing that address. Found by the panel review. ## Why David paused the Postgres job-store port on 2026-11-19 (Multica SCA-1959). With #25630 on main, every Cloud Run train from main adds the `JOBSTORE_*` target env. That makes account and conversation erasure connect to the idle `prod-jobs` instance before `finish_privacy_purge`, so a Postgres outage would make purges raise and retry, for no benefit while the port is paused. lead2 holds all trains for that reason (b592a8), which also blocks the conversations v3 Cloud Run trains. After this revert, the files these two PRs touched carry no jobstore target env, and a train from main no longer changes erasure. ## Risk and rollback - Nothing here is serving, so no running behaviour changes. Serving is still the `a6824b8` revisions. - Migration 0010 was never applied in prod (ledger is 1..8) and the copy tables were empty at the last count (2026-11-19 01:15:53Z), so no data depends on the removed code. - Rollback: revert this PR. ## Product invariants affected - INV-MEM-4: the change set touches a path under this invariant's globs only because it restores that file to its pre-#25630 content. No memory-promotion behaviour changes. ## Verification - CI green on `214a8955` (64 checks, 0 failed). - Panel reviews `review-20261119t104759-a779` (one major, fixed) and `review-20261119t112157-f094` (minor and nit findings, triaged). - Pre-push preflight on this branch. - `git grep` for `retirement_cursor`, `jobstore.retirement`, `JOBSTORE_RETIREMENT`, `0010_retirement`, `JOBSTORE_PG_HOST` in prod overlays and charts: no matches. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…irement off on backend-integration (BasedHardware#25744)" This reverts commit d5329c7, reversing changes made to 1bdf17c.
…intenance (BasedHardware#25630)" This reverts commit f159cce, reversing changes made to a6824b8.
Summary
Run retained jobstore-copy retirement from the existing Cloud Run backend-integration Serving supervisor. Migration 0010 stores target-bound cursors in Postgres; page mutations and locked version/cursor compare-and-set advancement commit together. One table/source runs per bounded round-robin tick after critical maintenance, with a kill switch, shared normal pool, and counts-only retirement/rotation telemetry.
Prepare the production target/context on the retirement host and every source deletion executor: Cloud Run backend, backend-sync, backend-sync-backfill and backend-integration; GKE backend-listen uses its own backend-listen-runtime DB principal. The GPU batch-pipeline-worker target uses batch-pipeline-worker, but that process runs Pump, not Serving. Staging retains its own post-render bindings without duplicate env names. The co-host env-diff guard documents the production erasure bindings as listen-only: pusher mounts no deletion routes or jobstore purge caller. The production-mirror doc contains the exact caller/deploy inventory and CLI fallback.
Activation and rollback
Copy and recovery-hint activation remain off by default: JOBSTORE_PRODUCTION_MIRROR=off and BATCH_JOBSTORE_MODE=firestore. Retirement defaults on only with a complete PG target and valid data-plane context; it remains independent of copy kills. Mode-off cohort exclusion can retire all retained copies during rotation. Primary backfill requires the production mirror configuration. Missing migration 0010 skips safely with a metric; no boot migration occurs.
Release must apply/verify the schema and runtime DML grants separately, verify actual executor identities/routing and mode-off erasure, measure a complete rotation/lag and fleet connection budget, then approve mirror and hint policy cohorts. In particular, verify the backend-listen-runtime SQL user/grants. No production data/API access, GCP tier, IAM change, gcloud write, deploy or merge was performed.
Rollback retirement with JOBSTORE_RETIREMENT_ENABLED=off; retain JOBSTORE_PG_* and synchronous erasure until copies retire. The fallback reconcile-page CLI keeps private checkpoints. The parked operator track and PRs #25613/#25215 are unchanged.
Budgets and state exits
Initial JOBSTORE_RETIREMENT_MAX_ROWS=10, MAX_PRIMARY_READS=20, MAX_STATEMENTS=500, PAGE_SECONDS=3, INTERVAL_SECONDS=20; total tick budget is 10 seconds. Before: no in-serving rotation or durable PG cursor. After: one bounded table/source per supervised leader tick, with normal-pool warmup outside the page budget and inside the total allowance. Maximum page time is 3 seconds, well below the 60-second advisory maintenance lease. Two normal sessions plus the existing reserved erasure session remain the per-process ceiling; the erasure connector retains its existing setup behavior.
The new cursor's terminal path is end-of-pass reset to NULL plus passes/version increments and rotation_completed_at in the page transaction. Errors roll back page and checkpoint. A failed table rotates out so it cannot starve other tables. Rows are retired only after a fresh authoritative absence/cohort exclusion, never by a clock/lease TTL. Rotation lag is current time minus cursor last-pass completion (creation before first pass), computed from bounded cursor-row observations without copy-table scans.
Product invariants affected
INV-MEM-4: canonical memory admission/promotion authority is unchanged; the bounded copy and retirement worker never writes Firestore documents or promotes canonical memory. Firestore remains the sole job writer/claimant and privacy authority; no customer-facing wire contract changes.
Verification
All tests and type checks run through /Users/dazheng/workspace/omi/bin/omi-heavy with GOOGLE_APPLICATION_CREDENTIALS and CLOUDSDK_* unset. Local Postgres uses a disposable Unix-socket test cluster and a synthetic primary.
Representative exact commands (all wrapped in omi-heavy; paths from the task worktree):
Failure-Class: none
This is a new maintenance/configuration capability, with no incident failure class claimed.
🤖 Generated with Claude Code