Skip to content

M3 review fixes: off-loop legacy mode, final-pass ACK, provider-STT sweep + draining gates - #23082

Merged
Git-on-my-level merged 2 commits into
integration/legacy-retirefrom
lr/01-m3-review-fixes
Oct 21, 2026
Merged

Git-on-my-level merged 2 commits into
integration/legacy-retirefrom
lr/01-m3-review-fixes

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

M3 review fixes for integration/legacy-retire: Luna found two majors and GLM (the M2 reviewer) one P1. The lead signed off the lane 10 file changes as acting owner (ruling b209a5).

Luna (M3 delta review):

  • routers/sync.py: sync_local_files_v2 now reads the legacy mode off the event loop, through run_blocking(db_executor, legacy_dark.current_mode), as batch intake does. The ramp cache never waits on the loop. Before this change, a cold instance served the on default until its first background read landed, so it could admit legacy work after the ramp moved to draining or dark. Absent documents and real read failures still serve on.
  • routers/sync.py: a conversation owned by legacy_final_pass_v1 with no content-ledger row now gets intake's ACK (LEGACY_ACTIVE, the shipped in-progress 409) instead of the admission-refused backstop, in draining and dark. No legacy job is created.

GLM M2 (P1):

  • routers/enrichment.py: maintain() also sweeps outbox_for(PROVIDER_STT). Intake swallows a lost post-commit wake and relies on that sweep, which had no caller. A sweep failure is counted and isolated from the enrichment and summary-debt halves.
  • scripts/rollout/ramp_controller.py: DRAINING_PRECONDITIONS adds provider_stt_live (the prod provider-stt queue, PROVIDER_STT_TASKS_* env and the maintenance job) and legacy_final_pass_rehomed (lead ruling b209a5). The runbook lists both. ramp_set cannot leave on until the operator confirms each. Prod stays on after M3, and in on intake never creates provider units.

GLM P2s, recorded in the M3 PR rather than fixed here:

  • BYOK uploads route to batch in on (David's 10-19 ruling).
  • The router's stranded-row 409 loop without batch_adopts_stranded. This is lane 10 follow-up debt.

Tests:

  • New: test_legacy_dark_router.py, 2 tests; test_enrichment_route.py, 1 new test and 1 updated; test_ramp_controller.py, now computed from the precondition set.
  • Green: the router, legacy-dark, sync v2/async/cloud-tasks, enrichment route, ramp controller and provider-STT tests.

Line-Count-Exception: backend/routers/sync.py | 3954 -> 3966 | M3 review fixes: off-loop legacy-mode read and the final-pass ACK at the legacy fence call site; the file shrinks with the C6/C11 deletions
Failure-Class: none

View guided diff Turn on auto-fix

Git-on-my-level and others added 2 commits October 22, 2026 01:17
…a legacy final-pass owner like intake

- sync_local_files_v2 read legacy_dark.current_mode() on the event loop, where the
  ramp cache never waits: a cold instance served the 'on' default and could admit
  legacy work after the ramp went draining/dark. Read it through run_blocking, as
  batch intake does, so the first read gets its bounded cold wait.
- In draining/dark, a conversation owned by legacy_final_pass_v1 with no content-ledger
  row fell through to admission_refused (error log, retry_later). Give it intake's
  ACK (LEGACY_ACTIVE: the shipped in-progress 409); still no legacy job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…; gate draining on C8 and final-pass re-home

- routers/enrichment.maintain() also sweeps outbox_for(PROVIDER_STT): intake swallows a
  lost post-commit wake and relies on this sweep (contract (b), invariant 4), which had no
  invoker. Its failure is counted and isolated from the enrichment and summary-debt halves.
- DRAINING_PRECONDITIONS gains provider_stt_live (queue, PROVIDER_STT_TASKS_* env and the
  maintenance job live in prod) and legacy_final_pass_rehomed (lead ruling b209a5), so
  ramp_set cannot leave 'on' before either; the runbook lists both.
Prod stays legacy_sync 'on' after M3, where intake never creates provider units.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T18:34:49.255862Z e2c8214 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2c82142ff

ℹ️ 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".

try:
from database.outbox import OutboxKind, outbox_for

provider = outbox_for(OutboxKind.PROVIDER_STT).sweep(now=now)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Page through all provider-STT rows needing a wake

When more than 100 provider-STT rows are open, this maintenance call does not guarantee that lost wakes are repaired: FirestoreProviderSttOutbox.sweep() filters only on state == open, applies a fixed limit(100), and has neither ordering nor a cursor. If that first stable page contains future-due or actively leased rows, subsequent scheduler passes inspect the same rows while due lost-wake rows beyond the page remain stranded in provider_pending. Query/order by recovery eligibility or paginate past skipped rows before relying on this sweep as the recovery path.

Useful? React with 👍 / 👎.

Comment thread backend/routers/sync.py
Comment on lines +1303 to +1307
decision = legacy_dark.FenceDecision(
legacy_dark.FenceAction.ACK,
legacy_dark.LegacyDarkReason.LEGACY_ACTIVE,
legacy_dark.LegacyOwnership.ACTIVE,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return a pollable handle for the final-pass owner

In the exact no-ledger-row case this constructs an active ACK without a job_id, so fence_response() emits 409 sync_content_in_progress with job_id: null. The Flutter client only adopts that response as queued when the ID is nonempty (app/lib/backend/http/api/conversations.dart:925-934); otherwise it treats it as an edge throttle and retains and reposts the WAL (:1004-1011). Consequently this does not let the client follow an owner or end the retry loop as the new comment claims; it needs a durable pollable owner handle or genuinely terminal/accepted response semantics.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit c13818a into integration/legacy-retire Oct 21, 2026
25 checks passed
@Git-on-my-level
Git-on-my-level deleted the lr/01-m3-review-fixes branch October 21, 2026 18:42
Git-on-my-level added a commit that referenced this pull request Oct 21, 2026
## 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant