Skip to content

config(merge): canary the stale-head merge skip for one canary uid - #25679

Merged
kodjima33 merged 1 commit into
mainfrom
config/stale-head-canary
Nov 18, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
config/stale-head-canary

Conversation

@kodjima33

@kodjima33 kodjima33 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Canary config for the stale-head merge skip from #25673 (merged as ac9f48fb2f). BATCH_PIPELINE_MERGE_STALE_HEAD_UID_ALLOWLIST is bound to one canary uid on every prod process that runs the ordered merge, so the skip does not depend on which writer wins a commit.

Prod process Runs OrderedMerge.commit_next? Env
Cloud Run backend-integration Yes: the only host with BATCH_PIPELINE_SERVING_ENABLED=true (10 s serving loop), the quarantine-recovery task audience, and the provider-STT settle handler URL set (prod.overlay.yaml, composed runtime_env.yaml)
GKE prod-omi-batch-pipeline-worker + -t4 (GPU pump) Yes: commits directly after each publication set (prod_omi_batch-pipeline-worker_values.yaml, rendered via a hasKey-gated template line). Inert until the worker image rolls: the live image ef42ee8 predates the reader
Cloud Run backend-sync No: serving off; the GPU worker only calls /v2/batch-pipeline/authorize-compute here (admission, no merge) not set
Cloud Run backend, backend-sync-backfill No: serving off, no recovery or provider-STT callbacks not set
GKE backend-listen No: serving off not set
GKE record-seal-worker No merge path not set (renders nothing)

Live readback (2026-11-18, gcloud run services describe, kubectl get deploy): BATCH_PIPELINE_SERVING_ENABLED is true only on backend-integration, and PROVIDER_STT_TASKS_HANDLER_URL and BATCH_PIPELINE_RECOVERY_TASK_AUDIENCE both point to backend-integration. All four Cloud Run services run release c868729e55, which predates ac9f48fb2f. The canary takes effect only once backend-integration runs a release that contains #25673; before that the env is ignored.

Both uid literals are recorded in backend/deploy/cross_service_known_gaps.json as reviewed no-uid-literals exceptions, following the existing referral-preview exception. Each has a delete condition: remove the keys when the skip ramps fleet-wide or at its 2026-12-18 review. Binding the GPU worker also resolves the reader-split violation the cross-service contract raised for a worker that reads the flag but leaves it unset.

Also adds the reviewer-suggested regression case: a ready row ahead of the unit with an old enqueued_at but a recent available_at (requeued a minute ago) refuses the skip. The head-position version of this case already existed (redriven).

Canary and rollback

  • Enable: merge this PR, then run the normal backend deploy of a release containing ac9f48fb2f and this PR. That rolls backend-integration; the GPU worker picks the value up on its next chart and image roll.
  • Readback: event=batch_merge outcome=stale_head_skip log lines. For the canary uid's next recordings, the last unit's committed_at - ready_at drops from ~60-100 s to about one serving tick.
  • Rollback: set the value to '' (or delete both lines and both known-gap keys) and redeploy. No migration.

Product invariants affected

  • INV-MEM-4: path-glob match only (backend/deploy/runtime_env.yaml). No memory-promotion, consolidation or intake setting changes; the composed file gains one merge-scheduling line for backend-integration.

How it was verified

  • python3 backend/deploy/compose_runtime_env.py then --check: up to date. The composed value appears only at environments/prod/cloud_run/services/backend-integration/env.
  • helm template (prod and dev, deploy namespace): prod renders the env on prod-omi-batch-pipeline-worker and prod-omi-batch-pipeline-worker-t4 only; record-seal-worker and dev render nothing.
  • backend/scripts/cross_service_contract.py: 0 new violations, 35 known gaps, 0 stale.
  • backend/scripts/pre-deploy-check.sh: passed. Runtime env validation passed for dev and prod; 632 contract tests passed.
  • All 56 changed-file-selected unit test files pass, including test_cross_service_deploy_contract.py, the runtime-env and flag-budget suites, and the stale-head suite (33 passed). Mutation check: judging ready rows by lease_until fails the new case.
  • make preflight: feature-flag registry regenerated (the row now renders the prod binding). product-invariants passes with this body.

