Skip to content

Pipeline lab: replay a recorded day through a ref's real pipeline, with an agent guide - #25862

Merged
Git-on-my-level merged 53 commits into
mainfrom
lane/pipeline-lab
Nov 20, 2026
Merged

Git-on-my-level merged 53 commits into
mainfrom
lane/pipeline-lab

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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 feat(conversations-v3): cut at sit-downs when the silence gap is over five minutes #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

Git-on-my-level and others added 30 commits November 20, 2026 18:23
…keys, spend ledger

contracts.py types every record of the pipeline-lab store contract with JSON
round trips that keep unknown keys, the ordered stage enum, item kinds and
stable content keys. store.py keeps the run store and the separate verdict
root owner-only and outside git, with atomic writes and locked JSONL appends.
keys.py is the stage cache key over the backend tree hash; ledger.py is a
hard-capped USD ledger that reserves before every billable attempt.

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

Detached worktrees per commit under the configured worktree root (never under
~/workspace, via the git on PATH), verified clean at the pinned sha before use;
backend tree-hash lookup; an arm runner that vendors the lab package and runs
a stage module against the arm's backend with a scrubbed env overlay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sits behind OMI_LLM_GATEWAY_URL: keys canonical requests, serves cached
responses byte for byte (SSE included), forwards misses after a ledger
reservation, refuses at the cap with a non-retryable 402, and logs every call
with stage and conversation tags from headers or a session tag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Walks the stages in order through drivers other lanes register in
<dir>/plugin.py, consults the stage cache, records timings, status and spend,
and stops on the spend cap. The CLI covers corpus, run, runs, show, verdicts,
sample-run, worktree, llm-proxy, stages and doctor with --json; engines owned
by other lanes fail with "tool not registered" until they plug in.

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

llm-proxy --port 0 now prints the URL it actually bound. A run whose pinned
worktree has a different backend dependency lock than the harness records a
warning in run.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tual clock, overlay pins

Persistent lab environment forked from replay_harness/env.py: loopback peers from
dev-up defaults, deny-by-default sockets/DNS/gRPC with an STT allowlist, a
harness-owned wall clock with no new dependency, and an overlay that pins every
serving_for cohort through the product's own digest list and logs decisions.jsonl.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Numeric, persistent Pinecone-compatible index (namespaces, metadata filters, cosine
scores, upsert/update/delete/list/fetch with LSN acks for OwnerIndex), a pluggable
embedder with an on-disk input-hash cache, and a seed plan written through the
product's own vector_db helpers. Tests run the real task-dedup query against it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reads the fetch-owner-audio snapshot format, cuts rows created at or after the day
start, strips stored LLM input/output hashes, remaps the source uid to
local-dev-user everywhere (with a no-survivor check), drops byte markers, adds a
synthetic FCM token, and writes through product database helpers. Reset is
guarded to the lab uid on a loopback demo-* emulator. Synthetic snapshot generator
included for tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
FCM at messaging.send_each becomes a would-have-fired log (scope, caller, fire time)
with a success response; webhooks, task sync and PostHog are captured at their
product leaves; any other HTTP egress is recorded host+path and answered 200; calls
to the lab LLM proxy are tagged with conversation and stage headers.

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

Ordered conversation driver over the real durable finalization path (intent, lease,
finalize_persisted_conversation, completion) at each conversation's production
finalization instant, with an executor barrier and event-loop drain between
conversations and K=4 export to the store contract. Day stages run the per-user
recap worker at the replayed instant and compute goals, memory delta and chat-index
readiness. Baseline normalizes production rows with the same exporter, matches by
id then time overlap, and emits status chips. The clock now swaps datetime only in
product packages; product modules are imported before any patching; the product
embedder binds lazily inside the lab env. Adds an emulator smoke runner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gaps, lanes, evaluability)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stdlib loopback server over the run store (JSON API, audio with Range,
verdict append), a no-build HTML/CSS/JS inspector implementing the DESIGN
Inspector UX, and a fictional sample day covering every replay status.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ple snapshots, phone layout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…store IO (RULINGS 1-11)

