Repository navigation
legacy-retire lane 10 slice 2b: legacy-dark fence at the legacy call sites - #22495
Conversation
…-local-files 410 (lane 10 slice 2b) routers/sync.py: no legacy job outside on (fence for legacy-owned content, 409 retry-later otherwise), legacy-fresh skipped, sequencer registration and pre-sequencer migration only at on, dark sweep stops claims but keeps enrichment and summary-debt repair, dark wake 200. uid_sequencer: kick/sweep inert in dark. /v1/sync-local-files returns 410 (7-day census: zero calls); its v1-only tests are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # backend/utils/sync/uid_sequencer.py
# Conflicts: # config/feature-flags.yaml
… 410 in slice 2b Co-Authored-By: Claude Opus 5.5 <[email protected]>
…te is 410) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lr/10-slice2b # Conflicts: # config/feature-flags.yaml
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n def Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…listed like test_sync_cloud_tasks 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: 3336bc2851
ℹ️ 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".
| client_device_context.client_device_id, | ||
| snapshot_out=record_snapshot, | ||
| ) | ||
| legacy_mode = legacy_dark.current_mode() |
There was a problem hiding this comment.
Await the initial legacy-mode read before admitting
On a cold Cloud Run instance while the ramp is draining or dark, this call runs on the event loop, where _RampCache.snapshot() deliberately starts a refresh without waiting and immediately serves the default on. The first upload on each new instance can therefore pass legacy_allowed and create a legacy job—particularly when batch intake is disabled or a record is legacy-owned—so autoscaling can repeatedly bypass the kill switch. Read current_mode through await run_blocking(db_executor, ...) as batch intake does, or explicitly await the ramp warm-up before evaluating it.
AGENTS.md reference: backend/AGENTS.md:L263-L272
Useful? React with 👍 / 👎.
| try: | ||
| # Imported per call (a cached module lookup): router test harnesses replace | ||
| # ``utils`` wholesale, and a missing reader must serve ``on``, not fail import. | ||
| from utils.rollout import runtime_percent |
There was a problem hiding this comment.
Keep the rollout import at module scope
Move this import back to module scope and update the router test harness to stub the real dependency instead. The new per-call import explicitly violates the backend import convention, hides the production dependency to accommodate test-module replacement, and makes import/source-closure analysis less reliable.
AGENTS.md reference: backend/AGENTS.md:L161-L169
Useful? React with 👍 / 👎.
| await run_blocking(sync_executor, _cleanup_files, paths) | ||
| await run_blocking(sync_executor, shutil.rmtree, job_dir, True) | ||
| return ( | ||
| legacy_dark.fence_response(decision, total_files=len(files), lane=lane_decision.lane.value) |
There was a problem hiding this comment.
Return completed ledger hits through a terminal client contract
When this new fence call classifies a legacy row as completed or held, fence_response returns HTTP 202 with the old legacy job_id, but both shipped Flutter and macOS upload clients treat every 202 as queued and ignore the response's status: completed. Because the ledger lasts 45 days while Redis jobs last 24 hours, an older completed hit sends clients to poll an expired job, revert the WAL after 404, and upload it again indefinitely. Return the existing HTTP 200 completed-result shape or materialize a pollable completed job instead of exposing the stale legacy ID.
Useful? React with 👍 / 👎.
| await run_blocking(sync_executor, shutil.rmtree, job_dir, True) | ||
| return ( | ||
| legacy_dark.fence_response(decision, total_files=len(files), lane=lane_decision.lane.value) | ||
| or legacy_dark.admission_refused_response() |
There was a problem hiding this comment.
Use a retry response that shipped clients actually throttle
When draining or dark mode reaches this refusal fallback, the response is a 409 sync_content_retry_later with Retry-After, but neither shipped upload client recognizes that code: Flutter treats it as a generic SyncUploadHttpException, while macOS treats every 409 as an ordinary upload failure. Consequently clients retain but repeatedly re-upload the same bytes without honoring the 60-second backoff, depressing the rollout's upload-success SLO and potentially creating a retry storm exactly when the batch route is unavailable. Use an already-supported response contract or deploy client handling before activating this branch.
Useful? React with 👍 / 👎.
| # Legacy-dark (contract (h)): never create a legacy job. Content legacy | ||
| # already owns is answered by the fence; anything else keeps its audio. | ||
| ledger_row = await run_blocking(db_executor, legacy_dark.read_ledger_row, uid, content_id) | ||
| decision = legacy_dark.fence_decision(ledger_row, legacy_mode) |
There was a problem hiding this comment.
Verify that an active ledger owner still has a Redis job
For a fallback upload whose ledger row says processing, this call omits owner_job_present, so fence_decision classifies every claim younger than 48 hours as active even when its Redis job has already expired after 24 hours or was deleted. The route then returns sync_content_in_progress with a nonexistent job ID; shipped clients poll it, confirm 404, re-upload, and receive the same dead owner until the ledger becomes stale. Read the referenced job and pass its presence into the fence so missing owners take the stranded/recovery path.
Useful? React with 👍 / 👎.
| return batch_response | ||
| sequencer_registration_started = False | ||
|
|
||
| if not legacy_allowed: |
There was a problem hiding this comment.
Resolve legacy record owners instead of permanently refusing them
In draining or dark mode, a conversation stamped record_lane_owner == 'legacy_final_pass_v1' makes registered_record_response return LEGACY, so batch intake is skipped and this new branch looks only for a sync ledger row keyed by the uploaded WAL hash. A legacy live final pass cannot have that upload-derived key before the first upload, while the owner marker is preserved on subsequent conversation writes, so the decision remains unowned and every retry is refused forever even after the final pass finishes. Acknowledge covered/completed legacy-record audio from its durable conversation state or provide an ownership migration path before disabling legacy admission.
Useful? React with 👍 / 👎.
…oves to the C6 deletion PR (lead ruling (a)) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
## 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)
Summary
Lane 10, slice 2b: wires the legacy-dark switch (contract (h)) into the legacy call sites. The
/v1/sync-local-filesretirement moved to the draft deletion PRlr/10-delete-v1(lead ruling (a), 10-19). Atlegacy_sync=onthe behaviour is unchanged. The_rampdoc does not exist in prod, so lane 6's reader serveson, and any read failure also serveson.routers/sync.py, v2 upload, outsideon:completed;sync_content_in_progressthat tells the client to follow the owner's job;Retry-After.omi_legacy_sync_admissions_total{reason}counts every legacy job still created aton.Sequencer:
on.dark, the sweep stops claiming and dispatching. Enrichment repair (reprocess.sweep) andsummary_debt_repair.tickkeep running until C4 moves them (lead ruling 10-19).dark, the wake returns 200legacy_dark.uid_sequencer.kickanduid_sequencer.sweepdo nothing indark.Lane / contract
Lane 10, contract (h), consuming (f)
legacy_sync_mode. Owner sign-offs: therouters/sync.pyanduid_sequencer.pyedits are lane 10's (swarm plan §3; they were held until #21932 and #22452 merged).Product invariants affected
routers/sync.pyis in its path set. This diff changes no production data-plane routing authority (project, database or bucket selection), only legacy admission and sequencer gating.Verification
Unit layer:
test_legacy_dark.py(43) andtest_legacy_dark_router.py(6 router-wiring tests through the shared fast-path harness; allowlisted for the fast-unit CPU guard liketest_sync_cloud_tasks.py);test_sync_cloud_tasks.py(186),test_sync_v2.py(182),test_sync_backfill_uid_sequencer.py(117),test_stt_cap_dispatch_http.py,test_sync_record_usage.py,test_sync_local_files_async.py,test_sync_fair_use_gate.py,test_sync_silent_failure.py,test_sync_transcription_prefs.py,test_multipart_limits.py,test_background_task_ratchet.py. All v1 tests are unchanged from integration.test_task_target_retry_semantics.py(5) andtest_cross_service_deploy_contract.py(18) pass against integrationf482aa3b, which has lane 1's known-gaps update.Not run locally: the full suite, which CI runs. Staging comes at M2: the on→draining→dark→on cycle under replay.
Rollback
Revert. Runtime rollback needs no deploy:
ramp_set.py --legacy-sync on, which takes effect within 30s.Line-Count-Exception: backend/routers/sync.py | 3820 -> 3857 | legacy-dark fence wiring at the call sites (contract h); the C9/C10/C11 deletion PRs remove ~2.5k lines from this file
Failure-Class: none
🤖 Generated with Claude Code