Skip to content

Dream: verify what budget-stopped passes staged; label every unverified item; liberal verifier (shadow) - #24166

Merged
Git-on-my-level merged 6 commits into
mainfrom
lane/dream-measure-loosen
Oct 31, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
lane/dream-measure-loosen

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Dream throws away much of what it finds. On 10-30/31 it proposed about 1,170 edits a day and dropped 252 as verifier_unverified. 171 of those 252 never reached a verifier (verifier_calls = 0). 123 came from passes that stopped on their token budget and 26 from passes that stopped on their deadline. Unverified items on the default verifier chain are dropped, not offered to Review, so that work evaporates.

There were two causes:

  1. Nothing held the verifier's budget during the main loop. A pass could spend its whole budget searching and leave too little to verify what it staged.
  2. The verifier's batch byte ceiling was tokens // 8. With a tight leftover budget the ceiling fell below ordinary whole-conversation evidence, so batches() skipped every item as "oversized" and no call was made.

Changes

  • DREAM_VERIFY_HOLD_MODE (default serve; off is the kill switch). On every main-lane turn, invoke_once subtracts verification_hold_tokens(staged) from the remaining budget: two framed calls per verifier batch, plus headroom for one full batch (up to 10% of the pass budget) for proposals a turn stages together with finish. The verify budget now subtracts the search-embedding bound, as invoke_once does. The hold only moves budget from searching to verifying; total spend is unchanged and stays inside the reservation. Shadow records held only.
  • Verifier batch ceiling. verify_two sizes batches from per-call affordability, (tokens // 2 − completion) × BYTES_PER_TOKEN, still capped at 24,000 bytes, and still never truncates evidence. At today's normal verify budgets (≥ 192k) the ceiling is unchanged at 24,000.
  • verify_reasons. Every item left without two boolean votes is labelled oversized, ids_invalid, call_failed, single_vote, budget_tokens or budget_deadline, in the report and on the dream_pass record (bounded labels, no content). The rest of the 252 can then be audited from logs alone.
  • DREAM_LIBERAL_VERIFIER_MODE (default shadow). It covers auto-eligible dismiss_person, spelling, title, overview, set_language and vocabulary edits that were unverified because of budget, deadline or a failed call, where at least one verifier agreed and none disagreed. Zero-vote items never apply.
    • Serve applies them through the normal apply_verified_edit path: guards, fences, journal and Undo.
    • Never applied: after a disagree vote, a split, oversized evidence, invalid verifier ids, a question, a protected target or a demoted kind.
    • Shadow counts would_apply only.
  • Registry and runbook. Feature-flag registry rows rendered; runbook updated.

Ramp plan

  • DREAM_VERIFY_HOLD_MODE: serves globally on deploy. Clean metric: verify_reasons.budget_tokens per day falls from about 123 zero-call items; value-weighted applied edits per sweep don't fall; zero dream_lever_error lever=verify_hold. Expander: dazheng, by 2026-11-07. Rollback: DREAM_VERIFY_HOLD_MODE=off.

  • DREAM_LIBERAL_VERIFIER_MODE:

    1. Shadow 48 h (would_apply, verify_reasons).
    2. 10% serve via _SERVE_PERCENT, salted per owner (INV-MEM-5: no fixed-UID cohort).
    3. 100% after a 24 h soak.

    Clean metric: liberal-applied items' 7-day Undo rate ≤ the verified Undo rate for the same kinds; failed passes < 2/h. Expander: dazheng, by 2026-11-14. Rollback: off.

Verification

  • tests/unit/test_dream_verify_hold.py (17 tests):

    • a budget-stopped pass verifies and applies with the hold on;
    • the same pass drops the item with budget_tokens when the hold is off;
    • shadow leaves the budget unchanged;
    • liberal shadow vs serve;
    • defaults;
    • every reason label;
    • a tight hold still batches ordinary evidence;
    • a proposal staged together with finish at the budget edge is still verified;
    • multi-batch reserve;
    • the liberal path never applies zero-vote, disagreed or no-agree items;
    • local budget refusals and in-flight timeouts are labelled budget_*.
  • The Dream, agent-capabilities, review and Firestore guard suites pass under backend/test.sh: 1,791 tests, 0 failed. test_dream_budget_notice pins the hold off, because it tests the notice arithmetic.

  • Luna adversarial review: BLOCK, 4 findings, all fixed in 79e8f5a.

    1. A proposal staged with finish was unreserved: fixed by next-turn headroom.
    2. Only one batch was reserved: fixed by a per-batch reserve.
    3. The embedding bound was missing from the verify budget: fixed.
    4. Timeouts and refusals were labelled call_failed: fixed.

    The liberal path additionally requires an agree vote.

  • Luna re-review: BLOCK, 3 findings, all fixed in 8ffb25a.

    1. Headroom now funds one full batch, capped at 10% of the pass.
    2. The verifier now sends the same compact UTF-8 payload the reserve measures.
    3. A per-call timeout is labelled budget_deadline, and a budget-limited skip budget_tokens.
  • Luna final check: SHIP-WITH-NITS. Two label-precision nits fixed in the last commit: a budget stop before the second call is named as such, and an early provider timeout counts as call_failed.

  • These are unit-level results. Prod proof: verify_reasons and levers.verify_hold on dream_pass, with verifier_unverified per day falling from about 252.

Product invariants affected

None. The default arm changes only the budget split between search and verification, and the liberal lever is shadow by default with a salted-percent cohort.

Failure class

Failure-Class: none

🤖 Generated with Claude Code

Git-on-my-level and others added 4 commits October 31, 2026 18:41
…d item

Hold the two verifier calls' token reserve (sized from staged evidence) out of
the main loop (DREAM_VERIFY_HOLD_MODE, default serve) and size verifier batches
from per-call affordability instead of tokens // 8, which dropped ordinary
evidence as oversized whenever the leftover budget was tight. 10-30/31: 171 of
252 daily verifier_unverified items had zero verifier calls.

Record per-item verify_reasons on dream_pass, and add the liberal-verifier lever
(default shadow): trivially reversible auto kinds unverified by budget, deadline
or a failed call, with no disagree vote, apply with Undo under serve.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re an agree for liberal applies

Review fixes: the reserve pays two calls per verifier batch with framed prompts;
the main-loop hold adds headroom (up to 5% of the pass) for proposals a turn
stages with finish; the verify budget subtracts the search-embedding bound like
invoke_once; the liberal path needs at least one agree vote; local budget
refusals and in-flight deadline timeouts are labelled budget_*, not call_failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… per-call timeouts

Re-review fixes: next-turn headroom covers one full 24000-byte batch (capped at
10% of the pass); the verifier payload is the compact UTF-8 JSON that batch
sizing and the reserve measure; a per-call verifier timeout is budget_deadline;
a skip that is within the verifier ceiling but beyond the budget is
budget_tokens, not oversized.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…timeouts are failed calls

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 31, 2026
…dos (#24168)

## Summary

This PR adds measurement and a safety backstop before Dream gets any
more freedom. It's the second step of the bitter-lesson plan, after
#24166; the planning lenses ranked missing owner-decision data as the
biggest gap.

**Today we can't tell whether Dream's edits are wanted.**
- Undo and Review accept/dismiss decisions live only in encrypted
per-user documents. No log or metric aggregates them per kind.
- Verifier outcomes carry no kind.
- Per-owner demotion (`demoted_types`) needs 10 changes of a kind in 30
days before an undo rate can pause it. Dream reaches each owner about
weekly, so an owner who undoes 3 wrong dismissals in a row is never
protected.

## Changes

- **`dream_outcome` JSON log record** (content-free: `kind`, `decision`
undo/redo/accept/dismiss, and an applied-age bucket). It is emitted on
Undo/Redo of a Dream-journaled change and on Review answers to Dream
edit/vocabulary proposals.
- The kind is the change's `edit_kind`, not the key segment.
Memory-target spelling keys use `memory`, and accepted proposals are
re-keyed `agent:user:`.
  - An accept that writes nothing new still counts as an accept.
- The main Undo path records the transition its own transaction
committed.
  - Telemetry never raises into Undo or Review.
- **`verifier_by_kind` on every `dream_pass` record.**
- **Low-volume backstop in `demoted_types`.**
`DREAM_AGENT_UNDO_RECENT_COUNT` (3) undos among a kind's changes applied
in the last `DREAM_AGENT_UNDO_RECENT_DAYS` (7) pause that kind for the
owner. The existing 30-day rate rule is unchanged.
- Both rules now bucket by policy kind. This also fixes the old rule,
which bucketed memory-target spelling undos under `memory` while
`spelling` kept auto-applying.
- The rule depends only on the owner's own decisions, never a UID list
(INV-MEM-5).
- **Runbook** updated, including what is not yet counted: answers to
Review questions.

## Ramp plan

The backstop serves on deploy for every owner. It only ever moves an
auto kind to Review (suggest) for an owner whose own recent undos trip
it; Undo is unchanged. The outcome records are log-only.

- **Clean metric:** `dream_outcome` records appear for undo, redo,
accept and dismiss with bounded labels; applied auto edits per sweep
don't fall more than the demoted share explains; zero
`dream_telemetry_error record=outcome`.
- **Expander:** dazheng, by 2026-11-07.
- **Rollback:** `DREAM_AGENT_UNDO_RECENT_COUNT=1000`.

## Verification

- `tests/unit/test_dream_outcomes.py` covers:
- the recent backstop: it trips at 3 and not at 2 or on old undos, and
it is configurable;
- policy-kind attribution for memory-target spelling and accepted
proposals;
  - bounded, content-free payloads and age buckets;
  - `dream_kind`/`change_kind`;
  - never-raise even when error accounting fails;
  - an unchanged vocabulary accept;
  - dismiss kind;
- end to end: Undo, a repeated Undo, then Redo of a real applied Dream
change emit exactly undo then redo.
- The Dream, agent-capabilities, review and Firestore guard suites pass
under `backend/test.sh`.
- **Luna adversarial review: BLOCK with 6 findings, all fixed in
b7a0ede.**
- **Luna re-review: SHIP-WITH-NITS.** One P3 is left as a known gap: two
concurrent Undos on the specialized memory-hygiene, memory and
transcript setters can each record an Undo, because those setters don't
report whether their own transaction made the transition. The
pre-existing `omi_dream_undo_total` counter has the same race. The
follow-up is to have those setters return the transition flag.
- These are unit-level results. **Prod proof:** `dream_outcome` records
and `verifier_by_kind` in backend-sync logs.

## Product invariants affected

None. INV-MEM-5 holds: demotion is a UID-independent function of each
owner's own decisions.

## Failure class

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/24168?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24168?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24168&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
…osen

# Conflicts:
#	backend/docs/runbooks/dream-agent.md
#	backend/utils/dream_telemetry.py
@Git-on-my-level
Git-on-my-level merged commit 9bc703c into main Oct 31, 2026
56 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dream-measure-loosen branch October 31, 2026 14:17
Git-on-my-level added a commit that referenced this pull request Oct 31, 2026
…eled calibration export (#24171)

## Summary

This adds an edit-level **value judge** in shadow, the instrument the
rest of the Dream bitter-lesson plan gates on. It follows #24166 (verify
hold) and #24168 (owner-decision records and the low-volume Undo
backstop).

The second check asks whether an edit is *supported*. The judge asks
whether the owner is *better off*, which is what we actually want to
maximise. Hand-weighted edit counts can't tell 800 great edits from 800
useless ones, and 98% of today's applied edits are dismissals of junk
people.

## Design

- **Sampling.** Stratified and owner-independent:
- every applied edit of a rare, high-stakes kind (merges, memory/task
edits, `close_task`, `entity_summary`, `set_language`);
- `DREAM_JUDGE_COMMON_PERCENT` (2%) of the common kinds, chosen by a
salted hash of the edit key.

  Nothing about the owner affects selection (INV-MEM-5).
- **Blind input.** The judge sees the owner-visible change view from
`change_view.edit_change`: kind, before/after, speaker-marked cited
speech and record labels. It never sees the proposer's reason or the
verifier votes.
- **Cost and capacity.**
- One call per judged pass covers up to 25 edits, the pass edit cap, so
no rare edit is dropped.
- It runs only after **scheduled** owner passes: never canary, dry-run,
manual or operator CLI runs.
- It is **reserved capacity only**: `model_turn(reserved_only=True)`
never uses on-demand capacity.
- Spend is bounded by `DREAM_JUDGE_TOKENS_PER_PASS` (60k) and
`DREAM_JUDGE_MAX_CALLS_PER_SWEEP` (4), at most about 1% of the reserved
daily draw. Expected spend is far lower.
- **Output.** Content-free `dream_judge` records (kind, stratum,
verdict, three 0–2 scores) and `levers.value_judge` counts. It changes
no outcomes, and judge failures fail open. `DREAM_VALUE_JUDGE_MODE` is
off/shadow, default shadow.
- **Calibration (David 2026-10-31: David labels in decision-mill, via an
in-pod export of his own changes).**
- `backend/scripts/dream-label-export.py` runs in an isolated operator
pod.
- It refuses any owner not listed in `DREAM_LABEL_EXPORT_UID_SHA256S`
(fail closed).
- It samples that owner's journaled Dream changes and judges the same
projection on reserved capacity within one total allowance, stopping
after any failed call.
- It prints decision-mill `proposal` items to operator stdout, with the
judge verdict under `hidden` so labeling stays blind.
  - Labels never enter git.
- Judge scores gate nothing until their agreement with owner labels
reaches 0.7.

## Ramp plan

- Shadow on deploy (records only).
- Weekly calibration on David's account.
- Judge-based gates for later Dream changes are enabled only at ≥ 0.7
agreement with owner labels.

**Clean metric:** judge tokens ≤ 1% of daily Dream weighted tokens; zero
`dream_lever_error lever=value_judge`; `dream_judge` carries only
bounded labels and scores. **Expander:** dazheng, by 2026-11-14.
**Rollback:** `DREAM_VALUE_JUDGE_MODE=off`.

## Verification

- `tests/unit/test_dream_judge.py` (20 tests) covers:
- stratification (rare always; common share about 2%, deterministic and
owner-independent);
  - env controls fail closed;
  - a blind projection that includes cited speech with speakers;
  - supplied-id filtering and fail-open;
  - content-free records;
- end to end: a sampled applied edit is judged, an unsampled one is not,
and judge-off makes no call;
  - manual and `judge=False` runs are not judged;
  - one call covers the edit cap;
  - per-sweep caps survive overlapping sweeps;
  - reserved-only transport;
- export consent, blindness and speaker names, and stopping after a
failed call.
- The Dream, agent-capabilities, review and Firestore guard suites pass
under `backend/test.sh`.
- Luna adversarial review:
- Round 1: BLOCK, 6 findings fixed (cited speech, the 8-item cap, cost
caps, on-demand capacity, export consent, manual runs).
- Round 2: BLOCK, 4 P2s fixed (the CLI path, export spend on failure,
overlapping sweep counters, export speaker names).
- These are unit-level results. **Prod proof:** `dream_judge` records in
backend-sync logs, and `levers.value_judge` on `dream_pass`.

## Product invariants affected

None. Sampling is owner-independent, the judge is shadow-only, and the
export is operator-only for a consenting owner.

## Failure class

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/24171?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24171?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24171&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Oct 31, 2026
…shoots (#24193)

## Why

#24166 (verify hold, live since the 10-31 15:11Z train, revision
`*-14d7e31-*`) was meant to stop staged Dream edits from being dropped
unverified when a pass runs out of budget. A prod readback shows it
doesn't (ro-prod, `dream_pass` lines on backend-sync, 10-31
15:30–21:18Z):