- contracts: RunRecord.commit, ConversationRecord.baseline_ids, Mark.clear,
  Verdict.reviewer, typed DailySummary/Goal, RunDay chat_index/recap, parse_time
- store: raw_conversations.jsonl baseline file, lab_root, SEGMENT_PATTERN,
  latest verdicts drop clear targets
- ingest: timeline/paths.py removed; store/contracts used directly;
  BudgetExceeded is a SpendCapReached so STT and LLM share one stop
- chain: export keys use contracts.task_key/memory_key (were a private hash);
  baseline compare gains boundary and transcript fields
- inspector: reader uses contracts content_key/safe_id and reads chain's
  baseline.json for pairs and status (local pairing only as a fallback);
  verdicts store the production id (replay id kept as replay_conversation_id)
- orchestrator: one overlay schema (pins refused), proxy URL env, from-stage
  skips uncached earlier stages, lock drift fails closed unless allowed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…orpus add-day; hermetic e2e

- seed/corpus.py + seed/plugin.py: corpus add-day from a local snapshot (+ optional
  audio dir): day.json, baseline in both shapes, start_state/, audio index, timeline;
  source uid remapped and checked for survivors
- chain/plugin.py + chain/entry.py: discard..chat_index as one composite execution
  (pinned arm via python -I, or in process) reporting per-stage status; baseline.json
  built after the chain; chain/fake.py is a hermetic stand-in engine
- lanes/plugin.py: ingest, transcribe (cassette playback, overlay model_config.stt),
  boundaries/speakers (production-owned in M1), record-stt on core's ledger;
  span cassettes by default, streaming via the sync driver
- cassette: ParakeetBatchAdapter (per-window, URL from env, refuses GPU-off fallback)
- llm_proxy/fake_upstream.py: schema-driven fake gateway behind the real proxy
- inspector/plugin.py: serve and sample-run; header shows the STT source and engine
- day outputs in contract shape (daily_summary title/overview/highlights, goals)
- run --in-place / --engine / --allow-lock-mismatch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…runtime_env; clock and process fixes

- stack/chain_smoke.py + run_chain_smoke.sh: LOCAL-STACK SMOKE (not a unit test):
  synthetic day through the real product chain on a Firestore emulator + redis on
  non-default ports, fake LLM upstream behind the real proxy, inspector check
- stack/runtime_env.py + 'overlay from-runtime-env': production flags of one service
  from the ref's deploy/runtime_env.yaml (no secrets/endpoints), cohorts as serving pins
- clock: transport libraries (grpc, google-api-core, http, redis, asyncio...) keep real
  time.time; gRPC deadlines were computed from the virtual clock and every RPC expired
- in-place runs execute stage entry modules in a fresh python -I process, so the chain's
  network guard and clock never reach the proxy serving from the orchestrator
- chain records full processing tracebacks to the run's private processing_errors.log;
  the entry's own traceback goes to chain_errors.log (no longer overwritten)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…book; tool tests; lint

- README: layout per directory, the store contract as integrated, overlay schema,
  run flags, smoke, and a RUNBOOK (add-day, prod overlay, stack, budgeted run,
  inspector over tailscale serve) with every private path as an env var
- proxy: OMI_PIPELINE_LAB_UPSTREAM_TOKEN (operator env only) authenticates the
  real gateway; the product inside the lab keeps a placeholder
- tests: runtime_env overlay, Parakeet batch adapter, add-day with audio,
  record-stt on the stub adapter; ingest day test pins the exact sync mode it tests
- ruff and detect-secrets clean on every pipeline_lab file (placeholders marked)

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

A v3 day feeds the day's recordings in production order on the virtual clock through the
real v3 code: admission (mark_new), durable finalization (recording_short_path -> changed),
named Cloud Tasks run in process (loopback queue with name dedupe and schedule_at), the
reconcile handler body and the */5 sweep. Export writes v3 conversations in the contract
shape with recordings and Home state, paired with production by shared recording.

- v3/: feed, tasks, driver, product ops, run, entry, fake engine, export, corpus, select,
  prod_export (owner guard injected by path; Firestore/Storage/Redis writes refused)
