Skip to content

fix(dream): keep voice fields out of verifier evidence and run the state pass in shadow - #24293

Merged
Git-on-my-level merged 5 commits into
mainfrom
lane/dream-state-shadow
Nov 1, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
lane/dream-state-shadow

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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=shadow in the prod overlay on backend-sync, which runs the sweep today, and on backend-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.yaml and 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 the last_state_pass_at cadence stamp on the owner's dream_users state 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_FIELDS in dream_verify.py). Reading a person record in full returns speaker_embedding, the speech sample fields and the nested person_voice_base and person_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, plus has_voice_profile: true when 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):

  • The main loop's read tool (agent_capabilities/session.py) can return a full person row, voice fields included, to the planning model.
  • A staged question's quote is 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 StatePlan has 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.
  • Outside those caps: the shadow value judge that follows a pass. It has its own per-sweep counter, so it adds up to 4 calls per sweep on top of the normal judge's 4, each with a 60000-token allowance (up to 240000 tokens per sweep). It is bounded by the outer Dream pass deadline, and its tokens are not in levers.state_pass.total_tokens.

Rollout

  • Metric and gates: the row for this flag in backend/docs/feature-flag-registry.md, measured over at least 300 shadow state passes.
  • Who expands it: the Dream owner reads back after the train. Serving is a later change; this PR only reaches shadow.
  • Rollback: set 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.
  • Readback: levers.state_pass on dream_pass lines.

Product invariants affected

  • INV-MEM-4: named because runtime_env.yaml matches 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

  • Luna R1 returned BLOCK on the PR body, not the config: it understated the transcript reads, the 480s scope and the separate judge calls, and put the cadence stamp on the wrong record. All were checked against the code and are corrected above. That code is already merged and behaves as its comments and the runbook intend, so this PR has no code change for them.
  • Luna R2 returned BLOCK on voice fields reaching the verifiers, and R3 on nested voice fields that the first fix missed. The allowlist above replaces that first fix.
  • Luna R4 cleared the allowlist and returned BLOCK on the question-quote path above. It is main-loop only, so it is disclosed here and left to the read-tool follow-up.

Tests

test_person_voice_fields_never_reach_a_verifier covers 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_hold and test_dream_state_pass pass.

Config: test.sh via omi-heavy on test_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_deploy and test_dream_state_pass: 148 passed. Not run in prod yet.

Failure-Class: none

🤖 Generated with Claude Code

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]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-01T20:03:19.796860Z
We couldn’t complete this review. Comment @codex review to try again.
1d1bfad PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 4 files

Confidence score: 5/5

  • backend/docs/feature-flag-registry.md still lists only backend-sync in the rollout plan, so it misses that shadow mode is enabled on backend-sync-backfill too. 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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

Git-on-my-level and others added 2 commits November 2, 2026 03:30
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]>
@Git-on-my-level Git-on-my-level changed the title chore(dream): run the state pass in shadow on the sweep hosts fix(dream): keep voice fields out of verifier evidence and run the state pass in shadow Nov 1, 2026
Git-on-my-level and others added 2 commits November 2, 2026 03:44
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]>
@Git-on-my-level
Git-on-my-level merged commit ae977c2 into main Nov 1, 2026
61 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dream-state-shadow branch November 1, 2026 22:06
Git-on-my-level added a commit that referenced this pull request Nov 1, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant