Repository navigation
fix(dream): keep voice fields out of verifier evidence and run the state pass in shadow - #24293
Conversation
Sets DREAM_STATE_PASS_MODE=shadow on backend-sync and backend-sync-backfill. Shadow stages, verifies and renders only, on reserved capacity. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
1 issue found across 4 files
Confidence score: 5/5
backend/docs/feature-flag-registry.mdstill lists onlybackend-syncin the rollout plan, so it misses that shadow mode is enabled onbackend-sync-backfilltoo. Update the plan to include both.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/docs/feature-flag-registry.md">
<violation number="1" location="backend/docs/feature-flag-registry.md:237">
P3: The rollout plan is now stale: this change enables `DREAM_STATE_PASS_MODE=shadow` on both `backend-sync` and `backend-sync-backfill`, but the plan still names only `backend-sync`. Update the feature-flag source ramp to name both services and regenerate the registry so operators know the backfill lane is intentionally covered.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| | `DREAM_REQUIRED_INTAKE_BACKLOG_COHORT` | Empty denies historical fold-in; explicit uid:<owner>,pct:<0..100> or all cohort, separate from ordinary Dream eligibility | backend | env | closed | — | — | — | — | pending | on | 2026-11-07 | dazheng | | ||
| | `DREAM_REQUIRED_INTAKE_BACKLOG_ENABLED` | Default off; Dream retrospectively resolves historical pending required submissions after canonical-neighbor dedupe and independent verification | backend | env | closed | — | — | — | — | pending | on | 2026-11-07 | dazheng | | ||
| | `DREAM_STATE_PASS_MODE` | Weekly whole-corpus Dream state pass per owner (projected people, generated tasks, memory facts, recent conversation titles; one planning call), staged and verified but never applied, plus a ref-grounded profile v2 written only to users/{uid}.ai_user_profile_v2 with no reader: off/shadow; serve runs as shadow; default off | backend | env | open | — | — | — | — | pending | undecided | 2026-11-21 | dazheng | | ||
| | `DREAM_STATE_PASS_MODE` | Weekly whole-corpus Dream state pass per owner (projected people, generated tasks, memory facts, recent conversation titles; one planning call), staged and verified but never applied, plus a ref-grounded profile v2 written only to users/{uid}.ai_user_profile_v2 with no reader: off/shadow; serve runs as shadow; default off | backend | env | open | — | — | shadow | — | pending | undecided | 2026-11-21 | dazheng | |
There was a problem hiding this comment.
P3: The rollout plan is now stale: this change enables DREAM_STATE_PASS_MODE=shadow on both backend-sync and backend-sync-backfill, but the plan still names only backend-sync. Update the feature-flag source ramp to name both services and regenerate the registry so operators know the backfill lane is intentionally covered.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/feature-flag-registry.md, line 237:
<comment>The rollout plan is now stale: this change enables `DREAM_STATE_PASS_MODE=shadow` on both `backend-sync` and `backend-sync-backfill`, but the plan still names only `backend-sync`. Update the feature-flag source ramp to name both services and regenerate the registry so operators know the backfill lane is intentionally covered.</comment>
<file context>
@@ -234,7 +234,7 @@ and an explicit empty literal renders as `''`.
| `DREAM_REQUIRED_INTAKE_BACKLOG_COHORT` | Empty denies historical fold-in; explicit uid:<owner>,pct:<0..100> or all cohort, separate from ordinary Dream eligibility | backend | env | closed | — | — | — | — | pending | on | 2026-11-07 | dazheng |
| `DREAM_REQUIRED_INTAKE_BACKLOG_ENABLED` | Default off; Dream retrospectively resolves historical pending required submissions after canonical-neighbor dedupe and independent verification | backend | env | closed | — | — | — | — | pending | on | 2026-11-07 | dazheng |
-| `DREAM_STATE_PASS_MODE` | Weekly whole-corpus Dream state pass per owner (projected people, generated tasks, memory facts, recent conversation titles; one planning call), staged and verified but never applied, plus a ref-grounded profile v2 written only to users/{uid}.ai_user_profile_v2 with no reader: off/shadow; serve runs as shadow; default off | backend | env | open | — | — | — | — | pending | undecided | 2026-11-21 | dazheng |
+| `DREAM_STATE_PASS_MODE` | Weekly whole-corpus Dream state pass per owner (projected people, generated tasks, memory facts, recent conversation titles; one planning call), staged and verified but never applied, plus a ref-grounded profile v2 written only to users/{uid}.ai_user_profile_v2 with no reader: off/shadow; serve runs as shadow; default off | backend | env | open | — | — | shadow | — | pending | undecided | 2026-11-21 | dazheng |
| `DREAM_VALUE_JUDGE_MODE` | Edit-level Dream value judge on applied changes (every rare high-stakes kind, a salted share of common kinds) on the reserved verifier lane; emits content-free dream_judge records only: off/shadow; default shadow | backend | env | open | — | — | — | — | keep | keep | 2026-11-14 | dazheng |
| `DREAM_VERIFY_HOLD_MODE` | Hold the two Dream verifier calls' token reserve, sized from staged evidence, out of the main loop so budget-stopped passes still verify their staged work: off/shadow/serve; default serve, shadow records held only | backend | env | open | — | — | — | — | keep | keep | 2026-11-07 | dazheng |
</file context>
A person cited only as evidence sent speaker_embedding and speech sample fields to the verifiers. Strip them in minimal_context, after staging has judged protection, and pass has_voice_profile instead. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
A prefix filter missed the nested person_voice_base and person_voice_confirmations, which hold embeddings, sample paths and transcripts. An allowlist also keeps later voice fields out by default. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…4309) ## Why Dream's main loop could put a person's voice data in front of a model. A review of the state pass (#24293) found these paths. The state pass doesn't use them; the live main loop does. A person record read in full includes `speaker_embedding`, the speech sample fields (paths and transcripts) and the nested `person_voice_base` and `person_voice_confirmations`. All of it stayed on the reserved Gemini model and in the owner's scope, but the model has no need for it. **How often this happened in prod is not measured.** ## What `model_view` in `agent_capabilities/evidence.py` gives a model only an allowlist of person fields, plus `has_voice_profile: true` when real voice data exists. A voice field added to person rows later stays out by default. It now covers every path below: - **Read tool:** `Session.read` returns the model view. The read budget charges what the model sees. - **Seed prompt:** a dirty person record placed in the seed reaches the prompt as the model view. - **Previous notes:** see Behaviour change. - **Question quotes:** a question citing a person must quote text from the model view, so it can't carry hidden voice text to a verifier. - **Verifier evidence:** `dream_verify.minimal_context` uses the same function, replacing the copy from #24293. The session keeps the full row in `Session.records`. Staging and the protection checks (`require_unprotected_person`) read that, so a person with voice data stays protected. `Session` is shared, so this applies to every authority it serves, not only Dream. **Depends on #24293**, whose commits appear in this diff until it merges. The lead has it queued. ## Behaviour change - No user-visible change expected. - A model can no longer read a person's sample transcripts. Nothing in Dream's instructions relies on them, but a pass that used those words as context loses them. - **Old notes dropped once:** notes a model wrote before this deploy could contain words copied from a sample transcript, and a model could carry them forward. New runs mark their notes (`notes_voice_free`), and `dream_seed.load` ignores unmarked notes, so each owner's next pass after deploy starts without its previous notes, once. - Person rows are smaller, so reads cost slightly less of the byte budget. - Spend: none added, reserved capacity only. ## Rollout The voice narrowing has no flag, because it only narrows what a model sees; rollback is reverting the PR. Until #24293 merges, this PR's diff also contains that PR's `DREAM_STATE_PASS_MODE=shadow` rollout, which has its own ramp plan and rollback. Merge #24293 first. Metric that must stay clean: applied edits per complete pass and the second-check agreement rate, with no rise in `dream_lever_error` or failed passes. The Dream owner reads back after the train. David has not ruled on this. The rollout lead ruled to proceed without waiting because it only narrows data (bus, 21:17Z); David was told. ## Product invariants affected - INV-MEM-4: named because `runtime_env.yaml` matches its path glob, through #24293's commits in this diff. This PR adds no memory intake or promotion route. ## Review Luna R1 returned BLOCK on old notes carrying voice text. Luna R2 showed my first answer, that the path drains by itself, was wrong, because a model can copy notes forward. Fixed in code as above. Luna R3 cleared the code and returned BLOCK only on this PR body's rollout wording, corrected above. ## Tests New `tests/unit/test_dream_voice_narrow.py`, 8 tests, plus one in `test_dream_verify_hold.py`. Reverting each of the read output, seed prompt, read charge, quote, notes marker and notes filter changes fails its matching test. All `test_dream*.py`, `test_agent_tool_rules.py` and `test_review_stale_answers.py` pass under `test.sh` via `omi-heavy`. Failure-Class: none Line-Count-Exception: backend/utils/dream_agent.py | 1606 -> 1607 | one field marking notes beside the notes it describes; splitting the pass loop is out of scope for this fix 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Why
Dream's weekly state pass has been merged and off since #24166, #24168 and #24171 went live. The rollout lead approved turning it on in shadow (bus 88966c). Until it runs in shadow, we have no numbers to decide whether it should ever serve.
What
Sets
DREAM_STATE_PASS_MODE=shadowin the prod overlay onbackend-sync, which runs the sweep today, and onbackend-sync-backfill, where #24216 moves it once the scheduler is reconciled. Setting both means the flag doesn't get lost in the move.runtime_env.yamland the feature flag registry doc are regenerated, and the flag is added to the deployment-setting classification.In shadow, the pass's people and task cleanup proposals go through staging and the two verifiers and are never applied or offered. It does write: the ref-grounded profile v2 and the planner's notes on each processed owner's user doc (
users/{uid}.ai_user_profile_v2), and thelast_state_pass_atcadence stamp on the owner'sdream_usersstate record. No product feature reads the profile v2 or the notes yet, so no user sees any change; the state pass itself rereads them for its next run.Voice fix: verifier evidence for a person now comes from an allowlist (
PERSON_EVIDENCE_FIELDSindream_verify.py). Reading a person record in full returnsspeaker_embedding, the speech sample fields and the nestedperson_voice_baseandperson_voice_confirmations, and staging needs them to protect that person, so they can't be dropped at read time. A person with voice data can't be an edit target, but one cited only as evidence would have sent those fields to the verifiers. In a person's evidence row, verifiers now get only the listed fields, plushas_voice_profile: truewhen real voice data exists. A voice field added later stays out by default. This also covers the main Dream loop's verifier calls, which use the same function.Not fixed here (main loop only, existing live behaviour, flagged to David):
readtool (agent_capabilities/session.py) can return a full person row, voice fields included, to the planning model.quoteis matched against the full cited record (guards.verbatim_quote) and sent in the verifier payload, so a model that read a person's sample transcript could quote it to a verifier.The state pass reaches neither: its planner gets slim projections, and
StatePlanhas only cleanup and profile ops, so it cannot stage a question.Data the pass reads: the planner sees slim projections (people without voice fields, generated tasks, memory facts, conversation titles). Staging and the cleanup verifiers then read the records the plan cites, up to 48 per pass, with person rows narrowed as above; the profile-line check uses the slim projections. A whole-conversation citation sends that conversation's full transcript text to the verifiers. This is the same read path and reserved model the main Dream loop already uses, with no new provider, but this PR does turn that flow on for the state pass.
The 1800s backfill request timeout the lead also approved is not in this PR. The deploy passes per-service flags only for
backend-integration, so setting it in source means editing.github/actions/, which needs David to name the change. Details are on the bus (253fbd).Spend
Reserved capacity on gemini-3.8-flash only, so no added vendor spend. Limits:
DREAM_STATE_PASS_TOKENS_PER_PASS(120000) covers the planner, cleanup verifiers and profile-line check.DREAM_STATE_PASS_SECONDS(480) covers that same work. The profile write runs after it, on purpose: the transaction refuses to start past the deadline but can finish just after it.DREAM_STATE_PASS_MAX_PER_SWEEP(4), and one complete pass per owner per week.levers.state_pass.total_tokens.Rollout
backend/docs/feature-flag-registry.md, measured over at least 300 shadow state passes.DREAM_STATE_PASS_MODE=off, or revert this PR. That stops new runs but does not cancel one in progress; profile v2 fields already written stay on user docs, unread.levers.state_passondream_passlines.Product invariants affected
runtime_env.yamlmatches its path glob. Shadow proposals are never applied, and profile v2 lives on the user doc with no reader, so this adds no memory intake or promotion route.Review
Tests
test_person_voice_fields_never_reach_a_verifiercovers top-level, nested and future voice fields; it failed when the first version of the fix was reverted, and the allowlist passes it.test_dream_verification,test_dream_verify_holdandtest_dream_state_passpass.Config:
test.shviaomi-heavyontest_backend_runtime_env_validator,test_render_backend_runtime_env,test_check_cloud_run_env_drift,test_config_train,test_cloud_run_service_identity,test_cloud_run_forbidden_env_deployandtest_dream_state_pass: 148 passed. Not run in prod yet.Failure-Class: none
🤖 Generated with Claude Code