- corpus add-day ingests <snapshot>/v3 (recordings, production v3 conversations, prior
  recordings into the start state)
- run picks v3 when the overlay turns CONVERSATIONS_V3 on and the day has recordings;
  model_config.pipeline overrides; the classic chain stays available
- overlay from-runtime-env: backend-sync default, owner uid allow-lists carried to the lab
  uid, every static serve decision pinned
- inspector: v3 baseline, Home visibility, recordings, sections
- contracts: ConversationRecord.recordings and .v3

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

- v3/smoke.py (SMOKE_MODULE for run_chain_smoke.sh): synthetic v3 day through the real
  v3 code on the Firestore emulator with the fake upstream
- export only the v3 conversations this replay planned (start-state rows stay out)
- static serve-mode pins also cover names bound through constants
- overlay from-runtime-env --owner-uid-file (0600 file; never env or argv)

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

- a production stamp over 30 min after finished_at is not an arrival (backfill donors carry
  their legacy re-finalization in terminal_family_at)
- v3 smoke --ref runs a pinned arm with that ref's runtime env (verified on the production
  release)
- README: v3 store files, the v3 replay, overlay service and owner uid file, v3 smoke

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mapped; smoke takes an overlay

`overlay live-env` filters a `gcloud run services describe` JSON (stdin) into a
secret-free env with the owner uid replaced by the lab uid; `from-runtime-env
--live-env` merges it and refuses an overlay the owner uid survives in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ible reset, merged status

The first real-day dry run failed in seeding after 198 s. Fixes, each with a synthetic test:
- conversations seed through the product's encode seam in batches (not the per-row processing
  upsert); per-row failures become counted run warnings, never silent drops;
- blobs still sealed under the production key (open_loop_extractions) are cleared and counted;
- memory ledger commits over Firestore's entity limit are split until they fit;
- a focused goal is created in the background, then focused;
- a down Typesense turns the product's index-write kill switch on (decision typesense_unavailable);
- the reset also clears the lab uid's top-level docs and Redis keys (finalization jobs and
  daily-summary locks made a re-run take other paths), keeping the batch privacy authority;
- v3 production rows sharing recordings with a replay conversation are "merged", not "missing";
- the stage cache key carries the selected pipeline; phase and seed timings in chain_entry.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A real-day v3 replay died on a single 502 from the dev gateway while
seeding start-state embeddings. The proxy now retries 429/502/503/504 and
pre-send transport errors up to four attempts with backoff, before the
client sees anything. Errors after the body was sent are still never
retried (unknown fate, reservation kept).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A paid real-day v3 replay failed twice at the same start-state embedding
batch: OpenAI answered 5xx for that batch every time while all others
succeeded. CachedEmbedder now bisects a provider-side failure (5xx or
transport) down to the refusing texts; those get a deterministic
near-orthogonal placeholder vector (not cached) and a counted run warning.
Spend-cap stops and 4xx answers still propagate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The dev gateway answered every 60-64 text embedding call with a provider
5xx after ~18 s while every 30-32 text call succeeded, so real-day seeding
never finished. CachedEmbedder sends at most 24 texts per call
(OMI_PIPELINE_LAB_EMBED_BATCH overrides).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level and others added 16 commits November 20, 2026 18:23
…ow, wait out a dropped tunnel

- v3 feed: a live capture's speech now lands in one-minute partial updates through the product's
  own update_conversation_segments (which re-arms the builder), before the recording finalizes.
  Each segment is modelled as landing at its end + 60 s. Whole-recording arrival froze earlier
  windows that production kept open. Overlay model_config.v3 partial_step_seconds (0 = off) and
  partial_lag_seconds.
- v3 export: replay conversations starting at or after the day's end are left out, as production's
  baseline does; recording fate still counts their claims.
- LLM proxy: a refused or reset connection before sending is retried for up to 120 s
  (OMI_PIPELINE_LAB_UPSTREAM_CONNECT_WAIT); a replay lost its daily summary to a tunnel gap.
- Inspector: batch diarization's per-segment BATCH_UNASSIGNED_* labels show as one
  "Unassigned speaker" instead of "Speaker 71".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wo-draft review

