Repository navigation
Dream: edit-level value judge (shadow), reserved-only, with owner-labeled calibration export - #24171
Merged
Merged
Conversation
…ee; weekly owner-labeled calibration export utils/dream_judge.py judges sampled applied edits after a pass's effects on the reserved verifier lane: every rare high-stakes kind and DREAM_JUDGE_COMMON_PERCENT (2) of common kinds by salted edit key (owner-independent). Input is the owner-visible change view without the proposer's reason or verifier votes; output is content-free dream_judge records and levers.value_judge counts, within an extra DREAM_JUDGE_TOKENS_PER_PASS allowance. DREAM_VALUE_JUDGE_MODE off/shadow. backend/scripts/dream-label-export.py (operator pod, authorized owner only) samples that owner's journaled Dream changes, judges the same projection, and prints decision-mill proposal items with the judge verdict hidden, so owner labels measure the judge's agreement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… all edits, sweep cap, consented export Review fixes: the projection keeps speaker-marked cited speech; one call covers up to 25 edits so no rare edit is dropped; DREAM_JUDGE_MAX_CALLS_PER_SWEEP (4) and a 60000-token allowance bound spend, and the export spends one total allowance; judge and export calls request reserved capacity only (model_turn reserved_only); the export refuses owners not in DREAM_LABEL_EXPORT_UID_SHA256S; only scheduled owner passes are judged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rvive overlap; export stops after a failed call; export keeps speaker names Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y flag registry Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # backend/utils/dream_agent.py
# Conflicts: # backend/docs/feature-flag-registry.md # backend/utils/dream_agent.py # config/feature-flags.yaml
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.
model_turn(reserved_only=True)never uses on-demand capacity.DREAM_JUDGE_TOKENS_PER_PASS(60k) andDREAM_JUDGE_MAX_CALLS_PER_SWEEP(4), at most about 1% of the reserved daily draw. Expected spend is far lower.Output. Content-free
dream_judgerecords (kind, stratum, verdict, three 0–2 scores) andlevers.value_judgecounts. It changes no outcomes, and judge failures fail open.DREAM_VALUE_JUDGE_MODEis 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.pyruns in an isolated operator pod.DREAM_LABEL_EXPORT_UID_SHA256S(fail closed).proposalitems to operator stdout, with the judge verdict underhiddenso labeling stays blind.Ramp plan
Clean metric: judge tokens ≤ 1% of daily Dream weighted tokens; zero
dream_lever_error lever=value_judge;dream_judgecarries 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:judge=Falseruns are not judged;backend/test.sh.dream_judgerecords in backend-sync logs, andlevers.value_judgeondream_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