Skip to content

fix(conversations-v3): configure boundary timing and merge locked windows - #25794

Merged
Git-on-my-level merged 22 commits into
mainfrom
lane/v3-lock-merge
Nov 19, 2026
Merged

Git-on-my-level merged 22 commits into
mainfrom
lane/v3-lock-merge

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

DESIGN

  • With stretch cohesion enabled, CONVERSATIONS_V3_SILENCE_GAP_SECONDS controls the recorded-silence boundary (120–1800 seconds) and CONVERSATIONS_V3_LOCK_SECONDS controls the notes deadline measured from the last speech (120–3600 seconds). Each defaults to 300 seconds and invalid values use the default. Unset both or switch cohesion off to restore the existing timing. Historical re-derive keeps its existing partition boundaries. A lock shorter than the silence interval can finalize an initial card before later speech arrives. That speech starts a continuation, which can merge after both cards settle and the outline covers both.
  • Under configured timing, Home shows each unlocked preview with its outline title and emoji once the outline is ready. Older previews use the same card presentation while the writer tracks a single live slot. Full notes become due at lock. A provisional card can leave Home at lock if the finalized stretch falls below the existing word floor. Explicit Open uses the existing scoped reconcile and notes stream, and End uses its existing manual-cut path. Both bypass the configured delay. The separate live catch-up recap remains a preview, including for participants in its existing cohort. If the scoped Open reconcile reaches its existing timeout, the notes stream can still finalize the same revision in its existing write. The builder rebases a paid preview outline when later speech moves its line numbers, and reuses it at lock. An eligible window had one initial full-notes generation before and has one after. The configured path removes the automatic late rewrite. Post-lock refinement adds zero notes calls. An unchanged stretch uses one successful outline generation before and after. A configured stretch keeps its paid preview through lock, including after a transcript revision. Its title or topics can reflect the earlier preview. Full notes use the current transcript. An explicit silence-setting change alters the cache key.
  • Within the affected recording and claim closure, a single outline window can cover two or more previously locked cards. Cards outside that bounded snapshot keep their existing boundaries. Refinement requires complete coverage of their published speech and claims. When ownership, user edits, cut boundaries or notes coverage are ambiguous, the existing cards keep their boundaries. Refinement uses the shared user-managed card policy. A card with user corrections stays separate, as does a donor with linked standalone tasks or saved open-loop extractions. Cards with note evidence pointers stay separate to preserve those pointers. Cards without generated sections also stay separate because a user-edited overview removes those sections. The earliest row keeps its ID. Existing recap sections and audio are retained with duplicate same-file intervals removed. The compatibility overview is rendered from the combined notes. Absorbed IDs redirect to the survivor. Donor redirects and the union of existing claims commit in the same fenced transaction as the survivor. The operation adds no claim sources, fanout, or audio reads.
  • Default reconciliation has the existing read and write shape. A configured silence gap over 20 minutes widens the neighborhood query from 20 minutes per side to the selected gap, up to 30 minutes per side. The existing hard read limits still apply. Under configured timing, a pass also reads each provisional card that has fallen out of the live slot once via the bounded lease index. A merge reads one existing-delete-intent marker per donor. A candidate gets one bounded task-presence query during planning and repeats it inside the claim transaction. Each query returns at most one projected task reference. The transaction writes one survivor and one redirect per donor in place of the projected card writes, and uses the existing source claim and lease writes.

Only the last stretch or unmatched fragment can be in progress. Earlier stretches close for commit purposes even when their outline preview remains unlocked and their full notes are deferred. The lock deadline uses the existing Cloud Tasks continuation. Each unlocked preview retains a pending marker on one source recording, so the existing sweep can recover a missed deadline. The marker clears when the preview settles. No new sweep query is required. The builder's existing follow-up check can read up to one extra pending-source record per deferred preview source.

READBACK

Compare the default replay and the 900-second silence / 3,600-second lock replay on the lab's 11-18 run. Exclude dictation, and report only card count, ideal Home recall, and whole-card recall. The lab will run this comparison. After an authorized rollout, verify the readback on the serving SHA, including open/End lock latency, outlines and notes per card, and same-file claim/playback overlap.