- ideal/packet.py exports a corpus day's speech as numbered lines with normalized speakers
  (ME, known names, S1.. per recording, S? for batch abstention) and duplicate captures marked.
  No audio and no existing results, so a drafter is not anchored.
- ideal/schema.py defines the ideal format (cards over line ranges: kind, Home, key points,
  tasks, confidence, why). Its stdlib-only validator is copied next to drafts.
- ideal/score.py scores production, a replay or another draft against an ideal: splits, merges,
  boundary F1, Home recall/whole/precision, misses and false adds.
- ideal/review.py aligns two drafts into spans and lists the disputed ones, with production and
  replay context.

Packets and ideals hold the owner's transcripts and live under the 0700 lab root, never in git.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…'t-care kinds

- ideal/hourpass.py: one call per hour of transcript on the production outline lane
  (omi:auto:conversation-v3-outline) decides that hour's cards, Home calls, titles and key points,
  with the end of the earlier cards as context. Merge-only continuation into earlier cards, the
  open card carried into the next window, one format retry with the validator's errors, a
  low-effort fallback on persistent gateway 5xx. Every call goes through the lab proxy and ledger.
- ideal/jevhome.py: asks Jev the production relevance question about each card and writes
  one ideal-format file per Home threshold.
- ideal/score.py: --ignore-kind leaves ideal kinds out of the score (dictation for now). Candidate
  cards and Home precision count only lines the ideal scores.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…irer Home scoring

Hour pass: --variant switches for gap markers, sit-down rules, the last conversation in context,
boundaries-only output with a tolerant parser, second-capture tags or collapse, and windows cut at
15-minute silences. refine: absorbs background runs inside a conversation, asks Jev and one Luna
call whether neighbouring cards are one sit-down, and Jev for Home on the merged cards; build()
rebuilds any configuration offline. score: a candidate Home card made mostly of don't-care lines is
no longer a false add; word-weighted Home recall and precision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g claim times)

The attribution wrappers now pass every argument through (outline.messages gained cohesion=).
Seeded recordings get their claim times back as datetimes: the planner compares them with segment
times. Failed driver events record where they failed (file:line, never the message), and the v3
overlay takes max_events for short probe runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…/B escape hatches