- 60 edits unverified in 5.8 h, about 248 a day against the 252/day
baseline before the hold.
- 44 of the 60 have the reason `budget_tokens`, and most of those come
from passes with `verifier_calls 0`.
- Those passes end at a weighted spend of 1,005,644–1,057,707 against a
1,000,000 limit, or just over 625,000 on medium passes. The hold
(33–80k) was reserved, but a main turn cost more than its pre-call
estimate (a cache miss on a 1.3–2.2M-token history) and spent it. The
verify lane then has nothing left, and every call raises
`dream_input_token_budget`.

## What

- After the main loop ends, a served hold
(`DREAM_VERIFY_HOLD_MODE=serve`, already the default) gives the main
verification call an allowance: the staged items' two-call reserve,
minus whatever budget the pass still has. Both `invoke_once`'s remaining
budget and `verify_budget` use it, so batch sizing matches what the
calls can afford.
- The allowance applies only to the `dream_verify.verify` call. It is
cleared in `finally`, so the value judge and the shadow state pass,
which share the verify lane, never draw on it.
- `levers.verify_hold.allowance` records the allowance granted on each
pass.

## Spend

Everything stays on the gemini-3.8-flash reservation; Dream is
reserved-only, so there is no new vendor spend. A pass can now go over
its token limit by the overshoot already spent plus one two-call reserve
for its staged items: 33–80k weighted in the readback, about 3–8% of a
heavy pass. That is the same verification #24166 meant to pay for. The
judge and state-pass allowances are unchanged.

## Rollout

- No new flag. The fix sits behind the existing kill switch:
`DREAM_VERIFY_HOLD_MODE=shadow` or `off` removes both the hold and the
allowance.
- Metric that must stay clean: unverified edits per day
(`verify_reasons.budget_tokens`). It should fall well below 252/day,
with no rise in `failed` passes or `dream_lever_error
lever=verify_hold`.
- The Dream owner reads it back after the train.

## Tests

- New tests in `backend/tests/unit/test_dream_verify_hold.py`:
  - a served hold still verifies after a 200k overshoot;
  - a shadow hold grants no allowance;
- the allowance never funds the value judge. This test fails with the
`finally` removed (mutation-checked).
- All 46 `tests/unit/test_dream*.py` files pass through `test.sh` under
`omi-heavy`.
- Luna review: round 1 BLOCK (the judge leak), fixed in 8ffa796.

Failure-Class: none

Line-Count-Exception: backend/utils/dream_agent.py | 1586 -> 1598 | the
verify-lane allowance lives beside the hold and judge/state allowances
it must stay scoped against; splitting the pass loop is out of scope for
a one-bug fix

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/24193?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24193?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24193&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Nov 1, 2026
…ate pass in shadow (#24293)

## 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](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