Repository navigation
pipeline lab: per-scenario operation budgets; Finish, privacy and Home paging scenarios - #26389
Conversation
A declarative JSON scenario (origins, batch-lane recordings with sessions, stream gaps, scripted synthetic speech, transcript landing, a Finish tap with fast finish, device-sync fragments, env overlay, expectations) runs through the real v3 code on a local emulator in under a minute: python -m testing.pipeline_lab scenario run <file|name>... Events feed the unchanged v3 driver. Real code: capture admission, the Finish branch (retrieve_in_progress_conversation, finish_live_window), _manual_finish_admitted -> promote_manual_end -> fast_finish.run with its privacy fence and writer, transcript writes and wakes, reconcile/planner/ notes/Home visibility. Stand-ins (capture-close job, record admission, batch projection, sync intake) are counted per run and listed in the README with follow-ups. Committed scenarios: finish_after_reconnect_late_transcript (SCA-4385 shape, expected failure on main) and finish_single_recording_fast (passes). Slice 2 importer design in scenario/IMPORTER.md. No production code changes. Refs SCA-4386, SCA-4385 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ever-lands Finish scenarios - ScenarioOps writes external_data.recording_origin_id on batch rows, as listen stamps every generation of one client recording, so the v3 reconnect rule (same origin, new session, same device) is exercised. - finish_after_long_reconnect_gap: the incident's capture with a 360 s stream gap, longer than the 300 s silence gap; only the reconnect rule joins A and B. - finish_transcript_never_lands: fast finish off and B's batch transcript never lands (from the review of #26304); the cut must survive the Finish wait. Both are strict expected failures on main until the v3-finish-late-predecessor fix (#26304) lands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An aged sync fragment that lands before the Finish cut is stored locks by the ordinary lock delay, a separate rule; the scenario keeps to A and B. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in' into lane/pipeline-lab-scenarios
…6304 - Incident scenarios: #26304 (6e3204f) landed, so the three SCA-4385 scenarios are plain passes; their expected_failure blocks are gone. - expected_failure names the labelled checks the known bug fails (`checks`); any other failing check is `failed`, not `xfail`. - Reconnect scenarios check membership, visibility and manual end in one expect row, so one Finish conversation must satisfy all of them. - finish_target() treats a batch recording as capturing from its first audio through its seal (tie order runs the tap before the seal) and picks the newest open one, as get_in_progress_conversation does; two open captures with the same start are refused as ambiguous. - Recording and origin ids must be unique ignoring case (they name documents). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eat, scenario stack and compare Each scenario process gets its own demo-lab-<run id> Firestore project, a leased Redis database (product bounded clients pointed at it through the lab env), its own blob root, and Typesense writes off; the reset clears only the leased database. Adds scenario stack up|down|status (shared stack with a pid file under the lab root), run.json/verdict.json, --repeat determinism and scenario compare. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tonic and loop time sim (tick=False) freezes the wall clock between driver sets. product_monotonic gives product callers (utils, database, ...) a monotonic and asyncio loop clock that follows the replay: frozen at the virtual instant for a per-event liveness grace (30 s real), then real-time so product polls still end. Late reads are counted. asyncio internals, threading, gRPC and the lab keep real time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rtifacts Allowlist of wall-clock fields (seconds, timings, window, stored_at, ms, cache_hit), random lab ids (llm_call_ids counted, run_id dropped), uuid4 renamed by first sight; compare_runs/semantic_diff report JSON paths only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Overlay model_config.v3.clock: tick restores the ticking clock. The run records its clock mode and late product monotonic reads in v3_driver.json. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The child loads stack/clock.py by path (never the ref's testing tree), freezes at the day's end and reports the clock it actually saw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…twice, planpass twice) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…x, local recorder interface Cassettes record who produced their words; old cassettes read as vendor. A per-audio index lets a scenario find any cassette recorded for its file. Words may carry a confidence. cassette/local.py defines the local speech-to-text recorder interface and its registration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uct decoding) record-local runs production's parakeet-tdt-0.6b-v3 checkpoint at ASR_REVISION on CPU through the product's pin_parakeet_decoding and ParakeetWords, in 30 s windows, keyed parakeet_local/...cpu-fp32 with source local. The model stack is an optional extra (requirements-local-stt.txt) in its own venv, never imported by the default lab. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…record-local) A recording or sync fragment may give audio_file instead of speech. Its words come from the STT cassette for that exact audio and pass through the batch or sync lane code (real PipelineWorker, projection_segments, retrieve_vad_segments) before the existing landing calls write them. The result names each transcript's cassette source and which steps were product code. Adds a committed synthetic say fixture, its synthetic cassette, and audio_single_recording_finish. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…header line Co-Authored-By: Claude Opus 5.5 <[email protected]>
…_finish 286 KB, 8.9 s, 16 kHz mono PCM16, regenerated with its cassette by scenario/fixtures/make_synthetic_audio.py. Force-added past the root *.wav ignore, as backend/scripts/fixtures/parakeet_route_synthetic.wav is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A v3 account's Home is GET /v1/conversations (homeMode auto, X-Omi-Home-Ownership) plus GET /v1/conversations/live; the feed is suppressed for v3 (app/lib/providers/conversation_home_fetch.dart:115, conversations_v3_provider.dart:224). scenario/home.py calls both routes in process over ASGI against the emulator, as the lab uid (dependency override, the hermetic-test seam), after each expect checkpoint and at the end, and writes <scenario>/home.json with the bodies unmodified. New check field on_home reads the route's answer; disagreements with the lab's copy of the visibility rule are listed in home.json. run.py gets a minimal hook. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tory python -m testing.pipeline_lab scenario view <run-dir> [--port N] serves the run directory on loopback (free port by default) with the inspector's access policy: verdict and checks, Home as the route returned it with a snapshot picker and a "Not on Home" group, a timeline with recordings, seals, landings, sync arrivals, gaps, Finish and checkpoints, conversation bars, a detail drawer, the stand-ins, and base/head compare. Falls back to result.json and names each missing file. Stdlib only, no external assets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ck reads as a marker Co-Authored-By: Claude Opus 5.5 <[email protected]>
affected BASE..HEAD maps changed paths to the earliest stage (import closures, an explicit table, run-everything default) and to scenarios. The lanes stages and the chain unit are now cacheable: entries store the files a stage wrote and restore them on a hit; lane stage keys hash only the code they run. Every run reports hit/miss, seconds and LLM calls per stage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…peline-lab-scenarios
Conflicts: cli.py (view beside stack/compare), scenario/run.py. One Home hook: ScenarioOps holds the HomeRecorder and calls write_home_snapshot before each checkpoint's snapshot; run.py calls it before the final snapshot. The isolation lane's after-checkpoint wrapper and the Home lane's method wrapping are both removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e table Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s are not stored Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: cli.py (--stt beside --jobs/--repeat), scenario/run.py (materialize audio before the Home recorder and ops), spec.py (on_home and the audio constants), stack.py (--stt threaded through run_set into the isolated run_one). Scenario host state (scenario stack, recorded cassettes) now defaults to a per-user cache when the lab volume is absent (scenario/paths.py). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- One comparison for --repeat and day replays: determinism.compare_runs over SCENARIO_ARTIFACTS (result.json, home.json, v3 tasks, decisions); home.json's updated_at is Firestore update_time (emulator wall clock), allowlisted. - verdict.json carries each recording's transcript source (scripted, synthetic, local, vendor). - scenario view reads run.json, verdict.json rows, repeat-<k>/ directories (nondeterministic state) and compare.json as scenario compare writes it; plain-sentence compare summary; source tags on chips and in the drawer; rail names break only at underscores; timeline labels stack instead of overlapping, one unit style per axis, and the default range holds the Home moment shown; check rows fall back to the check's summary. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l layout fixes Nested children flatten fully (transcript tags rendered as text before), labels avoid point glyphs and sit above leader lines; tests for the real run and compare layouts and the repeat route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI shard 5 measured it at 1.26 s CPU, over the 1.00 s fast-unit limit, once v3 day replays run on the simulated clock by default. It moves to the slow-marked guardrails job, which still runs on every pull request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e paging scenarios - scenario/budget.py counts Firestore reads, writes, deletes and no-op writes (a write answered with the document's previous update_time) at the emulator client's GAPIC API, by collection, with each no-op's call site, plus vendor calls (fake gateway requests, fast-finish STT calls, cassette plays). Counts land in result.json, the verdict row, the summary, the text report and a table under the verdict in the web view, and are compared between repeats. Reads through a real-time TTL cache (dream_control) are kept apart. - Scenario format: an optional budget block (each key a budget_<key> check), account (cloud audio off, sync_off_at), seed (Home history in runs), finish.again_at, and recording / finish_response / home_paging checks plus titled, has_notes, home_titled, home_has_notes and holders fields. - Eight new scenarios: next recording opens before the current closes, Finish after a second close (expected_failure: Finish targets the older open window), Finish on a closed conversation on Home, double tap, nothing to finish, cloud audio off, privacy refusal before fast finish (zero STT calls), and Home paging past hidden runs. - Every committed scenario has a budget from its measured counts; reach.json re-measured; CI budget for the advisory job 3 -> 5 minutes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o lane/plf-followup
CI shard 6 measured test_add_day_run_baseline_and_inspector at 1.03 s CPU, over the 1.00 s fast-unit limit. Rather than chase one shard at a time, move every lab test a local scan measured near the limit (whole-pipeline runs, the sample determinism run, the grace-period clock test) to the slow-marked guardrails job, which still runs on every pull request. A rescan at 0.6 s leaves only test_pipeline_lab_core_ledger, which is unchanged from main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e trace Co-Authored-By: Claude Opus 5.5 <[email protected]>
…of compared counts Its fenced write lands or not depending on thread timing inside one event (utils/ai_profile_refresh.py -> database/users.py write_ai_user_profile_if_unchanged), which made two scenarios' counts differ between repeats. Shown in ops.racy_ops. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…chet) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aces A stage-cache restore does not write llm_calls.jsonl or decisions.jsonl (orchestrator.RUN_FILES), so comparing an executed run with its cached repeat reported nondeterminism on those files alone. They are now marked as execution traces: compared when both runs have them, listed under traces_one_sided when only one does. Product outputs present on one side stay differences. Codex review on #26303. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis 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: 6e01701c68
ℹ️ 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".
| with tempfile.TemporaryDirectory(prefix='plab-local-stt-') as work: | ||
| pcm_path, out_path = Path(work, 'audio.pcm'), Path(work, 'words.json') |
There was a problem hiding this comment.
Keep local STT temporary data under the private lab root
When --stt record-local uses the separate interpreter on private audio, this creates audio.pcm and the recognized words.json in the system temporary directory rather than the configured lab root. Although the temporary directory is owner-only, this violates the lab's explicit private-file confinement rule and leaves private data outside that root if the process is killed before cleanup. Create the worker directory beneath the validated private lab root instead.
AGENTS.md reference: backend/testing/pipeline_lab/AGENTS.md:L15-L16
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed on the base branch (#26303) in ec33ed7. Worker now writes the PCM and words into a per-call directory under an owner-only tmp/local-stt in the scenario lab root (store.ensure_private_dir), never the system temp directory. The directory is removed after each call. Tests: test_worker_round_trip_through_files asserts the files land under the lab root, at 0700, and are cleaned up.
| Artifact('llm_calls.jsonl', drop=frozenset({'at', 'id', 'usd', 'recorded_usd'}), unordered=True), | ||
| # Orchestrator decisions are stamped with real time (``utc_iso``); the decision itself is semantic. | ||
| Artifact('decisions.jsonl', drop=frozenset({'at'}), unordered=True), |
There was a problem hiding this comment.
Account for stage-cache hits in semantic comparisons
When an unchanged day replay hits the new stage cache, its product artifacts are restored but llm_calls.jsonl and decisions.jsonl are deliberately not restored. The new determinism.ARTIFACTS nevertheless compares both files, so comparing an executed run with its cached repeat reports missing-file differences even when their product outputs are identical. I reproduced this with a cacheable driver: both runs succeeded, the second was cached, and compare_runs reported decisions.jsonl $ (only_a). Align the comparison with cache provenance or retain equivalent semantic evidence separately so the documented repeatability check does not report false nondeterminism.
AGENTS.md reference: backend/testing/pipeline_lab/AGENTS.md:L30-L35
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Already fixed on the base branch (#26303) in 6044960, after this branch was cut. llm_calls.jsonl and decisions.jsonl are marked as execution traces. They are compared when both runs have them, and listed under traces_one_sided (not counted as a difference) when a stage-cache restore omits them. This PR picks it up when it merges #26303. Test: test_a_cached_repeat_without_execution_traces_compares_equal.
With --stt record-local through the separate interpreter, the worker wrote the PCM and recognised words to the system temp directory. They now go to an owner-only directory under the scenario lab root (ensure_private_dir), one removed per call, so private audio stays inside the lab root even if the process is killed. Codex review (P1) on #26389. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… review Private files: - scenario --keep and the child's --out are validated with ensure_private_dir: an existing group/other readable tree is refused, not chmod-ed; each per-scenario directory is validated too. Default output goes under the private scenario lab root, not system temp. - home.json, result.json, scenario_error.log, called_files.json, stderr.log, run.json, verdict.json, compare.json, the shared stack's stack.json, lock, firebase.json and emulator logs are written 0600 (atomic where possible). - the scenario lab root (default ~/.cache/pipeline-lab) is created owner-only; an open default root left by an older lab is tightened, a configured one is refused. - scenario children and the emulators run under umask 077. - private_subdir creates every missing parent 0700 (mkdir -p used the umask for parents). - the inspector's verdict root, v3 trace rows and v3 smoke's copied overlay go through the same helpers. Cache keys: - CodeState records a staged rename's or copy's source path, the executable bit, symlink targets and nested-repository contents. - refused or uncached stage results still contribute their artifact digest to downstream keys. - ingest stages key on the raw baseline fields a missing timeline.json is built from. - transcribe keys the ambient env values its product STT code can read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o plf-followup-local # Conflicts: # backend/testing/pipeline_lab/scenario/run.py
replay_sync_lane wrote owner audio as WAV files into a mkdtemp in the system temp directory when no scratch was given (every caller). Day replays now pass <store root>/tmp/sync and scenarios (and the default) the scenario lab root's tmp/sync, both validated owner-only. Ingest-lane tests point the root at tmp. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… private - run_set clears an earlier run from a reused --keep directory before any job starts (every scenario directory holding scenario.json, plus run.json, verdict.json, compare.json); the stack's .stack and other files stay. Appended artifacts (v3_tasks.jsonl, decisions.jsonl, sink logs) no longer mix runs. - scenario audio passes the sync lane an explicit private scratch directory. - store.private_tempdir points tempfile and TMPDIR at <root>/tmp/product for the scenario child, the transcribe replay and record-stt, and the chain and v3 entries, so the product's own temp files (utils/sync, utils/batch_pipeline) on owner audio stay inside the lab root. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o plf-followup-local
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…he index Cassette.save() used to write only the cassette file, so an audio scenario without a provider/model pin missed every cassette recorded before the by-audio index existed (only pinned lookups had a fallback). When the index has no live entry for an audio hash, recorded_for_audio now scans the stored cassettes for that hash (substring filter, then parse and path check) and backfills the index, so the scan runs once per audio. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o plf-followup-local
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d23b26b74
ℹ️ 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".
| if not seen: | ||
| seen = {c.key.digest: c for c in _unindexed_for_audio(audio, root)} |
There was a problem hiding this comment.
Backfill legacy cassettes before treating the index as complete
When a lab root contains a vendor cassette recorded before the by-audio index existed, recording a new local cassette for the same audio creates a nonempty index containing only the local entry. This condition then permanently skips discovery of the older vendor cassette. Consequently, an unpinned scenario replay silently uses local words despite scenario/audio.py explicitly preferring vendor evidence. I reproduced this with two cassette files on disk: recorded_for_audio returned only the newly indexed local cassette. Backfill existing cassettes before creating the first index entry, or track migration completeness separately from whether the index has any live entries.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 7b99633. The pre-index scan now runs until the by-audio index records a backfill marker (BACKFILL_MARKER). It merges the unindexed cassettes with the indexed ones, appends only the missing rows plus the marker, and later lookups read the index alone. Test: tests/unit/test_pipeline_lab_scenario_audio.py::test_unpinned_replay_finds_a_pre_index_vendor_cassette_after_a_local_one_was_indexed (older unindexed vendor cassette plus newer indexed local one: vendor is chosen, no second scan).
| # the files one scenario run writes, so a repeat and a day replay agree on what "the same" means. | ||
| SCENARIO_ARTIFACTS: tuple[Artifact, ...] = ( | ||
| # ``log`` is the path of this run's own error log (it names the run directory), not a product output. | ||
| Artifact('result.json', drop=frozenset({'log'}), optional=False), |
There was a problem hiding this comment.
Exclude STT cache provenance from repeat comparisons
When scenario run --repeat 2 --stt record-local (or record-vendor) starts without the requested cassette cached, the first execution reports origin='recorded' and its repeat reports origin='lab_root', even though both consume the identical saved cassette. SCENARIO_ARTIFACTS compares this provenance in result.json, so the run is inevitably marked nondeterministic and exits unsuccessfully despite identical product results. I reproduced consecutive prepare calls with a deterministic local recorder: comparison reported only result.json $.audio.recordings[0].origin (changed). Retain provenance for inspection, but exclude it and any provenance-derived descriptions from the semantic repeat comparison.
AGENTS.md reference: backend/testing/pipeline_lab/AGENTS.md:L30-L35
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 7b99633. The recording summary now reports provenance as cassette_origin, and SCENARIO_ARTIFACTS drops that one field from result.json. The cassette digest, word count and source are still compared, and so is a device origin (gaps). Test: tests/unit/test_pipeline_lab_scenario_audio.py::test_record_mode_repeat_is_deterministic_despite_cache_provenance (two record-local prepares, recorded then lab_root, compare as the same; a changed cassette or gap origin still differs).
| BACKEND = Path(__file__).resolve().parents[3] | ||
| _LAB_DIR = str(BACKEND / 'testing' / 'pipeline_lab') |
There was a problem hiding this comment.
Resolve budget stack frames against the product arm
When scenario compare runs a pinned ref, worktrees.vendor_lab copies this module into a separate vendor directory, so deriving BACKEND from __file__ points at that directory rather than the backend being measured. Consequently, racy_caller never recognizes the product's utils/ai_profile_refresh.py frames and includes its deliberately excluded account operations in budget totals; call_site also reports every product write as (outside backend). Comparing a pinned base with the default working-tree head therefore applies different counting rules to the two arms and can produce false budget regressions. Loading a vendored copy reproduced both failures for the same product frame. Resolve the product backend independently of the vendored harness location, as scenario/run.py:product_runtime_env already does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 7b99633. call_site and racy_caller now resolve frames against product_backend(), which is the tree database imports from (the same approach as product_runtime_env), and not against the vendored lab's __file__. Frames from the running lab and from the arm's own copy of the lab are both excluded. Test: tests/unit/test_pipeline_lab_scenario_budget.py::test_frames_resolve_against_the_product_arm_not_the_vendored_lab (separate arm and vendor roots: the arm's utils/ai_profile_refresh.py is the racy caller and its write is attributed; against the vendor root nothing is).
…rm-relative budget frames - cassette/format.py: the pre-index scan runs until the by-audio index records a backfill marker, so an index holding only newer cassettes no longer hides older unindexed ones. - determinism.py / scenario/audio.py: the STT cassette provenance is reported as cassette_origin and dropped from result.json repeat comparison; the cassette digest and words stay compared. - scenario/budget.py: call sites and racy callers resolve against the product backend that `database` imports from (a compare arm), not the vendored lab's location. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rios, Home route, audio, isolation, view, CI) (#26303) * pipeline lab: scripted v3 Finish scenarios (slice 1) A declarative JSON scenario (origins, batch-lane recordings with sessions, stream gaps, scripted synthetic speech, transcript landing, a Finish tap with fast finish, device-sync fragments, env overlay, expectations) runs through the real v3 code on a local emulator in under a minute: python -m testing.pipeline_lab scenario run <file|name>... Events feed the unchanged v3 driver. Real code: capture admission, the Finish branch (retrieve_in_progress_conversation, finish_live_window), _manual_finish_admitted -> promote_manual_end -> fast_finish.run with its privacy fence and writer, transcript writes and wakes, reconcile/planner/ notes/Home visibility. Stand-ins (capture-close job, record admission, batch projection, sync intake) are counted per run and listed in the README with follow-ups. Committed scenarios: finish_after_reconnect_late_transcript (SCA-4385 shape, expected failure on main) and finish_single_recording_fast (passes). Slice 2 importer design in scenario/IMPORTER.md. No production code changes. Refs SCA-4386, SCA-4385 Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario rows name their capture origin; long-gap and never-lands Finish scenarios - ScenarioOps writes external_data.recording_origin_id on batch rows, as listen stamps every generation of one client recording, so the v3 reconnect rule (same origin, new session, same device) is exercised. - finish_after_long_reconnect_gap: the incident's capture with a 360 s stream gap, longer than the 300 s silence gap; only the reconnect rule joins A and B. - finish_transcript_never_lands: fast finish off and B's batch transcript never lands (from the review of #26304); the cut must survive the Finish wait. Both are strict expected failures on main until the v3-finish-late-predecessor fix (#26304) lands. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: long-gap scenario tests the reconnect rule alone An aged sync fragment that lands before the Finish cut is stored locks by the ordinary lock delay, a separate rule; the scenario keeps to A and B. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario review fixes; incident scenarios pass after #26304 - Incident scenarios: #26304 (6e3204f) landed, so the three SCA-4385 scenarios are plain passes; their expected_failure blocks are gone. - expected_failure names the labelled checks the known bug fails (`checks`); any other failing check is `failed`, not `xfail`. - Reconnect scenarios check membership, visibility and manual end in one expect row, so one Finish conversation must satisfy all of them. - finish_target() treats a batch recording as capturing from its first audio through its seal (tie order runs the tap before the seal) and picks the newest open one, as get_in_progress_conversation does; two open captures with the same start are refused as ambiguous. - Recording and origin ids must be unique ignoring case (they name documents). Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: per-run isolation, run directory contract, --jobs/--repeat, scenario stack and compare Each scenario process gets its own demo-lab-<run id> Firestore project, a leased Redis database (product bounded clients pointed at it through the lab env), its own blob root, and Typesense writes off; the reset clears only the leased database. Adds scenario stack up|down|status (shared stack with a pid file under the lab root), run.json/verdict.json, --repeat determinism and scenario compare. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: simulated clock mode with replay-following product monotonic and loop time sim (tick=False) freezes the wall clock between driver sets. product_monotonic gives product callers (utils, database, ...) a monotonic and asyncio loop clock that follows the replay: frozen at the virtual instant for a per-event liveness grace (30 s real), then real-time so product polls still end. Late reads are counted. asyncio internals, threading, gRPC and the lab keep real time. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: determinism.py, one definition of a replay's semantic artifacts Allowlist of wall-clock fields (seconds, timings, window, stored_at, ms, cache_hit), random lab ids (llm_call_ids counted, run_id dropped), uuid4 renamed by first sight; compare_runs/semantic_diff report JSON paths only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: v3 day replay runs on the simulated clock by default Overlay model_config.v3.clock: tick restores the ticking clock. The run records its clock mode and late product monotonic reads in v3_driver.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: planpass child runs on the lab's simulated clock The child loads stack/clock.py by path (never the ref's testing tree), freezes at the day's end and reports the clock it actually saw. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: determinism tests (jitter sim vs tick, fake-engine day twice, planpass twice) Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: cassette source (vendor|local|synthetic), by-audio index, local recorder interface Cassettes record who produced their words; old cassettes read as vendor. A per-audio index lets a scenario find any cassette recorded for its file. Words may carry a confidence. cassette/local.py defines the local speech-to-text recorder interface and its registration. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: local Parakeet recorder (optional extra, CPU fp32, product decoding) record-local runs production's parakeet-tdt-0.6b-v3 checkpoint at ASR_REVISION on CPU through the product's pin_parakeet_decoding and ParakeetWords, in 30 s windows, keyed parakeet_local/...cpu-fp32 with source local. The model stack is an optional extra (requirements-local-stt.txt) in its own venv, never imported by the default lab. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenarios from audio files (--stt replay|record-vendor|record-local) A recording or sync fragment may give audio_file instead of speech. Its words come from the STT cassette for that exact audio and pass through the batch or sync lane code (real PipelineWorker, projection_segments, retrieve_vad_segments) before the existing landing calls write them. The result names each transcript's cassette source and which steps were product code. Adds a committed synthetic say fixture, its synthetic cassette, and audio_single_recording_finish. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario run prints the repeat number on each report's header line Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: commit the synthetic say WAV for audio_single_recording_finish 286 KB, 8.9 s, 16 kHz mono PCM16, regenerated with its cassette by scenario/fixtures/make_synthetic_audio.py. Force-added past the root *.wav ignore, as backend/scripts/fixtures/parakeet_route_synthetic.wav is. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario Home stage from the product's own Home route A v3 account's Home is GET /v1/conversations (homeMode auto, X-Omi-Home-Ownership) plus GET /v1/conversations/live; the feed is suppressed for v3 (app/lib/providers/conversation_home_fetch.dart:115, conversations_v3_provider.dart:224). scenario/home.py calls both routes in process over ASGI against the emulator, as the lab uid (dependency override, the hermetic-test seam), after each expect checkpoint and at the end, and writes <scenario>/home.json with the bodies unmodified. New check field on_home reads the route's answer; disagreements with the lab's copy of the visibility rule are listed in home.json. run.py gets a minimal hook. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario view, a stateless read-only page per run directory python -m testing.pipeline_lab scenario view <run-dir> [--port N] serves the run directory on loopback (free port by default) with the inspector's access policy: verdict and checks, Home as the route returned it with a snapshot picker and a "Not on Home" group, a timeline with recordings, seals, landings, sync arrivals, gaps, Finish and checkpoints, conversation bars, a detail drawer, the stand-ins, and base/head compare. Falls back to result.json and names each missing file. Stdlib only, no external assets. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: rename a scenario job list the deferred-work marker check reads as a marker Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: affected map, stored stage outputs, per-stage cache report affected BASE..HEAD maps changed paths to the earliest stage (import closures, an explicit table, run-everything default) and to scenarios. The lanes stages and the chain unit are now cacheable: entries store the files a stage wrote and restore them on a hit; lane stage keys hash only the code they run. Every run reports hit/miss, seconds and LLM calls per stage. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: chain phase timings in the stage report; text-mode stage table Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: refresh never takes a stored stage; failed chain results are not stored Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: build affected closures once per test module Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: integrate isolation, Home, audio and clock lanes - One comparison for --repeat and day replays: determinism.compare_runs over SCENARIO_ARTIFACTS (result.json, home.json, v3 tasks, decisions); home.json's updated_at is Firestore update_time (emulator wall clock), allowlisted. - verdict.json carries each recording's transcript source (scripted, synthetic, local, vendor). - scenario view reads run.json, verdict.json rows, repeat-<k>/ directories (nondeterministic state) and compare.json as scenario compare writes it; plain-sentence compare summary; source tags on chips and in the drawer; rail names break only at underscores; timeline labels stack instead of overlapping, one unit style per axis, and the default range holds the Home moment shown; check rows fall back to the check's summary. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario view reads repeats and real compare rows; label layout fixes Nested children flatten fully (transcript tags rendered as text before), labels avoid point glyphs and sit above leader lines; tests for the real run and compare layouts and the repeat route. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario run with no files runs every committed scenario Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: scenario-aware affected, sim-clock chain, true stand-ins, one view command, advisory CI - affected names scenarios from a table (v3 runtime, Finish, fast finish, visibility, Home routes, harness, view: all; audio fixtures, cassettes, lanes: audio scenarios) and from measured reach (scenario/reach.json, written by scenario run --trace-calls + scenario reach); needs no run store. - Classic chain on LabClock 'sim' with product_monotonic; model_config.v3.clock "tick" restores ticking for both replays. run_chain_smoke.sh finds Homebrew openjdk@21; the scenario stack finds firebase in the repo pin or ~/.local/bin, and can use a given Redis and start only the emulator. - Stand-in lines are worded per run from its counters and transcript sources (scenario/standins.py) in result.json, verdict.json, the text report and the web view; audio runs list the audio-to-words steps. - Fake upstream answers Jev /v1/systemone (2xx), so jev_conversation_relevance is cached on re-runs. - view PATH opens the scenario page or the day-replay inspector from the path; scenario summary DIR prints a markdown verdict. - CI: advisory "Pipeline Lab Scenarios" job in backend-hermetic-e2e.yml (every PR and merge queue, skipped summary without a backend change, run directory artifact). Emulator proofs, desktop backend contracts and Static Contracts path filters widened to their suites' static import closures. - Docs: README Start here and scenario sections, lab AGENTS.md repeatability and PR rule, routing lines in backend/AGENTS.md and AGENTS.md; tie-order notes in scenario/spec.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> * checks manifest: exempt a check script named only in the emulator-proofs path filter Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: address Codex review on #26303 - Stage cache: a v3 replay whose arrival or reconcile event raised finishes partial with no failed conversation; cache_ok now rejects it using the v3 driver status carried in the discard summary. The summary also read the driver counts from the wrong level of chain_entry.json; fixed. - Home: annotate_rows finds disagreements after home.json was written at capture; rewrite home.json when new ones are found so the file the web view reads matches result.json. - Web view: an audio_file recording may omit `audio`; take its span and seal from the run timeline's capture_start and seal events instead of drawing a zero-width recording at t0. Sync fragments without `audio` use their arrival. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: second Codex review round and the real-clock budget ratchet - Stage keys carry the executing lab package's identity (sources, no bytecode). A pinned ref runs this checkout's vendored lab, so the product arm's code key alone could serve artifacts an older harness produced. - A sync fragment's arrives_at of 0 was treated as absent and replaced by the audio end, in the plan and in the row's created_at; use an explicit None check. - test_pipeline_lab_scenario_audio: the record-vendor spend caps are dollars, not clock budgets; name them as locals so the real-clock budget ratchet (test_real_clock_budget_ratchet) does not read budget_usd=0.03 as a 30 ms budget. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: third Codex review round - A Home route that raises or does not answer 200 (list or live) now makes the scenario an error, even when no check reads on_home; the failures are listed in result.json's home summary. - determinism: unordered JSONL rows are ordered with their random ids masked before ids are renamed to ordinals, so the same rows written in a different order by concurrent workers compare equal. - scenario run_one starts each scenario in its own process group and, on timeout, stops the whole group, so a local STT worker on its own interpreter does not outlive the scenario. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab tests: mark whole-pipeline tests slow for the fast-unit CPU guard CI shard 8 failed test_refresh_mode_reruns_and_failed_chain_results_are_not_stored at 1.03 s CPU over the 1.00 s fast-unit limit. The stage-reuse tests that run whole lab pipelines (the lab fixture) and the synthetic-day determinism test (0.90 s locally) move to the slow-marked guardrails job, which still runs on every pull request. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci budget: lab job at its measured p50; Linux cap for the #26303 additions The ci-budget hygiene check failed once main grew to 14381 of the 14440 Linux cap. Pipeline Lab Scenarios was budgeted at a 7-minute p50; its first four PR runs took 1m57s-2m39s, so it is budgeted at 3 (+186 instead of +434). The contract-suite path-filter widening adds 320. Forecast 14887; Linux cap 14900, with the rationale appended in the house format. macOS and time-to-signal caps unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: failed transcribe replays are not stored in the stage cache A lane replay can exit 0 with conversations marked failed (a transient worker or VAD error); those kept their stored transcript. TranscribeStage now rejects such a result from the stage cache, as the chain stage does, so the next identical run replays again. Diagnostics stay in the run warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: keep only deterministic transcribe failures in the stage cache Follow-up to 48fdd99, which rejected every failed replay and so stopped caching days with a plain cassette miss (three stage-reuse tests). The ingest index now records each row's error; TranscribeStage rejects only failures the key does not cover (a worker or VAD error), while no_audio, cassette_miss and lane_not_replayed are keyed by audio, cassette inventory and STT selection. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: key lane stages on the baseline languages replay reads lanes/day.py takes each conversation's language from load_baseline (raw rows preferred), which the lane cache keys did not cover, so a corrected language could restore stale ingest artifacts. Key on the (id, language) pairs only: other raw fields such as transcript text feed only the chain, which keeps rerunning alone when they change. Codex review on #26303. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab tests: mark the v3 day replay e2e test slow CI shard 5 measured it at 1.26 s CPU, over the 1.00 s fast-unit limit, once v3 day replays run on the simulated clock by default. It moves to the slow-marked guardrails job, which still runs on every pull request. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab tests: mark the remaining near-limit pipeline tests slow CI shard 6 measured test_add_day_run_baseline_and_inspector at 1.03 s CPU, over the 1.00 s fast-unit limit. Rather than chase one shard at a time, move every lab test a local scan measured near the limit (whole-pipeline runs, the sample determinism run, the grace-period clock test) to the slow-marked guardrails job, which still runs on every pull request. A rescan at 0.6 s leaves only test_pipeline_lab_core_ledger, which is unchanged from main. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: determinism comparison tolerates one-sided execution traces A stage-cache restore does not write llm_calls.jsonl or decisions.jsonl (orchestrator.RUN_FILES), so comparing an executed run with its cached repeat reported nondeterminism on those files alone. They are now marked as execution traces: compared when both runs have them, listed under traces_one_sided when only one does. Product outputs present on one side stay differences. Codex review on #26303. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: local STT worker files stay under the private lab root With --stt record-local through the separate interpreter, the worker wrote the PCM and recognised words to the system temp directory. They now go to an owner-only directory under the scenario lab root (ensure_private_dir), one removed per call, so private audio stays inside the lab root even if the process is killed. Codex review (P1) on #26389. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: confine private files and close cache-key gaps found in review Private files: - scenario --keep and the child's --out are validated with ensure_private_dir: an existing group/other readable tree is refused, not chmod-ed; each per-scenario directory is validated too. Default output goes under the private scenario lab root, not system temp. - home.json, result.json, scenario_error.log, called_files.json, stderr.log, run.json, verdict.json, compare.json, the shared stack's stack.json, lock, firebase.json and emulator logs are written 0600 (atomic where possible). - the scenario lab root (default ~/.cache/pipeline-lab) is created owner-only; an open default root left by an older lab is tightened, a configured one is refused. - scenario children and the emulators run under umask 077. - private_subdir creates every missing parent 0700 (mkdir -p used the umask for parents). - the inspector's verdict root, v3 trace rows and v3 smoke's copied overlay go through the same helpers. Cache keys: - CodeState records a staged rename's or copy's source path, the executable bit, symlink targets and nested-repository contents. - refused or uncached stage results still contribute their artifact digest to downstream keys. - ingest stages key on the raw baseline fields a missing timeline.json is built from. - transcribe keys the ambient env values its product STT code can read. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: sync lane work files stay under the private lab root replay_sync_lane wrote owner audio as WAV files into a mkdtemp in the system temp directory when no scratch was given (every caller). Day replays now pass <store root>/tmp/sync and scenarios (and the default) the scenario lab root's tmp/sync, both validated owner-only. Ingest-lane tests point the root at tmp. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: fresh scenario output on reuse; product temp files stay private - run_set clears an earlier run from a reused --keep directory before any job starts (every scenario directory holding scenario.json, plus run.json, verdict.json, compare.json); the stack's .stack and other files stay. Appended artifacts (v3_tasks.jsonl, decisions.jsonl, sink logs) no longer mix runs. - scenario audio passes the sync lane an explicit private scratch directory. - store.private_tempdir points tempfile and TMPDIR at <root>/tmp/product for the scenario child, the transcribe replay and record-stt, and the chain and v3 entries, so the product's own temp files (utils/sync, utils/batch_pipeline) on owner audio stay inside the lab root. Co-Authored-By: Claude Opus 5.5 <[email protected]> * pipeline lab: unpinned audio replay finds cassettes recorded before the index Cassette.save() used to write only the cassette file, so an audio scenario without a provider/model pin missed every cassette recorded before the by-audio index existed (only pinned lookups had a fallback). When the index has no live entry for an audio hash, recorded_for_audio now scans the stored cassettes for that hash (substring filter, then parse and path check) and backfills the index, so the scan runs once per audio. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
# Conflicts: # .github/ci-budget.yaml # backend/testing/pipeline_lab/README.md # backend/testing/pipeline_lab/cassette/format.py # backend/testing/pipeline_lab/determinism.py # backend/testing/pipeline_lab/inspector/static/scenario.css # backend/testing/pipeline_lab/inspector/static/scenario.js # backend/testing/pipeline_lab/scenario/audio.py # backend/testing/pipeline_lab/scenario/checks.py # backend/testing/pipeline_lab/scenario/home.py # backend/testing/pipeline_lab/scenario/ops.py # backend/testing/pipeline_lab/scenario/reach.json # backend/testing/pipeline_lab/scenario/run.py # backend/testing/pipeline_lab/scenario/scenarios/audio_single_recording_finish.json # backend/testing/pipeline_lab/scenario/scenarios/finish_after_long_reconnect_gap.json # backend/testing/pipeline_lab/scenario/scenarios/finish_after_reconnect_late_transcript.json # backend/testing/pipeline_lab/scenario/scenarios/finish_single_recording_fast.json # backend/testing/pipeline_lab/scenario/scenarios/finish_transcript_never_lands.json # backend/testing/pipeline_lab/scenario/spec.py # backend/testing/pipeline_lab/scenario/stack.py # backend/testing/pipeline_lab/scenario/verdict.py # backend/tests/unit/test_pipeline_lab_affected.py # backend/tests/unit/test_pipeline_lab_scenario.py # backend/tests/unit/test_pipeline_lab_scenario_audio.py # backend/tests/unit/test_pipeline_lab_verdict.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb89b7ce83
ℹ️ 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".
| pb = _pb(response) | ||
| if pb.HasField('document'): | ||
| found += 1 | ||
| counter.add('reads', pb.document.name) |
There was a problem hiding this comment.
Count skipped query results toward read budgets
When Home paging uses the legacy offset path (with indexed Home and the conversation-list cursor lever disabled), database/conversations.py:1440 issues .offset(offset), whose skipped documents also incur reads. This wrapper counts only responses containing a document and ignores RunQueryResponse.skipped_results, so these runs underreport reads and can pass budgets despite exceeding their caps. A response with 50 skipped results and one returned document currently records only one read instead of 51. Include skipped results in the queried collection's count and apply the empty-query minimum only after accounting for them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed, and tracked with the proposed fix in #26395. This is a lab-tooling issue with no product impact, so it is deferred to a follow-up rather than holding this PR.
| 'passed': bool(row.get('ok')), | ||
| 'expected': expected_of(check), | ||
| 'actual': actual_of(check, snapshot, result.get('finish_target')), | ||
| 'actual': actual_of(check, snapshot, result.get('finish_target'), facts), |
There was a problem hiding this comment.
Preserve checkpoint facts when building timed verdicts
For a timed recording or finish_response check, _on_checkpoint evaluates the facts available at that instant, but this call reconstructs its actual evidence using the run's final fast_finish and finish_taps values. For example, a check asserting fast_finish="none" at 30 seconds passes before Finish, yet its verdict reports actual.fast_finish="written" after fast finish completes. A failed response check before a tap can likewise display the later successful response as its evidence. Save the facts alongside each checkpoint and use those for timed verdict rows so the reported actual values explain the recorded pass or failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed, and tracked with the proposed fix in #26395. This is a lab-tooling issue with no product impact, so it is deferred to a follow-up rather than holding this PR.
…s tail (#26419) ## Summary When Finish resolves to a live v3 window and a capture sealed after that window's last speech, Finish now also finishes that newer capture. Before, it cut only the window's tail. The bug was reproduced by pipeline-lab `finish_after_second_close` (#26389): 1. Recording A seals. 2. Recording B seals about two minutes later. B is a pendant or server-batch capture still waiting on its transcript, so no window lists it in `v3_recording_ids`. 3. The user taps Finish. A's window was still live: idle 125 s, inside `live.MAX_IDLE` = 2 h. So `finish_live_window` called `request_finish` on that window, which cut `members[-1]` = A. B got neither the manual-end cut nor a fast finish, and a short B stayed hidden under the Home word floor. The #26288 single-capture fallback and the #26361 named-window path both run only when no window is live. ## DESIGN **Reads and writes.** This changes only the live-window Finish transaction, with `CONVERSATIONS_V3_FINISH_NEWER_CAPTURE` on. - **Reads** (on top of main's window and tail-recording reads): - the existing `_recent_finish_sources` query: at most 8 documents, 1 billed read when empty; - when a newer capture qualifies, the account-deletion marker, then by path: | Path | Extra reads after the marker | | --- | --- | | Live-lane capture moved to | none | | Server-batch capture whose speech landed (`newer_recording_*`) | **B's native ledger, 1 read** (`_finish_capture` → `_native_projection_state`, since `newer_state` is None) | | Marked capture, pending-retry (a later tap on a still-requested batch B: `newer_already_requested` / `newer_consumed`) | **B's native ledger, 1 read** (same call) | | Stored both (`newer_dual_*`) | **2 ledger reads**: B's, plus A's when A is batch. A's is the read the tail cut always made, now ahead of both writes | | Selected, then declined | that path's ledger read; the tail's own batch ledger read is unchanged | Pinned by `test_server_batch_redirect_reads_the_capture_ledger_once`, `test_marked_pending_retry_reads_the_capture_ledger_once`, `test_stored_both_reads_each_ledger_once_before_any_write` (exact ordered read paths). - **Settlement:** none added. The Finish-to-visible sample is read from the derived row `settle_processing` already reads. - **Writes:** - **up to 2 documents** in the stored-both case: A's window-tail cut and B's recording-scoped request; - otherwise exactly 1, as before; - the Finish stamp (`v3_finish_requested`) rides in the write the transaction already makes, and the planner carries it in the derived-row write it already makes: **no added write**. - Off means the transaction is main's, plus the `tail` stamp in its existing write. - **Provider cost:** storing B's request makes B a fast-finish candidate. That adds at most one fast-finish pass per stored-both Finish, even when B turns out silent. - **Chunked (the default since #26344, production `on`):** each unit is split into chunks of at most 5 min with 3 s of overlap, sent concurrently. A B of up to 20 min (`MAX_SECONDS`) is a few prerecorded requests; the lab's 80 s B is one (STT 0 → 1). - **Chunking off:** one request per unit, at most `MAX_UNITS` (8), up to 20 min. - **Bounds:** - `CONVERSATIONS_V3_FAST_FINISH`: `cohort` by default, but production runs `on` for the services that serve Finish and admission, so the cohort does not limit it there. - A B over 20 min runs only for the long canary: `CONVERSATIONS_V3_FAST_FINISH_LONG_PERCENT` (25 in production) and `CONVERSATIONS_V3_FAST_FINISH_LONG_DAILY_SECONDS` (7200 s of such audio per UTC day across the fleet in production). That is the only fast-finish daily cap; a long pass reserves its planned seconds before any spend. - The shared funding gate (`fast_finish.funded` → `sync_admission(lane='batch')`): consent and the owner's funded STT plan allowance. **Production readback:** 1. `omi_conversations_v3_finish_no_pointer_total` by `outcome` for the `newer_*` and `newer_dual_*` labels, against the tail path's `cut` / `requested`. That shows how often Finish finds a newer capture and which branch it takes. 2. **The share of Finishes whose response target becomes visible within 60 s:** `omi_conversations_v3_finish_to_visible_seconds{path}` (`tail` / `newer` / `newer_dual`), `le="60"` bucket over `_count`, compared by path. One sample per Finish, at the response target's first visible manual-end settlement; kept by the sync scrape profile. 3. `omi_conversations_v3_finish_newer_declined_total{reason}`: how often a selected newer capture declined and the tail answered. ## Change - `database/conversations_v3_live.py` - `request_finish(..., newer_capture=False)` gets a new parameter. When it is true, the transaction runs the existing `_recent_finish_sources` scan after its two document reads and before any write. - `_newer_capture()` selects the capture. A capture qualifies when it: - is a sealed Listen capture; - ended strictly after the window's `finished_at`; - is not one of the window's sources; - carries `has_content` (a projection that landed empty clears it); - passes `_capture_ineligible(row, now)`: sealed within `RECENT_FINISH_AGE`, unclaimed, not marked for another window, not private, deleted, discarded, locked, merged, partial or upload-failed. The newest qualifying capture wins, as in `_latest_capture`. The account-deletion check (`_account_deleting`, shared with `_live_window_or_deleting`) runs before any write. - **B's speech has landed** (a live-lane capture with `has_finish_content`, or a batch capture whose projection landed): redirect only. B gets the recording-scoped cut or request through `_finish_capture`, and the response names B. Outcomes are `newer_recording_cut` / `newer_recording_requested`. - **B is a server-batch capture whose projection has not landed** (`_batch_speech_landed`). It may hold only silence: the session's last capture often does, after the quiet timeout seals A and the device stop seals B. The same transaction: - stores A's window-tail cut, exactly what main stores; - stores B's recording-scoped request. Both ledger reads come first. `_finish_window_tail` and `_finish_capture` take a pre-read `state=`, and StrictFirestore enforces the order in tests. The response names **A's window**, because the cut landed there. The outcome is `newer_dual_<tail outcome>`. - Silent B: A is cut at once, as on main, and B's request clears at whole-record completion. - Speech B: A is cut and B's request becomes B's own manual end, so B shows as its own card. - **Why not `has_finish_content` for batch B?** In production it is true for almost every batch capture right after creation. `create_in_progress_conversation` → `mark_new` stamps `v3_speech_landed_at` at creation (`utils/conversations/v3/triggers.py:61-69`), and audio custody sets `has_content` on any committed audio (`database/server_batch_audio.py:60`). So a batch capture's speech has landed only with its projection: `record_projection_revision` together with `has_content`. The lab, which creates captures through the product path, shows the same stamp. A test pins it: `created_stamp=True` fails if the check goes back to `has_finish_content`. - **The window-tail cut alone** runs unchanged when: - no capture qualifies; - two captures tie exactly on `finished_at`; - the scan is full with its oldest row still newer than the window; - `_finish_capture` declines or answers `already_empty`. It writes nothing in those cases. - **Retries never cut A twice.** - If A already carries this window's Finish (the stored-both case), the tail path answers (`already_cut` / `already_requested`) and B is not touched. - A capture an earlier recording-scoped Finish marked answers through `_finish_capture`, even if a window claimed it between taps. - If the marked capture can no longer answer (private, locked, deleted, discarded, merged, partial, upload-failed, or `_finish_capture` declines, e.g. an unavailable ledger), the **window tail is cut**. The app's `settleManualFinish` reads a 404 as "already closed", so a 404 would leave A uncut. `_finish_capture` writes nothing on those declines, so the tail cut's reads still precede every write. - A mark that resolved empty no longer holds the Finish. - Unmarked captures older than an active mark don't qualify. - `utils/conversations/v3/finish.py`: both live-window calls pass the switch. They are the empty body and a named window that is still live. `_acknowledge` counts the full label, then strips `newer_` / `dual_` to answer like the path that stored it. A window answer is what the app already settles on: `settleManualFinish` binds `_finishLiveId` to it (`app/lib/providers/conversations_v3_provider.dart:145-173`). - `config/conversations_v3.py`: `finish_newer_capture_enabled()` adds the kill switch `CONVERSATIONS_V3_FINISH_NEWER_CAPTURE`. It defaults on; off is exactly main. - `utils/conversations/v3/metrics.py`: pre-initialised labels in `omi_conversations_v3_finish_no_pointer_total`, apart from the tail path's outcomes, every one reachable: - `newer_recording_cut`, `newer_recording_requested`, `newer_already_cut`, `newer_already_requested`, `newer_resolved_empty`, `newer_consumed`, `newer_recording_ineligible` (account being deleted); - `newer_dual_cut`, `newer_dual_requested`, `newer_dual_consumed`, `newer_dual_already_cut`, `newer_dual_already_requested`, `newer_dual_already_empty`, `newer_dual_resolved_empty`. - `newer_already_empty`, `newer_batch_unavailable`, `newer_batch_disabled` could never be returned and are removed. A selected-then-declined capture counts in **`omi_conversations_v3_finish_newer_declined_total{reason}`** (`already_empty`, `batch_unavailable`, `batch_disabled`, `recording_ineligible`), once after the commit; the window tail still cuts and answers, counted as the tail's outcome. - **`omi_conversations_v3_finish_to_visible_seconds{path}`**, histogram, `path` ∈ `tail` / `newer` / `newer_dual`, buckets 5 s – 2 h. - **Finish-to-visible sample (no correlation store).** `request_finish` stamps `v3_finish_requested = {at, path}` in the first write it stores on the response target's source: the tail for `tail` / `newer_dual`, B for `newer`. In the stored-both case the tail's write is planned first (`_window_tail_plan`, no read or write), so B's request is stamped only when the answer names B; otherwise B rides along unstamped and B's own card never samples. Consuming cuts and `already_*` answers write no stamp, so a retried Finish keeps the first. The planner carries the stamp to the derived row that shows the cut (first stamp wins). `settle_processing` observes `now - at` once, at the row's first visible manual-end settlement (the `v3_manual_end_home_counted` transition), after the transaction commits; a stamp older than 2 h, a hidden row, or a re-settlement records nothing. `first_speech_to_visible_seconds` is not reused: it fires at row creation, and a live window's row exists before its Finish. `deploy/cloud_run_gmp_sync.yaml` keeps the histogram. - Pipeline lab (`scenario/ops.py`): at seal, the batch lane writes `has_content` with `server_batch_audio_end`, as production's `note_server_batch_audio` does in one transaction. `finish_after_second_close` now expects the answer to name A's window (`finish_response_names_a_window`) and B to be fast-finished (`b_fast_finished`, the check main fails). - Flag registry, contract paragraph in `listen_pusher_pipeline.mdx`, change note, Firestore query driver for `request_finish`. ## Verification All commands ran from `backend/` in the lane worktree, through `omi-heavy`. Base is origin/main `afab9560db2`. - **Scenario on main:** `finish_after_second_close` gave XFAIL. A was cut, B got no fast finish, reads 236. - **Scenario with the change:** PASSED. The answer names A's window; B fast finish `written`; B on Home. Reads 304, writes 74, no-op writes 12, STT 1, LLM 6. The budget is re-measured. - **Scenario with `"env": {"CONVERSATIONS_V3_FINISH_NEWER_CAPTURE": "off"}`:** same as main, at this head. Target A, `b_fast_finished` fails, 236 reads, 62 writes, 0 STT. - **All 13 committed scenarios:** passed. - **Unit tests:** `tests/unit/test_episodes_finalize_paths.py`, 154 passed; with the Firestore guard set, 1079 passed. - **End-to-end race test** (owners' request): `test_one_finish_cuts_a_at_once_and_consumes_b_once_across_resolution_and_retry`, parametrized by B landing with `speech` or `silence`. It runs entirely on StrictFirestore: 1. B is created through the real `triggers.mark_new`, so it carries the creation stamp. 2. Finish runs: one transaction cuts A and stores B's request; the answer names A's window. 3. B's projection lands (`replace_record`), then the real whole-record completion (`store.complete` → `_v3_finish_update`) runs twice. B's request is consumed once: B ends with `v3_manual_end` for speech, or the request is cleared for silence. 4. The same Finish runs again (same body and window id). It answers A's window with `already_cut` and no writes; A is cut once and B is requested once. With the retry guard removed, `[speech]` fails (the retry answers `capture-b`). `[silence]` still passes, because a mark that resolved empty no longer holds the Finish, so the retry reaches A's tail either way. - **Each new test fails without its own fix.** Mutation runs: - R1, no stored-both path: 12 fail; - R7, `has_finish_content` as the batch speech signal: 4 fail (`created_stamp=True`); - R2, ledger reads not hoisted: 4 fail (StrictFirestore read after write); - R3, stored-both retry guard removed: 3 fail; - R4, a blocked mark answers instead of a tail cut: 5 fail; - R5, a retry decline is a 404: 1 fails; - R6, the older-than-mark condition removed: 1 fails. The previous round's mutations (`has_content` gate, `already_empty` decline, newest-wins, deletion marker) still hold. - **Degraded-targeting telemetry counts once per Finish.** A tie or a full scan records `omi_fallback_total` (`conversation_finalization`, `newer_capture` → `window_tail`, `degraded`). `_newer_capture` only marks a per-attempt flag, reset at the top of the transaction body; `request_finish` records it once after the transaction commits. `test_live_window_finish_records_degraded_targeting_once_across_transaction_retries[tie|full_scan]` aborts the first attempt after the scan and before any write. With the recording back inside the body, both cases fail: "Called 2 times". - **Targeted set:** 43 files, 2597 tests passed: the changed tests, the Firestore guard set, every `test_conversations_v3_*`, `test_reliability_experiment_end_*`, `test_reason_label_enums`, `test_pipeline_lab_*`, `test_batch_pipeline_projection` and `test_server_batch_completion`. - `scripts/check_feature_flag_registry.py` OK. ### Review fixes (panel `review-20261127t015349-a22e`, F1–F5) - **F1** Finish-to-visible sample: `test_live_window_finish_stamps_only_its_response_target[tail|newer|newer_dual]`, `test_retried_live_window_finish_keeps_the_first_stamp[...]`, `test_consuming_cut_keeps_the_stamp_of_the_finish_that_stored_the_request[tail|newer]`, `test_finish_stamp_follows_the_cut_to_its_card_once` (planner, dual card), `test_finish_to_visible_is_observed_once_at_the_first_visible_settlement[...]` (re-settlement does not repeat), `test_finish_to_visible_drops_stale_hidden_and_unstamped_rows[stale|hidden|unknown_path|no_time|unstamped]`, `test_finish_to_visible_dual_card_samples_only_the_response_target`, `test_cloud_run_sync_scrapes_finish_to_visible`. - **F3** decline: `test_live_window_finish_counts_a_declined_newer_capture_and_still_cuts_the_tail[already_empty|batch_unavailable|batch_disabled|recording_ineligible]` and, separately, `test_live_window_finish_without_a_newer_candidate_counts_no_decline[none|older_than_window|silent]`; `test_newer_capture_finish_labels_are_reachable_or_absent`. - **F2/F4** read counts: the three exact read-sequence tests above. - **F5** `test_live_window_finish_cuts_the_tail_without_a_newer_finishable_capture` asserts on the retained `b` that neither `v3_manual_end` nor `v3_manual_end_requested` was written (and, for `none`, that B was not recreated). - Mutations: dropping the decline record fails 4; stamping B's request in the stored-both case fails 1. - Focused files (15), all passed at the earlier merged head (origin/main merged after main moved): `test_episodes_finalize_paths` 178, `test_conversations_v3_fast_finish` 115, `test_conversations_v3_contract` 119, `test_firestore_query_shapes` 644, `test_firestore_runtime_witnesses` 25, `test_conversations_v3_live_passes` 53, `test_conversations_v3_live_rederive` 129, `test_conversations_v3_created_delivery` 59, `test_conversations_v3_engine` 97, `test_conversations_v3_finish_late_predecessor` 33, `test_batch_pipeline_projection` 87, `test_pipeline_lab_scenario` 51, `test_monitoring_telemetry_contract` 58, `test_fleet_deployment` 11, `test_attach_cloud_run_gmp_sidecar` 117. - `python -m testing.pipeline_lab affected` → 15 scenarios, all passed, budgets unchanged (`finish_after_second_close` included). The full backend unit suite is left to CI. ## Lab vs production - **The final conversation shows `manual_end = no` in the lab.** The lab's native-completion stand-in (`batch_projection`) skips the projection transaction, so neither A's window-scoped request nor B's recording-scoped request is ever promoted to `v3_manual_end`. Production promotes them: at admission for a window-targeted single unit, at whole-record ledger completion for a recording-scoped request (`database/batch_pipeline_projection.py`, `whole_record_consumed`), as for the existing #26288 fallback. In the lab, A and B end in one conversation because no cut lands. - **#26344 interaction.** #26344 is merged into this branch (merge `4d2e913c`). Under its chunked fast finish and extended lab STT stand-in, `finish_after_second_close` still meets every check (`b_fast_finished: written`, STT 1 via `fast_finish`), now at 299 reads (was 304). ## Rollback Set `CONVERSATIONS_V3_FINISH_NEWER_CAPTURE=off` on the API service that serves `POST /v1/conversations`. That restores exactly main's Finish without a deploy; cuts and requests already stored stay. Or revert the merge commit. Product invariants affected: none Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Start here
This follow-up to #26303 adds per-scenario operation budgets to the pipeline lab, plus eight scenarios for the most frequent incident classes: Finish and recording boundaries, privacy, and Home paging. Everything is lab-only:
backend/testing/pipeline_lab/,backend/tests/unit/test_pipeline_lab_*, the lab docs and one.github/ci-budget.yamlentry. No product code changes. Stacked on #26303 (branchlane/pipeline-lab-scenarios), which is still open: until it merges, this diff includes its commits.What changed
Operation counts and budgets (
scenario/budget.py)database._clienthands the product, so every SDK path is counted once.update_time. Each no-op names its call site.result.jsonand to the verdict row (ops). They also appear as columns inscenario summary, as a line in the text report, and as a table under the verdict in the web view. Repeat runs compare them.by_scope.lab);dream_controlreads, which go through a 10 stime.monotoniccache;racy_ops, see Findings).budgetblock ({"reads", "writes", "deletes", "noop_writes", "vendor_calls": {"stt", "llm"}, "note"}) turns each key into a check labelledbudget_<key>. That check fails when the count goes over the cap.OMI_PIPELINE_LAB_WRITE_SITES=1names the call site of every write (ops.write_sites).Format additions (documented in
scenario/spec.pyand the README)finish.again_at: more taps of the same Finish button;account: cloud audio off takes the live lane (no batch admission);sync_off_atturns sync off mid-run;seed: Home history before t0 (visible, below-word-minimum, media, raw recording and discarded rows), laid out in runs.recording(fast_finishoutcome);finish_response(what tap N answered);home_paging: "visible_once": Home is paged to the end asConversationProvider._loadMorePagepages it (limit=50, offset byX-Omi-Conversation-Page-Size, cursor, page mode,X-Omi-Has-More).titled,has_notes,home_titled,home_has_notes,holders.New scenarios
finish_next_opens_before_closefinish_after_second_closeexpected_failurefinish_on_visible_conversationfinish_double_tapfinish_no_closed_recordingnot_foundand does not cut the next recordingfinish_cloud_audio_offprivate_cloud_sync_enabledfalse (live lane): Finish finishes A and answers with A, with zero STT callsfinish_privacy_refused_fast_finishprivacy_blocked, zero STT calls (budget)home_paging_past_hidden_runsEvery committed scenario now has a budget set from its counts measured at the merged head, plus about 10%.
reach.jsonwas re-measured. The advisory CI job's budget goes from a 3- to a 5-minute p50, and the Linux cap from 14900 to 15020 (.github/ci-budget.yaml, rationale in the house format).Expected failure
finish_after_second_closefailsfinish_response_names_bandb_fast_finishedon current main.finish_live_windowprefers the newest open v3 window: A's, idle 125 s, insidelive.MAX_IDLEof 2 h. It picks that window over a newer sealed recording that has no window yet.request_finishthen cuts at A's tail, and B gets neither the cut nor a fast finish. The #26288 recording fallback runs only when no live window exists (utils/conversations/v3/finish.py:31-36). I found no Multica issue for this; the nearest are SCA-4385 and #26288.Measured op counts (merged head
169f478de13, CI arguments)Findings
database/conversations_v3_leases.py:72renew, called throughrun_blockingfromservice.reconcile(utils/conversations/v3/service.py:397,774). The renewal rewrites the lease'suntilat the same lab instant it was claimed. The lab clock does not move inside one event, but production's does, so these are likely lab-clock repeats rather than production no-ops. Each budget setsnoop_writesto the current count and says this in itsnote.utils/ai_profile_refresh.py:218,database/users.py:2743write_ai_user_profile_if_unchanged) uses a write fenced against concurrent effects. Whether that write lands depends on thread timing inside one event. It landed in about 1 of 8 repeats under one load and in 12 of 12 under another, and it made two scenarios differ between repeats. These operations are now shown inops.racy_opsand not compared.requestedin the lab where production cuts, and a recording-scoped intent is never consumed. Scenarios avoid judgingmanual_endin those shapes; the README stand-in table says so.Verification
backend/tests/unit/test_pipeline_lab_*.py, one process per file: 45 files pass (132 s). The newtest_pipeline_lab_scenario_budget.pycovers the counter, no-op detection, scopes, wall-clock and racy buckets, budget checks, format validation, paging walk and verdict rows. All tests are pure, so none needslow.scenario run --jobs 10 --repeat 3: 13 scenarios, 12 passed and 1 xfail, no repeat differences, 59.9 s.--jobs 4 --repeat 2 --json --stt replay): passed in 67 s on an idle host, 128 s under load. The five old scenarios with the same arguments took 34.7 s.check_ci_budget.pypasses; black passes.Not in this PR
Product fixes (the Finish target bug above), the native completion ledger stand-in, and a Multica issue for the Finish target bug.
🤖 Generated with Claude Code