ideal/planpass.py runs a ref's own outline, planner and visibility over a finished corpus day (real
outline calls through the proxy, no Firestore), so cutting policies compare in minutes. The v3
overlay takes exclude_start_ids to leave a source both arms share out of the seed (a recording past
Firestore's size limit stops the owner). Failed events record product frames and the storage reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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 #25794 refs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sses on request

- summary_covers_through, v3_pending_since, recorded_start/end are Firestore timestamps in
  production; seeded as strings, #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]>
…_events

- testing/pipeline_lab/AGENTS.md: privacy in reports, replay bistability
  (repeat runs, report ranges), reading the per-card diff, known stalls,
  harness parity and mutation passes, one replay at a time, never kill
  dev_harness supervisors by pattern, bounded runs, cleanup.
- ideal/runs.py: score table against the day's ideal and per-card diff
  across runs; prints times, counts and flags only.
- ideal/score.py: a line two conversations share goes to the earlier one,
  not to whichever file a glob listed first.
- v3/fake.py: accept and pass max_events; entry.py's v3 options carry it,
  so every fake v3 run exited 2.
- backend/AGENTS.md and the lab README point to the guide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…collection budget scan

The scanner resolves unrelated .collection(name) parameters in
backend/database to the lab STT adapter's class attribute; it is not a
Firestore collection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…within its ratchet

The lab guide is reached as the nearest AGENTS.md and from the lab README,
so backend/AGENTS.md needs no pointer. Repo-relative test path; no
workspace-only tool names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Stored SPEAKER_NN segment labels come from contracts.wire_speaker_label.
- jevhome renders unnamed voices with the display authority's SpeakerLabeler.
- The STT cassette's per-window diarization id is built by a named helper.
- The synthetic inspector sample never puts a raw speaker field in prompt text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… reviewed sync-lane edge

- The first test of five lab files pays real product imports in its call phase.
- The lab's sync-lane replay imports utils.sync.pipeline as its subject; the
  edge is in the retirement baseline so C11 deletes the lane with the module.

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

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T12:50:48.903744Z 7f3e730 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51bb82b8ec

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

Comment on lines +187 to +189
staged = work / f'lab_{epoch}{"".join(Path(conversation.original_bin).suffixes) or ".bin"}'
shutil.copyfile(conversation.original_bin, staged)
wavs = decode_files_to_wav([str(staged)])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve codec tokens when staging original WAL files

When original_bin is a PCM WAL file, this rename removes its _pcm16_ or _pcm8_ token before calling decode_files_to_wav. That decoder selects PCM versus Opus from the filename (backend/utils/sync/files.py:272–274,320–337), so valid PCM bytes are sent to the Opus decoder instead. The rename also loses any _fsN frame-size marker. Preserve the decoding metadata when replacing the capture timestamp so the replay exercises the correct production decoder.

AGENTS.md reference: backend/AGENTS.md:L322-L322

Useful? React with 👍 / 👎.

result.outcome, result.error = 'failed', 'no_start_time'
return result
epoch = round(start.timestamp(), 3)
work = Path(tempfile.mkdtemp(prefix='plab-sync-', dir=scratch))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep sync replay scratch audio under the private lab root

Both sync callers in lanes/day.py omit scratch, so this defaults to the system temporary directory, where _source_wav and the VAD pipeline write private audio. Although mkdtemp protects the directory's permissions, the audio is outside the required lab root and remains there if the process is killed before the finally cleanup. Derive the scratch directory from the validated private lab root rather than defaulting to system temp, as required by the pipeline-lab privacy guide.

AGENTS.md reference: backend/testing/pipeline_lab/AGENTS.md:L15-L16

Useful? React with 👍 / 👎.

Comment on lines +74 to +75
if result and result.get('outcome') == 'transcript' and result.get('segments'):
row['transcript_segments'] = product_segments(result['segments'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply successful silence results instead of restoring production speech

When the replayed VAD/STT produces outcome: 'silence', this condition falls through to the stored-transcript branch, leaving all original production speech in the conversation. Both lane drivers explicitly distinguish successful silence from failure, so this masks a model or VAD change that removes speech: downstream notes, memories and tasks are still generated from production's transcript. Handle silence by clearing the transcript and reserve the stored fallback for missing or failed ingest results.

Useful? React with 👍 / 👎.

Comment on lines +229 to +231
if self.sweeps:
pending = await asyncio.to_thread(self.ops.pending, self.uid)
sweep_at = next_sweep(self.clock.now()) if pending else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve an already scheduled sweep across intervening events

Every arrival or task recomputes sweep_at, even when a sweep is already due. Because arrivals win ties, an arrival on the five-minute boundary silently cancels that sweep and schedules the next one instead. A synthetic run with pending work and arrivals every minute from 09:00 through 09:09 executes its first sweep at 09:10, skipping 09:05 entirely. With default partial updates this can repeatedly suppress the production recovery sweep and change when pending conversations are built; retain the existing sweep deadline until it executes or pending work clears.

Useful? React with 👍 / 👎.

Comment on lines +263 to +266
for name, body in blobs.items():
atomic_write_bytes(day_dir / name, body)
if daily_summary is None and (day_dir / 'baseline' / 'daily_summary.json').exists():
(day_dir / 'baseline' / 'daily_summary.json').unlink()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove stale artifacts when replacing a corpus day

When corpus add-day --replace rebuilds an existing day, this only overwrites files present in the new snapshot; optional artifacts from the previous import remain. Replacing a v3 snapshot with one without a v3 export leaves v3/recordings.jsonl and baseline/v3_conversations.jsonl behind, so day_has_v3() still returns true and an enabled overlay replays the old recordings against the new start state. A synthetic replacement reproduces this even though the new day's v3 metadata is null. Remove obsolete optional artifacts as part of replacement rather than merging the new corpus into the old directory.

Useful? React with 👍 / 👎.

'overview': str(row.get('overview') or row.get('summary') or ''),
'highlights': plain(list(highlights) if isinstance(highlights, list) else [highlights]),
}
out.update({name: plain(row.get(name)) for name in ('date', 'stats', 'memories_learned') if name in row})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain the production recap timestamp during normalization

For a day imported through add_day, this normalization discards the summary's created_at, but chain.entry._production_recap_at() later reads that exact field from the normalized baseline. Both replay engines therefore always fall back to 22:00 on the corpus date instead of using production's recap instant. With CALLS_RECAP_MODE=serve, this changes the day being summarized: utils.other.daily_recap.scheduled_date() selects the previous completed day, so a recap actually generated after 01:00 the following morning is replayed for the day before the requested corpus date. Preserve the timestamp in the corpus metadata so the worker receives the intended production instant.

Useful? React with 👍 / 👎.

Comment on lines +101 to +105
key = self.key_for(pcm16, language=language, vocabulary=vocabulary)
existing = load(key, self.root)
if existing is not None:
self.hits += 1
return existing

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include transcription window settings in the cassette identity

When the same audio is recorded with a different Parakeet --window-seconds value, the cassette key is unchanged: key_for() includes the provider, model, language, vocabulary and audio, but not the adapter's window size. This cache-hit branch consequently returns the earlier transcription without invoking the newly configured adapter. A synthetic recording with one-second windows followed by two-second windows produces zero new transcription calls and reuses the old window-specific speaker labels. Include output-affecting adapter settings in the recording and playback identity so window-size experiments do not silently compare the same cached result.

Useful? React with 👍 / 👎.

…, pinned arms)

- v3/prod_export: the v3 output must be an owned, non-symlinked directory
  under the allowed root; outputs open with O_NOFOLLOW and are reset to
  0600; the git probe fails closed; the fence also refuses recursive
  deletes, bucket deletes/copies/renames and Redis pipelines.
- llm_proxy: plain HTTP upstreams only on loopback.
- worktrees: a reused pinned arm with untracked Python under backend/ is
  refused.
- lanes: record-stt and replay validate the root (0700, not in git) and
  ids before writing; ingest output ids are safe segments.
- Token files go through read_private_value; the fake engine bypasses
  ambient HTTP proxies.
- ideal.runs handles open cards; the batch lane diarizes the unit in flight,
  not the first unit of the same length; cache identity cannot be
  overridden by a value; a proxy that fails to start marks the run failed;
  the fake v3 engine honours sweeps; the inspector skips empty groups.
- inspector app.js: decode only the first encoded '?' by position
  (CodeQL incomplete-replacement).

Failure-Class: none

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9aafa2c58b

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

gap = (entry.start - cursor).total_seconds()
if 0 < gap <= MAX_FILLED_GAP_SECONDS:
pcm += b'\x00\x00' * int(round(gap * RATE))
pcm += load_pcm16(path, entry)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Decode WAL files before assembling conversation audio

When a corpus contains an original sync .bin upload, both record_day_cassettes() and replay_day() call this loader before the sync lane reaches _source_wav(). However, load_pcm16() does not decode WAL framing: the default opus entry goes to pydub/FFmpeg as if it were a media container, while an explicit pcm16 entry includes the four-byte frame headers as audio samples. Consequently, valid Opus WAL inputs fail before reaching the production decoder, and PCM cassette recordings contain corrupted audio. Decode .bin inputs through the filename-aware production WAL decoder before constructing the canonical PCM buffer, preserving the original file for subsequent replay.

AGENTS.md reference: backend/AGENTS.md:L322-L322

Useful? React with 👍 / 👎.

Comment on lines +74 to +76
if 0 < gap <= MAX_FILLED_GAP_SECONDS:
pcm += b'\x00\x00' * int(round(gap * RATE))
pcm += load_pcm16(path, entry)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve clip offsets across gaps longer than ten minutes

When two retained clips for one conversation are separated by more than MAX_FILLED_GAP_SECONDS, this branch omits the gap but still concatenates their PCM into a single buffer anchored at the first clip's start. All subsequent cassette words and replayed segments therefore move earlier by the omitted duration; replay_day() applies only one conversation-wide shift and cannot recover those offsets. A synthetic pair of one-second clips starting 1,201 seconds apart places the second clip at offset 1 instead of 1,201. Process separated islands independently with their original offsets, or reject unsupported gaps rather than silently compressing the conversation clock.

Useful? React with 👍 / 👎.

Comment on lines +139 to +140
result, served_provider, served_model = prerecorded_from_bytes(
pcm16_to_wav(request.pcm16),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reserve spend separately for prerecorded provider retries

When a prerecorded provider retries internally, this call can send the audio multiple times under the recorder's single reservation and single-attempt estimate. In particular, modulate_prerecorded_from_bytes() in utils/stt/pre_recorded.py retries even after an accepted response fails JSON parsing, so two billable POSTs can occur while Recorder.ensure() settles and logs only one charge. A synthetic malformed-first-response run reproduced two accepted POSTs with one reservation at an already fully committed cap. Use the product's held_single_attempt() seam to prevent hidden retries, and route any subsequent attempt through a fresh ledger reservation and vendor-log entry.

Useful? React with 👍 / 👎.

Comment on lines +246 to +247
def _task_text(item: Mapping[str, Any]) -> str:
return str(item.get('description') or '')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include task due-date changes in baseline classification

When a replay extracts the same task description with a different due_at, the task comparison discards the date and reports no difference. classify_pair() passes only these descriptions to item_diff(), so even moving a deadline by a month leaves both compare_pair() and the baseline group classified as same; the task-change filters and digest therefore hide a substantive extraction regression. Preserve description-based matching, but compare the matched tasks' normalized due dates and classify date changes as substantive edits.

Useful? React with 👍 / 👎.

… fixes

- v3/prod_export: a log-record factory rewrites the owner uid in every
  record made during the export (the product's decrypt logs it on failure).
- CodeQL: bounded Range and static-name patterns, a linear scan for the
  fake upstream's schema block, control characters stripped from relayed
  header values.
- lanes replay scrubs credential-shaped env before running product code.
- Baseline production ids are safe segments; a malformed Content-Length
  is a 400; v3 admission markers are cleared in a finally; the owner uid
  comes only from a 0600 file (no --owner-uid-env); the seed prints rows
  dropped; ideal.runs uses the scorer's Home predicate for classic rows.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
self, status: int, body: bytes, content_type: str = 'application/json', extra: dict | None = None
) -> None:
self.send_response(status)
self.send_header('Content-Type', _header_value(content_type))
def _relay_stream(self, response: http.client.HTTPResponse, content_type: str, call_id: str) -> bytes:
"""Relay upstream chunks to the client as they arrive; return the full body."""
self.send_response(response.status)
self.send_header('Content-Type', _header_value(content_type))

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 63e2c084f4

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

Comment on lines +76 to +77
pcm += load_pcm16(path, entry)
cursor = max(cursor, entry.end)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Trim overlapping clips before appending conversation audio

When two audio-index entries for the same conversation overlap, the entire second clip is appended even though cursor already covers its beginning. For example, clips covering seconds 0–2 and 1–3 produce four seconds of PCM instead of three, duplicating speech and shifting subsequent cassette words and replay segments later. load_audio_index() accepts overlapping entries, and replay_day() applies only a conversation-wide offset, so it cannot repair this distortion. Trim already-covered samples or explicitly reject overlapping clips before recording or replaying them.

Useful? React with 👍 / 👎.

out = []
for event in structured.get('events') or []:
if isinstance(event, Mapping):
out.append((loose_text(event.get('title') or ''), str(event.get('start') or event.get('starts_at') or '')))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Classify event duration changes as substantive

When replay extracts an event with the same title and start but a different duration, _events() discards the duration, causing classify_pair() to classify the difference as cosmetic. A synthetic comparison changing only duration from 30 to 120 reproduces this. Duration is a functional field in models.structured.Structured.Event, so this hides a calendar-extraction regression from substantive-change filters and the default “worth a look” digest. Include the normalized duration in the substantive event comparison.

Useful? React with 👍 / 👎.

recap: dict[str, Any] = {'at': iso(at), 'at_source': source, 'tokens': len(tokens)}
with capture_scope(None, 'daily_summary'):
try:
pass_request = cron._send_summary_notification((uid, tokens, tz_name, at))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Run the synchronous recap worker outside the replay event loop

When a replay creates a daily recap, this synchronous call runs inside the active asyncio loop: both chain.run.replay_chain() and v3.run.replay_v3() call run_day() directly. The production worker subsequently invokes _deliver_day_summary_webhook(), which uses asyncio.run(...) and therefore raises RuntimeError before executing the webhook coroutine. That helper catches the error internally, so the lab reports the recap as successful while silently omitting its webhook from the capture sinks. Run the synchronous day worker outside the replay event-loop thread and await its completion.

Useful? React with 👍 / 👎.

Comment on lines +464 to +465
owner.cache_put(
key,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude failed SSE responses from the LLM cache

When an upstream stream reports an SSE error after sending HTTP 200, this unconditionally caches the failed response as a successful completion. This is a real gateway behavior: llm_gateway/routers/anthropic_messages.py emits event: error on midstream timeouts and HTTP failures. A synthetic timeout-error stream is cached on the first request and served as a cache hit on the second, with no new upstream request and no recorded proxy error. A transient provider failure therefore becomes persistent across retries and later runs using the shared cache. Check stream error events and successful terminal markers before admitting an SSE response to the cache.

Useful? React with 👍 / 👎.

…ir spend

A call is answered before its reservation is settled, and handler
threads are daemons, so stop() could return with the last call's spend
still in flight (CI: in_flight_usd 0.0149 after stop). stop() now waits,
up to the upstream timeout, for running handlers.

Failure-Class: none

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f3e7300b6

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

source,
AudioIndexEntry(
conversation_id=cid,
path=source.name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve unique paths when importing indexed audio clips

When an audio index references files in different subdirectories with the same basename, such as one/part.wav and two/part.wav, assigning both entries source.name maps them to the same destination. The copy loop in add_day() then overwrites the first clip, while both index entries remain and point to the second clip's bytes. This silently substitutes audio across conversations during cassette recording and replay. Preserve the relative paths or generate collision-free destination names when importing indexed clips.

Useful? React with 👍 / 👎.

'people': ('created_at',),
'goals': ('created_at',),
'daily_summaries': ('created_at',),
'meetings': ('start_time', 'created_at'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Cut meeting history by creation time instead of scheduled start

For a meeting synced before midnight but scheduled during the replayed day, preferring start_time makes _keep() discard it even though its created_at precedes the start-state cutoff. Consequently, the emulator lacks the day's previously known calendar meetings, and meeting_context_from_time_overlap() cannot supply their titles and participants to summarization when no direct meeting context is present. This changes the inputs being evaluated rather than reproducing production's stored context. Use the meeting's creation timestamp for the cutoff instead of its scheduled event time.

AGENTS.md reference: backend/AGENTS.md:L141-L142

Useful? React with 👍 / 👎.

Comment on lines +464 to +467
return {
'url': f'/audio/{day_id}/{clip_id}',
'clip_id': clip_id,
'offset': (start - parse_utc(best['start'])).total_seconds(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Identify the selected audio clip uniquely in playback URLs

When a conversation or recording has multiple indexed clips, audio_for() can select a later clip by time overlap, but its URL identifies only the shared conversation_id. The audio route resolves that identifier through audio_file(), which always returns the first matching entry. A synthetic recording with clips at 09:00 and 09:10 selects the 09:10 clip with offset zero but serves the 09:00 file, so reviewers hear unrelated speech and transcript-follow timing is incorrect. Include a unique clip identifier in the URL and resolve that exact entry rather than the first clip belonging to the conversation.

Useful? React with 👍 / 👎.

The proxy test's USD cap is named cap_usd (it is not a clock); the closed
port probe uses a 0.5 s timeout (a closed port refuses at once).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 52fbf21 into main Nov 20, 2026
61 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/pipeline-lab branch November 20, 2026 13:18
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.

2 participants