Evidence-based continuity across a 5–15-minute gap is follow-up work. Evaluate the existing smart-merge continuation question (Jev) against the ideal's real boundaries and continuations before changing that policy.

Failure-Class: none

Git-on-my-level added a commit that referenced this pull request Nov 19, 2026
## DESIGN:

- **Reads.** Unchanged. The change is in the pure planner
(`outline.stretches`, `planner.preserve_finished_windows`). It adds no
query, document read or transaction round trip.
- **Writes.** Unchanged per pass. Each committed pass writes the same
rows and source claims it would have written. Parked owners commit
again, so their backlog drains through the existing paths.
  - About 41 owners' builders resume after deploy.
- Their `v3_pending` backlog is bounded by what is there now: at most
200 pending sources per owner, read 32 per pass.
- **Cost.** No new model calls per pass. The one exception: an earlier
stretch that a backlog page's continuation held open now gets its single
outline call on this pass, the same call it would get once the
continuation clears. Earlier fragments of a split open window now finish
on the pass that splits it instead of when the stretch goes quiet. They
are the same fragments and get the same notes as before, only earlier.
The backlog the parked owners were owed was already counted. Nothing new
is admitted.
- **Production number that proves it.** `READBACK:` Builder leases
parked with `v3_blocked_reason=multiple_open_conversations` drop to
about 0 within 1 h of serving. Today's count is 41 at 17:2xZ, among the
483 owners holding `v3_pending` sources. The
`omi_conversations_v3_blocked_total{reason="multiple_open_conversations"}`
rate also stays at about 0. On b45a0c9 the log shows a median of 88
events per full hour, with 364 owners blocked at least once since
2026-11-18T21:44Z.

## Summary

`commit_projection` refuses a plan with more than one in-progress row
(`backend/database/conversations_v3.py:545-547`,
`Conflict('multiple_open_conversations')`). The reconcile parks the
owner (`service.py:46`, `BLOCKED`), backs off 5 min to 1 h, then replans
the same inputs. The plan comes out the same every time, so the park
never self-heals and the owner's Home freezes.

### Measurement (prod, read-only)

Tiers: `ro-prod` for logs, `prod-operator` for Firestore REST metadata.
In-process replay: every writer was stubbed and every Firestore write
method raised. `ENCRYPTION_SECRET` was held in memory only. Uids were
hashed in-process; no transcripts, titles or summaries were printed.

- **Logs.** 1,774 `v3 reconcile blocked
reason=multiple_open_conversations` events from 364 distinct owner tags,
all on backend-sync. The first was at 2026-11-18T21:44Z, the all-users
stage, and events occurred every hour after that. The problem predates
the 16:16Z deploy of #25764 and #25753.
- **Leases.** 41 parked owners. `v3_blocked_count` distribution: 1 (9
owners), 2 (12), 3 (1), 4 (4), 5 (4), and 16-28 (14). The 14 long-parked
owners all have more than 32 pending sources.
- **Sources.**
  - Every parked owner has a single capture device and source `omi`.
- Not one source carries a rotation stamp, and only one carries
`v3_manual_end`.
- 34 of 41 owners have no stored in-progress derived row, so both open
rows are new windows in the same plan.
- **Replay of one live pass per owner on main.** It found three shapes,
each ending in two or more unfinished planned windows:

| Shape | Owners (of 41) | Example |
|---|---|---|
| **Preserve split.** One open window is cut around retained finished
rows' lines into 2 to 74 open fresh fragments | 15 | A live stretch with
interleaved capture became 74 open fragments |
| **Page continuation.** A backlog page's continuation marker holds
every stretch ending in the page's latest recording open | 5 | Two or
three stretches that ended 10 to 20 h ago, all open |
| **Future-dated speech.** Stretches ending up to 2 h in the future stay
open across recorded silence | 5 | Four open stretches, ending at -3,
+47, +93 and +131 min |
| Already at one or no open window (the plan changed since parking; it
commits on its next pass) | 16 | |

