Skip to content

Dream: edit-level value judge (shadow), reserved-only, with owner-labeled calibration export - #24171

Merged
Git-on-my-level merged 8 commits into
mainfrom
lane/dream-value-judge
Oct 31, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
lane/dream-value-judge

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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

View guided diff Turn on auto-fix

Git-on-my-level and others added 8 commits October 31, 2026 19:50
…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]>
# Conflicts:
#	backend/docs/feature-flag-registry.md
#	backend/utils/dream_agent.py
#	config/feature-flags.yaml
@Git-on-my-level
Git-on-my-level merged commit 642ebe9 into main Oct 31, 2026
56 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dream-value-judge branch October 31, 2026 14:43
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