Repository navigation
fix(conversations-v3): give planned participants a source so lists and notes validate - #25588
Conversation
…d notes validate
The v3 planner stored participants as {'name'} only, while Structured.Participant
requires source. Every v3 window that named a person failed GET /v1/conversations
(ResponseValidationError) and the v3 notes pass (Conversation(**row)).
The planner now writes source='transcript', and Structured fills a missing source
before validation in both the SDK and fallback models, so rows already stored read
without a data rewrite. The JSON schema still requires source.
Failure-Class: FC-writer-reader-schema-drift
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: edec5939b0
ℹ️ 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".
| row['structured']['participants'] = [ | ||
| {'name': name, 'source': 'transcript'} for name in window.get('people') or [] | ||
| ] |
There was a problem hiding this comment.
Add the required conversation-lifecycle change note
This changes the v3 conversation lifecycle's persisted participant payload and adds read-time repair for previously stored rows, but the commit contains no pipeline change note. backend/AGENTS.md explicitly requires a note under backend/docs/listen_pusher_pipeline/changes/ for conversation-lifecycle changes. Add one describing the participant-source repair, rollout/rollback behavior, and verification evidence so the operational record includes this production recovery.
AGENTS.md reference: backend/AGENTS.md:L164-L164
Useful? React with 👍 / 👎.
models/structured.py is a hashed notes prompt source. The participant source default changes no prompt, schema or output, so notes-6 checkpoints stay reusable. Failure-Class: FC-response-model-decoupled-from-projection Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-absent fallback Runtime images copy only backend/, so they load the fallback Structured, not the SDK copy the checkout tests import. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The developer conversation response model required structured.category, but a v3 row written before its summary carries only title/overview/emoji/sections/ participants. The detail route therefore raised ResponseValidationError (one missing field) and 500'd, while the list route silently dropped the same rows from the page. #25588 fixed the app's own Conversation model for a participant with no source; the developer projection stayed stricter than the read seam. Project the stored structured through the same defaults the app model uses (title/overview empty, category other, invalid category folded to other) before validation on both the list and detail routes. The stored document is never rewritten and the published schema still requires the fields. Failure-Class: FC-response-model-decoupled-from-projection Co-Authored-By: Claude Opus 5.5 <[email protected]>
…category (#25628) ## What The developer conversation read paths 500 or drop a v3 row whose `structured` has no `category`, and the MCP conversation read paths drop it (list) or 404 it (detail). A v3 row written before its summary carries only `title`/`overview`/`emoji`/`sections`/`participants`; `category` arrives with the summary. The app's own `Conversation` model defaults `title`, `overview` and `category` (and, since #25588, a participant's missing `source`), so `GET /v1/conversations` and `GET /v1/conversations/{id}` serve those rows. Three other response models still required all three: - `GET /v1/dev/user/conversations/{id}?include_transcript=true` raised `ResponseValidationError` with exactly one error, `structured.category` missing, and returned 500. - `PATCH /v1/dev/user/conversations/{id}` persisted the title, then returned 500 on the re-read, so the client saw a failure for a write that landed. - `GET /v1/dev/user/conversations` caught the same `ValidationError` per row and dropped the conversation from the page. - `GET /v1/mcp/conversations` dropped the row; `GET /v1/mcp/conversations/{id}` turned it into a 404. This is the residual on SCA-2800: the list half was fixed by #25588, the other read surfaces were not. ## Fix `project_structured_defaults` fills the same defaults the app model uses (`title`/`overview` empty, `category` `other`, an invalid or unhashable category folded to `other`) before the response model validates. It returns a copy, so a shared or cached row never carries the projected defaults onward, and the stored document is never rewritten. The published schemas still require the fields, matching the #25588 pattern. Applied on: - developer detail (`read_conversation_item`), - developer list (before `Conversation.model_validate`), - developer PATCH re-read, - MCP cards (`conversation_card`, so list/search/detail and the MCP tool handlers all share one projection). The MCP call keeps its existing disposition for a *malformed* category: only a missing category is filled, so an out-of-enum value still reaches the MCP per-record skip guard. ## Diff scope - `backend/utils/conversations/structured_defaults.py` — new shared projection. - `backend/utils/developer_item_reads.py` — detail route uses it. - `backend/routers/developer.py` — list and PATCH use it (no line-count growth). - `backend/utils/mcp_server/helpers.py` — `conversation_card` fills the missing fields. - `backend/tests/unit/test_dev_api_conversations_poison.py` — v3 row through list/detail for a missing, out-of-enum and unhashable category; PATCH case asserting 200 and the title write; app-model disposition; copy-not-mutate. - `backend/tests/unit/test_mcp_conversations_poison.py` — v3 row without category survives the MCP list and detail. No change to `source` semantics for new rows, the share projection, participant identity/alias rules, or the v3 projection write path. The app routes keep a participant without `source` under `transcript`; the developer list/detail payloads have no participants field, so it is absent there. ## Test command and output ``` $ cd backend && python -m pytest tests/unit/test_dev_api_conversations_poison.py -q 22 passed, 2 warnings in 1.39s $ cd backend && python -m pytest tests/unit/test_mcp_conversations_poison.py -q 4 passed, 1 warning in 0.57s ``` The new cases fail on the pre-fix tree: both MCP cases (`list` drops, `detail` 404s) and the developer PATCH case (`2 failed` / `1 failed` respectively). Related files, each in its own process: ``` test_mcp_data_endpoints.py 116 passed test_mcp_detail_views.py 27 passed test_chat_addressable_refs.py 16 passed test_mcp_sse_pagination_bounds.py 9 passed test_home_transcribing_hold.py 110 passed test_developer_read_routes.py 6 passed test_conversations_v3_participant_source.py 2 passed ``` ## Kill switch Revert this commit. The developer list/detail/PATCH return to 500 or dropping such rows, the MCP list/detail to dropping or 404ing them, and no data changes. ## Product invariants affected none ## Failure class (fixes) Failure-Class: FC-response-model-decoupled-from-projection
…ersations-v3 first (SCA-2967) (#25713) ## What changed and why SCA-2967. Activating conversations-v3 for TestFlight on 2026-11-17 needed several services to move in a fixed order: backend Cloud Run, then llm-gateway, then pusher, then listen. Nothing encoded that order, and each gap was found in prod or by luck: - llm-gateway was two weeks stale and had no v3 lanes; - pusher lacked the `SYNC_TASKS_PROJECT`/`SYNC_TASKS_LOCATION` that listen sets; - pusher's image was 8 days old (version skew); - the `conversations-v3` queue and the v3 scheduler jobs did not exist. KB evidence: `evidence/2026-11-17-v3-testflight-activation-escapes.md` (#7, #8) and `2026-11-17-delivery-debt-from-v3-rollout.md` (D1, D8). This PR adds a feature activation manifest (data) and a read-only tool that checks it against live serving state. The first manifest is conversations-v3. **The tool is not wired into any gate.** - `backend/deploy/activation/conversations-v3.yaml` lists: - the services and the commits each must contain (ancestry, not an exact SHA); - the order they must move in; - env keys that must be set, and equal across runtimes where that matters; - gateway lanes, the queue and the scheduler jobs. Each entry has a `why` that points at the code or incident behind it. The format is in `backend/deploy/activation/README.md`. - `backend/scripts/activation_check.py` is pure: manifest + state JSON in, verdict out. Each requirement is `satisfied`, `missing`, `unknown` or `deferred`. - Exit codes: `0` READY; `1` BLOCKED (a controlled requirement is missing); `2` UNKNOWN (nothing missing, but a controlled requirement could not be read); `3` invalid input. - `unknown` never counts as satisfied. - Some requirements are owned elsewhere: anything marked `controlled: false` (the backfill queue), and anything listed under `not_checked` (Firestore indexes, owned by the index readiness gate). They are always reported, and the report says who owns them, but they never change the exit code. - `--before <service>` checks only the requirements due before that service moves. - The verdict prints the state's `collected_at`. - `backend/scripts/activation_collect.py` reads prod metadata only: - Cloud Run: only the revisions receiving traffic, from `status.traffic`, never the spec. - GKE: the Deployment template env, with ConfigMaps resolved, and the image digests of running pods. - Cloud Tasks queues and Scheduler jobs: one `list` call per location. Serving identity comes from the image: its OCI `org.opencontainers.image.revision` label, else its commit tag. The prod pusher digest is looked up in the dev registry it was promoted from. `OMI_BACKEND_RELEASE_SHA` is only recorded, as `release_env`: env merges never remove a value, so it can name a release the revision does not serve. The collector never reads Secrets and records only the env keys the manifest names. The checker's report prints key and runtime names, never values. ### v3 requirements | Kind | Requirement | | --- | --- | | Order | 1. `backend`, `backend-sync`, `backend-sync-backfill`, `backend-integration`, `desktop-backend` → 2. `llm-gateway` → 3. `pusher` → 4. `backend-listen` → lever (`CONVERSATIONS_V3_STAGE` / `CONVERSATIONS_V3`) | | Contains | Writers (`backend`, `backend-integration`, `backend-listen`): #25500, #25588, #25658, #25661. Builder hosts (`backend-sync`, `backend-sync-backfill`): the same plus #25691. `llm-gateway`: #25500 (v3 lanes). `pusher`: #25500 (v3-aware finalization), #25658 (admission) | | Gateway lanes | `omi:auto:conversation-v3-outline`, `-summary`, `-summary-open`, `omi:auto:conv-action-items` | | Env | `v3-task-binding`: `SYNC_TASKS_PROJECT`/`LOCATION`/`INVOKER_SA` set and equal on the six writers.<br>`v3-task-target`: `CONVERSATIONS_V3_TASKS_URL` or `SYNC_TASKS_HANDLER_URL`.<br>`v3-stage`: `CONVERSATIONS_V3_STAGE` equal on the writers and desktop (code default `beta` for an absent key).<br>`v3-kill-switch`: `CONVERSATIONS_V3` equal.<br>`v3-gateway-endpoint`: `OMI_LLM_GATEWAY_URL` on `backend` and `backend-sync`; the placeholders `http://127.0.0.1:9` and `:9080` count as unset | | Queues | `conversations-v3` (controlled); `conversations-v3-backfill` (`controlled: false`) | | Scheduler | `conversations-v3-sweep`, `conversations-v3-legacy-users` (ENABLED) | | Not checked | Firestore composite indexes (index readiness gate) | ### How Release calls it (not in this PR) Before each step of the train, and before a stage or kill-switch move: 1. `source ~/.local/bin/gcp-agent-env.sh ro-prod && git fetch origin`. 2. `python3 backend/scripts/activation_collect.py --manifest backend/deploy/activation/<feature>.yaml --cluster prod-omi-gke --promoted-from-gcloud-config ~/.config/gcloud-agent/ro-dev --out state.json`. 3. `python3 backend/scripts/activation_check.py --manifest … --state state.json --before <service|activate> --json`. 4. On exit 1, stop and name the missing requirements. On exit 2, a human reviews the unknowns. On exit 0, proceed. Only controlled requirements affect the exit code, so the check trips only on signals the activation controls. The meta-repo train (`omi-deploy-prod` / `train.sh`) can call these two scripts from its release checkout; that wiring is a separate change. ## Product invariants affected none ## How it was verified - `backend/.venv/bin/python -m pytest -q backend/tests/unit/test_activation_manifest.py`: 38 passed. - **2026-11-17 fixture** (`backend/tests/unit/fixtures/activation/state-2026-11-17.json`): `verdict=BLOCKED`, exit 1, satisfied=63, missing=14, unknown=1. Missing: - stale gateway: `service:llm-gateway:contains:012329830a9e`, plus the three lanes `lane:omi:auto:conversation-v3-outline` / `-summary` / `-summary-open`; - old pusher image: `service:pusher:contains:012329830a9e` and `:156b50921d7e`; - pusher task binding: `env:v3-task-binding:pusher:SYNC_TASKS_PROJECT` and `:SYNC_TASKS_LOCATION`, with their two `env-equal` results; - infra: `queue:conversations-v3`, `scheduler-job:conversations-v3-sweep`, `scheduler-job:conversations-v3-legacy-users`; - the backfill queue (advisory). The one unknown is the advisory Firestore-index item. With `--before backend-listen`, the gateway, pusher and infra gaps still block, and listen's own 10 requirements are deferred. - **Correct-state fixture** (`state-ready.json`): `verdict=READY`, exit 0, satisfied=77, missing=0; the only unknown is the advisory Firestore-index item. - **Current prod, collected 2026-11-18T19:24:59Z** with the read-only `ro-prod` identity, plus `ro-dev` for the dev-registry tag only. Metadata reads only, no writes. - `verdict=READY`, exit 0: satisfied=77, missing=0, unknown=1 (advisory `external:firestore-indexes`). - All 9 services resolved to a source commit, all 4 lanes are served, all env requirements are met and equal, the `conversations-v3` queue is RUNNING, and both v3 jobs are ENABLED. - The first manifest draft required #25691 on `backend-listen`, and prod (listen serving 44d0a4f) reported it missing. Short-task extraction runs only on the sync task handler, so that requirement now applies to the builder hosts only. - `scripts/pr-preflight --pr-body-file` passed, and so did `python3 .github/scripts/check_release_rings.py` (the scope panel warned against reusing the forbidden "release ring" names). ### Panels - **Scope** `scope-20261118t174316-a7fd`: only glm-flash completed; luna failed to launch (journal busy) and deepseek failed. Taken from it: - `activation` naming; - CLI and tests only, with no checks-manifest entry or cross-service invariant (check budget); - queue and scheduler ownership (ops_train, scheduler_reconcile); - keep the manifest from drifting away from `runtime_env` (handled by a drift test). Two of its claims were contradicted by live reads, and I resolved them that way: - It said `OMI_BACKEND_RELEASE_SHA` is the true marker. Image identity is used instead, per the documented env-merge misread. - It said prod pusher's digest has no live source. The dev-registry tag does resolve it. - **Review** `review-20261118t185330-8905` (FIX-FIRST; deepseek and glm-flash; luna failed to launch): - Accepted and fixed in d204e36: F1, F4–F17. - F2/F3: the PR body first posted was another lane's (SCA-2966), because a scratch file was shared between sessions. It has been replaced with this one. ## Tests `backend/tests/unit/test_activation_manifest.py` covers: - **Fixtures:** each 11-17 escape is reported by name; the correct state passes. - **Unknown handling:** an unreadable service, ancestry or lanes gives UNKNOWN (exit 2), never satisfied; missing beats unknown; uncontrolled requirements never change the exit code; split traffic (every serving revision must contain the commit); an env-equal result with one unreadable unit is unknown. - **Env values:** stage skew, code defaults versus an explicit empty value, the placeholder URLs, `any_of` and Secret refs. - **Order and input:** order deferral; invalid YAML, manifest and state exit 3. - **Collector, with fakes:** reads `status.traffic` and never the spec; never reads Secrets; resolves ConfigMap and `envFrom`; resolves promoted digests; failed reads become unknown; pod digest counting; container choice; `Registry.source` (label, index, tag fallback, ambiguity); only Google registry hosts. - **Drift:** queue, job and lane names are parsed exactly from `ops/prod.yaml`, `scheduler/jobs.yaml` and `generated_route_overrides.yaml`. Every required env key is declared for each runtime in the composed prod `runtime_env.yaml`; this would have caught pusher's missing task binding at PR time. ## UI evidence UI-Evidence: none -- backend tooling, no UI ## Failure class (fixes) Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code)
What broke
The v3 recording planner writes each named person into
structured.participantsas{'name': ...}.Structured.Participant.source(roster|transcript) is required. Since listen began creating v3 recordings in prod (2026-11-17 08:36Z, TestFlight beta stage), any v3 window that names a person makes:GET /v1/conversationsfail withResponseValidationErroratresponse.N.structured.participants.0.source: Field required, so that account's Home list does not load;/v1/conversations-v3/reconcilefail in_processatConversation(**row)with the same missing field, so no notes are written (226 of 298 sampled reconcile calls 500 between 08:00 and 08:45Z).Fix
planner.buildwritessource: 'transcript'for each participant (the window's people come from the transcript outline).Structured.participantsgets amode='before'validator, in both the SDK model and the in-repo fallback, that fills a missingsourcewithtranscript. Rows already stored keep loading without a data rewrite. The JSON schema is unchanged:sourceremains required for model output.models/structured.pyis a hashed notes prompt source, soNOTES_PROMPT_VERSIONmoves tonotes-7with its pinned digest. The prompt, schema and output are unchanged, sonotes-6joinsNOTES_REUSABLE_PREVIOUS_VERSIONSand no stored notes are re-bought. The prod image ships onlybackend/, so the fallback model inmodels/structured.pyis the one serving.Verification
tests/unit/test_conversations_v3_participant_source.py: a planned window with two people validates asConversation; a stored{'name'}participant reads back astranscript, an explicitrosteris kept, and the schema still requiressource.CollectorRegistryregistration; run file by file as CI does, they pass (57 + 26).test_runtime_image_contracts.py::test_structured_model_fallback_imports_without_plugin_sdknow pins the SDK-absent fallback that runtime images load: it fails without this fix and passes with it.plugins/omi-plugin-sdk/tests: 15 passed.test_llm_input_prompt_version.py6 passed;test_conversation_llm_input_dedupe.py63 passed.Failure-Class: FC-response-model-decoupled-from-projection
A writer stored a nested model shape that its own required-field reader rejects, so one stored row fails every list response for that account.
UI-Evidence: none -- backend model and planner fix, no client change.
Rollback: do not revert the read-side default alone. Rows already stored without
sourcewould failGET /v1/conversationsagain for those accounts. If the planner change must go, revert onlyplanner.pyand keep theStructureddefault. To stop new v3 rows instead, roll back listen (gcp_backend_listen_helm.yml mode=rollback).🤖 Generated with Claude Code