A second replay on the deployed b45a0c9 code, about 40 minutes later,
found 25 of the 41 owners still planning more than one open window.

### Root cause

1. **Preserve split.** `planner.preserve_finished_windows`
(`planner.py:482-485` on main) flushes the unmatched lines before each
retained row's line as a fresh window built from `{**window}`. Only a
manual stretch or its after-cut continuation
(`_keep_unmatched_together`, #25764) keeps them together. That path is
unchanged here. Every fragment of an open window inherits
`finished=False`, so a live stretch that contains published speech
(interleaved or late-synced capture, an on-open chapter, a backlog page
held open) plans one open window per gap.
2. **Continuation and future speech.** `outline.stretches`
(`outline.py:137-141` on main) computes `finished` per stretch from `now
- end >= SILENCE` and the continuation marker. A continuation marker on
the page's latest recording holds open every stretch whose last line is
in that recording. Speech stamped in the future is never 5 minutes old.
Both cases ignore the fact that a later stretch exists, and a later
stretch begins only after recorded silence or a manual cut
(`outline.py:121-131`).

### Fix

- `outline.stretches`: every stretch but the last is finished. Only the
last stretch can still be held open, by recency, page continuation or a
pending manual state.
- `preserve_finished_windows`: an open window splits around retained
rows exactly as a finished window does, with the same fragments, lines
and time matching. Only the last fragment keeps the window's open state;
published speech follows every earlier fragment, so none of them can be
the open edge. Those fragments are the same ones the window would
produce once its stretch goes quiet, so the end state is unchanged; they
just finish sooner.
- The first head (78b08e4) kept an open window's unmatched lines
together instead. The panel (F3) found that this widened the window's
time range across retained rows, so `service._match` could match a
deletion tombstone inside it and skip the whole open window. This head
drops that approach.
- Together these give at most one unfinished window per plan. Per group,
`planner.windows` and `_cohesive_groups` already leave only the last
part open. Retained windows are always finished.

What does not change:
- **Custody.** Fragments, their lines, ids and time matching are what
main produces; only `finished` differs. Retained rows keep their ids,
claims and audio. The open edge keeps the stored open row's id and
claims only unpublished audio. The test asserts all of this. The #25764
claim rules (no duplicate audio, earliest id kept) are untouched.
- **Healthy owners.** Finished windows are unchanged, and so is an open
window with a single fresh fragment, which is the shape that commits
today. The one behavioural change outside plans that cannot commit: a
backlog-continued stretch that was the only open one, but not the last
stretch, now finishes. A later stretch after recorded silence already
proves it ended.

No kill switch. Every changed plan except that one edge case is a plan
`commit_projection` refuses today. Rollback is a revert.

### Recovery (no manual unpark)

The parked owners recover on their own after deploy:
1. Their `v3_pending` markers are still owed, and the backoff expires
within 1 h.
2. The sweeper re-enqueues any owner whose pending sources are at least
10 minutes old.
3. The final batch of a successful commit clears `v3_blocked_count`,
`v3_blocked_reason` and `v3_backoff_until` (`conversations_v3.py:698`).

Replaying the fixed code against the same 41 owners runs the real
`commit_projection` against an in-memory copy of each closure (all
writers stubbed, reads from prod). Replay of head 3db0387
(~18:45-19:30Z), on the 41 owners parked at 17:20Z:
- 39 commit: 29 with exactly one open row and 10 with none. Planned rows
per owner were p50 22 and max 477.
- 2 raised `target_exists`, because a real pass committed for those
owners during the replay. Both leases were already cleared in prod, and
re-running the replay committed each with one open row.

Recount at 19:25Z: 57 owners parked, 22 of them from the 17:20Z set and
35 new. On the deployed code, 25 of the 35 new owners already plan at
most one open window, so they are transient parks that recover after
backoff; the other 10 are preserve splits. The same replay of the fix on
all 35 new owners: all 35 commit, 11 with one open row and 24 with none.

To unpark without waiting for the backoff, an operator deletes the three
fields on `users/{uid}/conversation_v3_leases/builder`, as the runbook
describes. That is not needed here.

### Out of scope, noted

- **Future-dated speech.** Six parked owners have segments stamped up to
about 2 h ahead of the server clock. This PR keeps them committing:
their last stretch stays open until real time passes its end. The clock
or offset source is a separate bug.
- **#25794 (v3-lock-merge).** It edits the same `finished` line, adding
`lock_delay`. With `lock_delay > silence_gap`, several unlocked
stretches would be open at once, and the commit refuses that. Whichever
PR lands second has to keep the rule that only the last stretch is open.

## Tests

- `test_published_speech_inside_an_open_stretch_leaves_one_open_window`:
a published row and a stored open row, then late capture around and
inside the published row. Red on main (three open fragments). Green
here, with these properties:
  - exactly one open row, holding the latest line;
  - no line lost;
  - the stored open row's id is kept;
  - the retained row's claims and audio are unchanged;
  - the open edge claims only unpublished audio.
- `test_only_the_last_stretch_stays_open`: page continuation and
future-dated speech, plus the cohesion windows. Red on main, green here.
- All 21 v3 suite files pass, 486 tests: `test_conversations_v3_*`,
`test_listen_v3_*`, record-close and batch-projection admission.
- The changed-file selector (`bash test.sh` via `omi-heavy`) picked 152
files, the same set CI runs, and 7,038 tests passed. One file failed
only the local 1.00 s CPU guard:
`test_conversation_processing_retryable_timeout.py`, on the
`/v1/conversations` OpenAPI case at 1.14 s. That is the same known local
guard hit recorded on #25764, and this change does not touch it.

## Panel triage

Panel review-20261119t180246-a22d returned SHIP on 78b08e4 (luna,
deepseek and glm-flash all completed).
- F1, accept: the test now stores the previous pass's open row and
asserts the open edge keeps its id.
- F2, reject: only one open stretch can commit. Holding a current
stretch open next to a future-dated later one is exactly the two-open
plan that parks the owner. Finishing it risks at most one split when
future-stamped data exists, and no speech is lost. The future clock is a
separate data bug, noted above.
- F3, accept: fixed by dropping keep-together. An open window now splits
exactly like a finished one, with only the last fragment open.
- F4, accept: the test asserts the retained row's claims and recording
pieces.

Panel review-20261119t184151-fa1e returned FIX-FIRST on the final head
3db0387 (luna, deepseek and glm-flash all completed). No code
changed after it.
- F1, reject: the reviewer misread the test. Line 75-85 is the synced
recording, unowned and sitting between the owned 60-70 and 90-100, so
the plan is four windows. The test passes on this head.
- F2, accept: the replay of this head is filled in above.
- F3, reject: the after-manual-end continuation keeps its lines together
under #25764's rule. That is one fragment, so at most one open edge. The
behaviour is pre-existing and unchanged, and the wording above now names
it.
- F4, reject: deliberate. A single open fragment commits today, so it
stays as on main.
- F5, reject for this PR: the `_match` tombstone rule is the same as for
a single-fragment plan on main. It is a candidate follow-up: prefer an
in-progress prior over a tombstone.
- F6, accept: the cost line above is corrected.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Preserve a single live edge while earlier stretches await their independent notes deadline.

Failure-Class: none
Preserve source wake markers through decode conflicts and rebase cached outline anchors by stable segment identity.

Failure-Class: none
Keep user-corrected cards out of refinement, retain paid outlines with surviving anchors, and persist scoped Open preview wakes.

Failure-Class: none
Finish explicit Open in the notes transaction, settle previews without eligible recordings, and protect note evidence pointers from refinement.

Failure-Class: none
@Git-on-my-level
Git-on-my-level merged commit 755558a into main Nov 19, 2026
66 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/v3-lock-merge branch November 19, 2026 22:32
Git-on-my-level added a commit that referenced this pull request Nov 20, 2026
… five minutes (#25829)

Builds on #25794 (merged as 755558a): sit-down cutting when its
silence gap is set above five minutes.

## DESIGN:

- **What changes.** When `CONVERSATIONS_V3_SILENCE_GAP_SECONDS`
(#25794's setting) is over 300 s, v3 cuts at sit-downs instead of at the
silence itself. At the default of 300 s nothing changes, so this PR
alone changes nothing in production; the gap setting is the switch, and
setting it back to 300 is the rollback.
- The outline sees pauses of 2 minutes or more as marker lines (`---- 4
min without speech ----`). A sit-down rule replaces the "N of recorded
silence is a hard boundary" sentence. Line numbering is unchanged.
- Neighbouring `conversation` entries of one stretch join into one card,
with topics as sections. Dictation under the Home word minimum that sits
between two of them joins as a section. Media, background and longer
dictation stay separate. Manual-end stretches keep their existing single
card.
- Under a long gap, each card meets the Home word minimum on its own
words. Otherwise #25786's stretch-level total lets every piece of a
two-hour stretch onto Home.
- **Two-hour cap, at any timing.** A stretch over two hours is cut after
the longest prefix that ends within two hours of its start, then again
from there. The cut ignores the outline and does not move as live speech
arrives; main's middle cut moved every pass and stranded one-line cards
(traced on 11-18, 13:54–14:04). The cap and the projection share one
ownership rule and one index per plan (`planner.Ownership.owner_of`,
built once in `plan()` and passed to both projections): an exact hold
(id and timing) wins first, across open and locked rows, with a row
naming the line's recording in `v3_recording_ids` ahead of a legacy row
naming none; only without one does containment in a row's window and
audio claim decide, locked rows first, so a revised turn stays with its
row. A deleted locked row (tombstone) still owns its lines, so the
deleted speech stays isolated in its own skipped window and never joins
the valid speech either side; the cap never reuses a tombstone's cut.
Deleted open rows own nothing, as before (left to the time-matched
tombstone path). When a locked row owns a part's first line, the part
ends at the first line it does not own: rows main already cut, or an
earlier pass cut, keep their cut after upgrade and on backfill resume,
even when a turn straddles it or a held turn is revised. A locked row
that owns none of the stretch's lines never cuts it. The plain duration
branch (no locked owner of the part's first line) still finishes every
part but the last without consulting later lines' owners: with no locked
owner there is no committed cut to keep, and the projection still routes
each finished part's lines through `owner_of`, so a line a protected row
owns is retained by that row and only lines no protected row owns can
land in the finished part. A stretch over two hours has to be cut
somewhere, so this is the existing cap behaviour.
- **One owner per segment.** A row that already holds a segment keeps it
on later passes, even when overlapping turns put it inside a neighbour's
window and clipped claim; a turn published in the open tail stays there
even when its audio lies inside the locked prefix's claim.
- **Lock clock under custom timing.** With either setting off 300, the
lock delay counts from the later of the last speech and
`v3_speech_landed_at`. That field is written in the same transaction as
the speech (live transcript write, sync assignment, batch recording
create), only when the speech changed, so a reconcile between the commit
and the re-arm already sees it. Offline batches of old speech no longer
lock on arrival. Default timing and backfill derive still count from the
last speech.
- **Reads and writes.** No new query, document or transaction. Speech
transactions on v3 recordings carry one more timestamp field.
- **Model calls.** Outline calls per stretch are unchanged, and a long
gap means fewer, longer stretches. Each prompt grows by the marker
lines, under 1% of tokens. Notes calls fall with the card count.
- **Latency.** No change of its own. Lock timing is #25794's
`CONVERSATIONS_V3_LOCK_SECONDS`.
- **Invariant kept.** At most one open window per owner plan (#25800).
Joining works inside one stretch and never holds an earlier stretch
open. There is a test for it.
- **Production number that proves it.** `READBACK:` Home cards per
active v3 owner-day, and the `below_word_minimum` share of derived rows.
Both fall, while the visible cards' word share of the day's speech stays
within 5% of baseline.

## Lab evidence

Pipeline lab (m5-mbp): the owner's real days, replayed offline through
each ref's own `outline`, `planner` and `visibility` code with real
outline calls. Scored against a reviewed ideal Home: 11-17 and 11-18
were reviewed by the owner, and 11-19 was judged by Fable. Dictation is
excluded. No production reads or writes, and no transcripts leave the
lab host.

**Whole finished day** (3 runs each, gap 900 s / lock 900 s, on #25794's
head c9e058c, which is identical in v3 code to 755558a):

| Day | Arm | Home cards | Whole ideal cards | Home precision |
|---|---|---|---|---|
| 11-19 | #25794 | 8-9 | 4/6 | 0.56-0.62 |
| 11-19 | + this PR | 9 | 4/6 | 0.56 |
| 11-18 | #25794 | 19-23 | 3-5/9 | 0.56-0.67 |
| 11-18 | + this PR | 10-13 | 5-7/9 | 0.54-0.70 |
| 11-17 | #25794 | 24-33 | 0/2 | 0.29-0.46 |
| 11-17 | + this PR | 7-12 | 0/2 | 0.22-0.43 |

Ideal Home recall is equal, except one of three 11-17 runs of this PR,
which missed one of the 2 ideal Home cards.

**Full live replay of 11-18** (incremental arrival, real locking, gap
900 / lock 900): #25794 gives 213 cards, 16 on Home, 6/9 recalled, 3/9
whole, precision 0.62. With this PR: 210 cards, 10 on Home, 5/9, 4/9,
precision 0.70. Live fragmentation, which neither ref changes, dominates
the live score; it is being traced separately.

Replays at main 755558a+ against this PR, at default timing and at gap
900 / lock 3600, are running. Results go in a comment before merge. At
default timing this PR is inert by construction: `outline.sitdown()` is
false at 300 s.

## Tests

- `test_conversations_v3_sitdown.py` (new): the 300 s threshold, the
prompt rule swap and gap markers, joining, long dictation, manual end,
the per-card word gate, and one open window.
- `test_conversations_v3_lock_timing.py`: the prompt-threshold test now
uses a 240 s gap, where the hard-boundary sentence still applies.
- `test_conversations_v3_live_passes.py` (new): real `reconcile` +
`commit_projection` passes on the strict fixture. One open card while
live speech stays inside the lock delay; offline batches of old speech
at 900 and 300; the cap cut survives the first paid outline, and ignores
a section a later outline drops (300 and 900); a reconcile between the
speech commit and the re-arm does not lock; derive ignores the landing
clock; overlapping turns at the cap keep one owner across passes with
non-overlapping claims; rows cut by main's middle cap keep boundaries,
segments and claims after upgrade, also when a turn straddles the old
cut or a held turn is revised (300 and 900); a turn published in the
open tail inside the prefix's claim stays in the open tail with no
finished fragment (300 and 900); a full write that changes no speech
keeps the landing time; resuming a main-cut backfill run keeps its rows.
Each was checked to fail with its fix removed.
- Tombstone and precedence: valid speech either side of a deleted card
in one stretch survives in live cards and the deleted speech does not
reappear (300 and 900); a tombstone never pins a cap cut; a
source-qualified exact hold beats an earlier legacy one; a deleted open
row never owns a line; an exact hold needs the same timing; one
`Ownership` per plan.
- Mutation pass over the ownership rule (14 mutations, every one caught
by at least one test): tombstones dropped; cap reusing a tombstone cut;
legacy before source-qualified; exact ignoring the recording; claim
before exact; no claim fallback; a separate locked-only cap rule; no cut
reuse; a locked run ignoring an owner change; the projection retaining
open-owned lines; the projection building its own index; service passing
no index; deleted open rows owning lines; exact ignoring timing.
- `test_sync_assignment_recovery.py`: the landing time commits with
assigned speech for recordings only, and an exact retry preserves it.
- `test_conversations_v3_engine.py`: a locked row holding none of an
over-cap stretch never cuts it (control), and one holding the stretch
start keeps its cut; an exact hold on a later locked row beats an
earlier row's claim, for the cap and the projection, and needs the
line's own recording. With `test_conversations_v3_stretch_cohesion.py`,
expectations moved to the stable cut.
- All v3 suites pass together (728 tests); the sync assignment,
cross-job, live transcript, manual speaker, batch projection, listen
failover and lifecycle files pass one file at a time. Their combined
xdist run has order-dependent failures and a hang that reproduce on main
without this PR (`test_sync_assignment_recovery.py` leaks state into
later files on the same worker).

Line-Count-Exception: backend/database/conversations.py | 5293 -> 5307 |
the landing stamp must commit inside update_conversation_segments'
speech transaction, gated on a speech change
Line-Count-Exception: backend/utils/sync/assignment.py | 1610 -> 1617 |
the landing stamp must commit inside the sync assignment transaction
that writes the speech

## Follow-ups (not in this PR)

- The retained-row duplicate check ignores speaker identity, so it can
suppress a distinct speaker's near-identical turn. This predates this PR
(reviewer note on #25829); it needs its own fix and test.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
rahul24 pushed a commit to rahul24/milo that referenced this pull request Nov 20, 2026
… five minutes

Under CONVERSATIONS_V3_SILENCE_GAP_SECONDS above 300 (BasedHardware#25794's setting; default
300 leaves today's behaviour unchanged):
- the outline sees pauses of 2 minutes or more as marker lines, and a sit-down
  rule replaces the hard-boundary sentence;
- neighbouring conversation entries of a stretch join into one card, with short
  dictation between them as a section;
- each card meets the Home word minimum on its own words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 20, 2026
…th an agent guide (#25862)

The pipeline lab replays one recorded day through a ref's real pipeline
code against local emulators. You can then compare, card by card, what
that ref would have built with what production built that day. It is how
the v3 sit-down work (#25794, #25829) was measured.

This PR lands the lab on main so every agent works from one copy instead
of a long-lived lane branch.

## Scope

- **What it touches.** Everything is under
`backend/testing/pipeline_lab/` and
`backend/tests/unit/test_pipeline_lab_*.py`, plus:
  - one `make pipeline-lab ARGS=...` target;
- a size budget for the new lab `AGENTS.md` in
`.github/scripts/check_agents_md_lean.py`, set to its size at creation;
- one `exempt` entry in `.github/firestore-collection-budgets.json` for
`parakeet_batch`. That is the lab's STT adapter name, not a collection:
the collection-budget scanner resolved unrelated `.collection(name)`
parameters in `backend/database` to it.
- five node ids in `backend/tests/fast_unit_duration_allowlist.txt`. The
first test of each of those lab files drives real product code and pays
its import chain in its call phase.
- one reviewed edge in
`backend/tests/unit/fixtures/sync_legacy_import_baseline.json`. The
lab's sync-lane replay imports `utils.sync.pipeline` as its subject, and
is deleted with that module in C11.
- **What it does not touch.** No product module imports the lab, no
service or deploy path runs it, and no workflow is added.
- **Contents.**
  - Run store and spend ledger.
  - LLM record/replay proxy with a hard cap.
  - Pinned per-ref worktrees.
  - Stage registry and CLI.
  - Seeder, chain and v3 drivers.
  - Inspector.
  - Ideal-day scoring.
  - Read-only v3 exporter.
- **Agent guide.** `backend/testing/pipeline_lab/AGENTS.md`, linked from
the lab README, records what earlier agents got wrong:
  - replay bistability at default timing (repeat runs, report ranges);
  - no text in reports;
  - one replay at a time on the shared emulator;
  - never killing `dev_harness` supervisors by pattern;
  - harness parity with `store.load` (tombstones);
  - mutation passes for custody tests;
  - cleanup.
- **`ideal/runs.py`.** It replaces the per-session scratch scripts: a
score table against the day's ideal and a per-card diff across runs. It
prints times, counts and flags only.
- **`ideal/score.py`.** A line two conversations share now goes to the
earlier-starting one. It used to go to whichever file the directory
listing returned first. With overlapping cards that made the score
depend on file order: Home precision on one 11-19 run came out 1.00 or
0.67.
- **Speaker labels.** No raw speaker interpolation:
  - stored `SPEAKER_NN` labels come from `contracts.wire_speaker_label`;
- the Home-judge prototype (`ideal/jevhome.py`) labels unnamed voices
with the display authority's `SpeakerLabeler`;
- the STT cassette's per-window diarization id comes from a named helper
and is never shown as text.
- **`v3/fake.py`.** It now accepts `max_events`. Without it, every
fake-engine v3 run exited 2 after the options gained that key.

## Privacy and production

- **The store refuses any root inside a git worktree.** Private data
lives under a 0700 root outside git. Tests use synthetic fixtures only.
- **Replays never touch production.** They write only to local emulators
under the synthetic uid `local-dev-user`.
- **`v3/prod_export.py` is the only production reader.** It is an
operator tool, run by hand under a read-only GCP agent tier for one
consenting owner and one day.
- It reads that owner's v3 recordings and derived conversations for the
day window.
- That is one day's rows, a few hundred to a few thousand reads per run.
  - It has no schedule and nothing calls it automatically.
- **No credential, uid, name, conversation id or transcript is in the
diff.** The owner uid and the gateway token are read from 0600 files by
path at the moment of use.

## Verification

Run on `m5-mbp`, at this branch rebased on `origin/main`:

- All 29 `tests/unit/test_pipeline_lab_*.py` files pass, each in its own
process, as CI runs them: `bin/omi-heavy run -- .venv/bin/python -m
pytest FILE -q`.
- New tests:
- `test_run_diff_reports_boundaries_and_home_flips_without_text` (the
output carries no segment text);
-
`test_a_shared_line_goes_to_the_earlier_conversation_whatever_the_input_order`,
which fails on the old scorer.
- `ideal.runs score` and `ideal.runs diff` match the scratch scripts on
the 11-18 and 11-19 replays. The one exception is the order fix above.
- The lab's real-day replays for #25829 ran on this code, before the
last commit's docs and tool.

## Review

There were two panel rounds:

- Round 1 had 17 findings: 16 fixed, 1 rejected with a reason.
- Round 2 had 14: the blocker and 7 others fixed, 6 deferred. Under R28
only blockers block.

Main fixes:

- Exporter outputs are owner-only and never follow symlinks, and the git
probe fails closed.
- The write fence also refuses deletes and Redis pipelines.
- The owner uid is redacted from every log record during an export.
- The proxy allows plain HTTP only to loopback.
- Pinned arms are refused when they contain untracked Python.
- Lab roots and ids are validated before any write.
- The CodeQL ReDoS and header-injection alerts are fixed.

## Follow-ups (not blocking)

- **v3 Home visibility.** `v3/export.home_visible` should follow the
product's `is_visible_conversation(hide_home=True)`: dream duplicates,
bridge-pending and settling fragments.
- **`corpus add-day --replace`.** It should clear optional v3 and audio
artifacts the new snapshot omits.
- **`run --in-place`.** It should record the sha of `HEAD`, not the
requested ref.
- **`decisions.jsonl` appends.** They should take an `flock` across the
orchestrator and arm processes.
- **Product logging.** `utils/encryption.decrypt` logs the uid on
failure. The lab redacts it, but the product log line itself is a
privacy follow-up.
- **Replay determinism.** Stamp v3 passes on the simulated clock so
default-timing replays are deterministic (see the lab `AGENTS.md`).

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
aryanorastar pushed a commit to PINYOPATTANAWASANPORN/omi that referenced this pull request Nov 20, 2026
…on does

- map the emulator's 'maximum entity size' wording to the product's size_error, so
  log_largest_write and the size backoff run as in production;
- keep the product's size warning (kind and bytes only) on the failing driver event;
- planpass passes silence_gap to planner.windows for BasedHardware#25794 refs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aryanorastar pushed a commit to PINYOPATTANAWASANPORN/omi that referenced this pull request Nov 20, 2026
…sses on request

- summary_covers_through, v3_pending_since, recorded_start/end are Firestore timestamps in
  production; seeded as strings, BasedHardware#25794's refinement failed every pass with TypeError;
- OMI_PIPELINE_LAB_V3_TRACE logs each pass's load result and preserve_finished_windows
  input/output (ids, times, statuses; no text).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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