Tests

backend/tests/unit/test_batch_pipeline_merge_stale_head.py::test_a_requeued_ready_row_ahead_of_the_unit_blocks_the_skip.

UI evidence

UI-Evidence: none -- deploy configuration only

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Binds BATCH_PIPELINE_MERGE_STALE_HEAD_UID_ALLOWLIST to one canary uid on
every prod merge writer: Cloud Run backend-integration (the only CPU host
with the serving loop, recovery wakes and provider-STT settle drains) and
the GPU worker chart (inert until its image reads the flag). Both uid
literals are recorded as reviewed cross-service exceptions. Adds a
regression test: a requeued ready row ahead of the unit refuses the skip.
@kodjima33
kodjima33 merged commit 84cde92 into main Nov 18, 2026
66 checks passed
@kodjima33
kodjima33 deleted the config/stale-head-canary branch November 18, 2026 10:31
Git-on-my-level added a commit that referenced this pull request Nov 18, 2026
…st (#25696)

* fix(deploy): omit the stale-head canary uid from the Cloud Run manifest

#25679 bound BATCH_PIPELINE_MERGE_STALE_HEAD_UID_ALLOWLIST as a literal in the
prod backend-integration overlay. test_rollout_cohort_deploy's contract is
that the Cloud Run manifest omits private uid bindings so deploys keep the
live value (gcloud preserves undeclared env), so main's backend unit suite
went red. Remove the literal and its known-gaps exception; the uid is bound
on the service at deploy time.

Unchanged: the test, #25673's skip code, #25679's regression case, and the
GPU worker Helm value. Helm is declarative, so omitting it there would drop
the canary on the next upgrade instead of preserving it; that literal keeps
its reviewed no-uid-literals exception.

Failure-Class: none
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(deploy): treat the stale-head canary uid as live-managed on backend-integration

Panel review-20261118t134925-d977: add the key to the drift report's
live-managed allowlist like the sibling canary uid allowlists (F4), and give
the surviving Helm exception its own removal condition now that the Cloud Run
key it pointed at is gone (F2).

Failure-Class: none
Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 18, 2026
…parity and exact undo (#25686)

* feat(conversations-v3): per-owner backfill and repair runs with live parity and exact undo

Turn the v3 backfill into a reusable per-owner repair tool:

- Operator plans one owner + window (default 2 days) from an owners file;
  partitions cut at five-minute silences; run ledger with counts, code SHA
  and outcome; the sweep starts planned runs only when
  CONVERSATIONS_V3_BACKFILL=on; one step at a time on a dedicated
  conversations-v3-backfill queue.
- Derive passes hold their own backfill-builder lease and notes marker, so
  they never make the live builder busy or ride the live queue/sweep.
- Backfilled notes take the live CAPTURE_END path (relevance, speaker
  resolution, meeting context, live floors); process_conversation withholds
  only derived effects for v3 backfilled rows.
- Non-destructive conversion: legacy notes kept, prior field values recorded,
  undo restores donors exactly and removes derived rows; deleting a
  backfilled copy never arms the donor audio purge.
- Resume and re-derive reuse ids by adoption; legacy manual stops map to the
  v3 manual end; discarded/imported/private/unreadable rows stay legacy.

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(conversations-v3): backfill settle/resume edge cases from self-review

Count live-writer terminal failures as failed, keep a start-marker read error
from failing the live sweep, resume a run whose start marker was lost, and
rename the live backoff local that shadowed the window bound.

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(conversations-v3): classify and register CONVERSATIONS_V3_BACKFILL_QUEUE

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(conversations-v3): narrow the backfill start run for the type checker

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(conversations-v3): drop an unused loop index in the backfill operator

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(conversations-v3): keep StrictFirestore DELETE_FIELD semantics; bind historical in the hook harness

Revert the fixture change (other suites assert the stored sentinel) and compare
the restored donor as Firestore would store it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(conversations-v3): answer the backfill panel review

- A legacy row no derived window claims stays a visible legacy conversation
  (counted as sources_unclaimed) instead of being hidden with no replacement.
- Start markers move under users/{uid} so account deletion purges them; the
  sweep reads them with a bounded collection-group list.
- The operator refuses a new run while one is blocked; undo/resume exit 1
  when no listed owner has the run.
- A redelivered committed partition re-dispatches a lost successor (named
  task, so a duplicate is a no-op).
- Re-derive blocks (rederive_mixed_runs) rather than merge rows from two
  runs, keeping undo run-scoped.
- A refused undo records its reason; a drain stopped mid-way reports stopped.
- classify_window reports legacy_candidates; the cost model has a test;
  the runbook documents the row-level partition-gap caveat.

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(conversations-v3): pin the historical gate on owner-recognition telemetry

Backfilled v3 rows skip owner-recognition telemetry and capture-loss
accounting; legacy processing already observed the same speech.

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(conversations-v3): declare the backfill lifecycle payload sites

The run ledger's run/partition status, the re-derive reset of a prior
backfilled copy, and undo's donor restore are reviewed entries in the
lifecycle writer inventory (restore is a backfill-lease-fenced extra writer).

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(home): import home_feed at collection so the CPU guard measures the test

The file-isolated runner charged the cold database.home_feed import to the
first feed-read case's call phase, which crossed the 1.00s CPU guard on CI.

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(desktop): drop the retired /v2/agent out-of-scope prefix (main red after #25050)

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* config(conversations-v3): enable the operator-only backfill route on prod backend-sync

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(deploy): omit the stale-head canary uid from the Cloud Run manifest

#25679 bound BATCH_PIPELINE_MERGE_STALE_HEAD_UID_ALLOWLIST as a literal in the
prod backend-integration overlay. test_rollout_cohort_deploy's contract is
that the Cloud Run manifest omits private uid bindings so deploys keep the
live value (gcloud preserves undeclared env), so main's backend unit suite
went red. Remove the literal and its known-gaps exception; the uid is bound
on the service at deploy time.

Unchanged: the test, #25673's skip code, #25679's regression case, and the
GPU worker Helm value. Helm is declarative, so omitting it there would drop
the canary on the next upgrade instead of preserving it; that literal keeps
its reviewed no-uid-literals exception.

Failure-Class: none
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(conversations-v3): undo never resurrects a deletion; fence it with both builders

- A donor whose backfilled copy the owner deleted (a post-run deleted span, or
  no claim left) is kept converted, with every copy it shares and their donors;
  the restore transaction re-checks, and a deletion that races undo is kept.
- Undo holds the backfill and live builder leases before it enumerates the
  run, so no pass commits or stamps a row while it restores and deletes.
- A converted donor that no longer reads blocks the partition
  (backfill_source_unreadable) instead of retiring its only copy.
- undo on a re-derive run id names the original run and exits 1; the dry-run
  counts donors the owner deleted; classification splits not-completed rows.

Failure-Class: FC-irreversible-terminal-hide

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 26, 2026
…ount deletion (#25703)

## Summary

Follow-up to #25686. It merged at 2c5a581 while omi-panel
`review-20261118t145557-1937` was still running on that head, and that
review came back FIX-FIRST. This PR fixes its findings in the backfill
drain, undo, re-derive and the operator script. Undo has to be
verifiable before the first owner run, so these fixes gate the run.

- **Account deletion stops the backfill drain** (F1, blocking).
`drain_backfill` checks the account-deletion marker before each notes
chunk. Once deletion starts, no transcript goes to the notes model, and
the step marks the run blocked with reason `account_deletion`.
- **Undo works one connected group per transaction** (F3, F4, F10). A
group is the donors plus the copies that claim them. In one transaction,
undo reads the group's donors, copies and the copies' deletion
tombstones. It then either restores the donors exactly and deletes the
copies, or keeps the whole group as backfilled v3. It keeps the group
when the owner deleted a copy, shown by a tombstone or by a donor
deleted span added after the run.
- A delete racing undo can no longer resurface a legacy row. The
tombstone is written before the claim release and is read inside the
transaction.
  - Nothing is hidden or shown twice partway through.
- A donor with no claim and no new span is restored. Its copy never
committed (an interrupted run) or a re-derive retired it. The previous
version wrongly kept it hidden.
- A kept copy's owed backfill notes move to the live notes marker. The
owner's next live builder pass writes them, so an owner with no further
capture or app open keeps them pending until then.
- **Re-derive** (F5, F6). A donor this run already converted that no
rebuilt window claims now blocks the partition
(`backfill_donor_unclaimed`) instead of staying hidden with no copy. A
re-derived prior copy no longer inherits a stale notes marker.
- **Operator** (F7, F8). One owner's blocked plan prints `owner[N]
blocked: <reason>`, the script continues with the other owners, and it
exits 1. Blocked reasons include an overfull partition, account
deletion, an unreadable source and an existing run.
- **Partitions** (F11). A gap-free run over the cap is now cut at the
latest of equal gaps, so partitions fill up. Before, every row became
its own partition with its own outline call.
- **Telemetry scope** (F9). Only backfilled v3 copies skip capture-loss
and owner-recognition telemetry. Silent-backfill recovery keeps both, as
on main before #25686.
- **Flag notes** (F12). The `CONVERSATIONS_V3_BACKFILL` registry notes
now state the prod backend-sync value and the operator-only gating.

Later review rounds on this PR (`review-20261118t171612-b1c4` through
`review-20261118t223845-273f`) added these fixes:

- **Account-deletion checks.** The drain checks the deletion marker
before each batch and row. At model admission, a single-attempt
Firestore transaction reads the same customer-data marker that deletion
intent writes. This covers both task-only and full notes for backfilled
v3 copies. If deletion wins after the row check, the drain releases the
lease, preserves the owed notes marker, and blocks the run without
incrementing its backfill retry count. The derive loader and the drain
read the marker fresh, past the 30-second negative cache, and the fresh
read keeps the check metrics.
- **Undo, per group:**
- The group transaction refuses while any copy holds a notes lease
(`notes_in_flight`).
- It records undo progress in the run ledger in the same transaction
(totals and removed copy ids), so a crash or retry loses nothing.
- **Undo, owner deletions:**
- Deleting a backfilled copy records its id on the legacy row even when
other claims cover the interval, so undo always sees it.
  - A deleted copy never goes to the notes model.
- Copies deleted in the instant undo removed them are listed as
`deleted_during_undo_ids`.
- **Undo, read bound.** A copy a donor names only by a post-run deleted
span or a recorded deleted copy still links the group but is not read,
because that donor already keeps the group. Old deletions therefore
never push a group over the read bound. Undoing a run that is already
`undone` or `undone_partial` reports its record and changes nothing.
- **Undo, status.** A run with kept groups or a raced delete ends
`undone_partial` (exit 1). The group size bound counts reads, not
documents. An undo that fails partway still checks the copies it already
removed for a racing delete and records them in the error.
`donors_kept_deleted` counts only converted donors that stayed hidden.
- **Re-derive and operator.**
  - Re-derived copies start a fresh notes retry budget.
- Only a re-derive blocks on an unclaimed converted donor; a resume
carries on.
- The operator script reports only Conflicts and an existing run (the
typed `BackfillRunExists`) as a blocked owner, and an owner skipped for
an active run sets exit 1.
- Undo renews its leases inside the per-group error handling, so a lease
lost on renew writes the same error record as a failed group.

From the 18:30Z smell audit:

- **Undo never deletes live capture.** A live builder pass after the run
carries the run tag onto a window that also holds recordings captured
after the run. Undo now keeps any group whose copy holds a recording
outside the group (`kept_live`). It counts
`groups_kept_live`/`donors_kept_live` and ends `undone_partial`.
- **Known limit, not changed:** donors are selected by `started_at <
until`, and `--until` defaults to now. Only completed, non-recording
legacy rows qualify (`backfill_legacy_source`), so an in-progress
capture is never converted. A legacy conversation that completed just
before the run is in scope. Pass an explicit `--until` to leave recent
history alone.

Rejected on purpose, and tracked as follow-ups (the coordinator agreed
with the notes-lock reject, bus a16967):

- A shared admission guard for ordinary live v3 and legacy notes remains
a follow-up. This change scopes the guard to backfilled v3 copies,
including copies whose owed notes move to the live queue after undo.
- A lock between the shared delete path
(`conversation_tombstones.record_deletion`) and undo. Undo surfaces the
race instead, through the raced ids and `undone_partial`.

Not changed here: F2 (removal of the
`BATCH_PIPELINE_MERGE_STALE_HEAD_UID_ALLOWLIST` prod binding). It came
from #25696 (jobstore-index's #25679 repair), which was merged into
#25686. Its owner and declaration live with that change.

## Product invariants affected

- INV-MEM-4 and INV-TASK-2 are unchanged. Backfilled v3 rows still take
no memory intake, tasks or Candidates. Kept copies that move to the live
notes marker go through the same `historical` seam in
`process_conversation`.

Failure-Class: FC-irreversible-terminal-hide

Line-Count-Exception: backend/database/conversations_v3.py | 1799 ->
1862 | Keep the connected undo transaction with the projection writer
and its visibility index.
Line-Count-Exception: backend/routers/conversations.py | 3276 -> 3314 |
Pass observed row existence through the existing delete paths so undo
races return the refresh response.
Line-Count-Exception:
backend/utils/conversations/process_conversation.py | 3608 -> 3612 |
Preserve typed admission failures and scope suppressed telemetry to
backfilled copies.
Line-Count-Exception: backend/utils/conversations/v3/service.py | 1652
-> 1678 | Check deletion during the paged drain and preserve the
processing state when admission is blocked.

## Test plan

November 26 verification after merging current main

- 97 ordinary backfill tests and 6 prompt-version tests passed.
- 1,309 related backend tests passed.
- 4 Firestore emulator cases passed, each covering both admission
orders. Cases combine immediate and grace-period deletion with absent
and cancelled markers.
- Backfilled notes use an 8-second SDK request timeout and a 12-second
overall admission budget. Slow notes exhaust one backfill retry and
cannot settle as success.

`tests/unit/test_conversations_v3_backfill.py` passed all 81 tests on
the rebased PR head, including the regression that starts deletion after
the drain checks and before model admission. Existing coverage includes:

- Undo on StrictFirestore:
  - `test_undo_never_resurrects_a_donor_whose_copy_the_owner_deleted`
-
`test_a_deletion_racing_undo_keeps_the_group_and_hands_owed_notes_to_live`
  - `test_an_interrupted_conversion_with_no_claim_is_restored`
  - the exact-restore and lease tests, now on `undo_backfill_group`.
- Undo grouping and ordering:
  - `test_undo_groups_link_donors_and_copies_including_deleted_copies`
  - `test_only_a_post_run_deleted_span_counts_as_the_owners_deletion`
  - `test_undo_holds_both_builder_leases_before_it_enumerates_the_run`
-
`test_undo_works_one_group_per_call_and_refuses_while_notes_are_in_flight`
- Drain:
  - `test_the_drain_stops_once_account_deletion_starts`
- `test_a_step_blocks_the_run_when_the_drain_stops_for_account_deletion`
- Re-derive:
- `test_a_converted_donor_no_rebuilt_window_claims_blocks_the_partition`
  - the stale notes marker asserted in the loader re-derive test.
- Operator: `test_one_owners_blocked_plan_never_stops_the_others`.
- Partitions: partition sizes asserted in
`test_a_gap_free_run_over_the_cap_is_a_counted_forced_cut`.

Updated pins: `test_owner_recognition_telemetry` and the
`test_capture_loss_accounting` harness.

The local Firestore emulator verified both admission orders with absent
and cancelled markers, for immediate and grace-period deletion.
Production was outside this verification.

🤖 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