Skip to content

Dream: count owner decisions per kind; pause a kind after 3 recent undos - #24168

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

Git-on-my-level merged 3 commits into
mainfrom
lane/dream-measure-backstops

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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

View guided diff Turn on auto-fix

Git-on-my-level and others added 3 commits October 31, 2026 19:22
… undos

dream_outcome JSON records (kind, undo/redo/accept/dismiss, applied-age bucket)
on Undo/Redo of Dream changes and on Review answers; verifier_by_kind on every
dream_pass. Demotion adds a low-volume backstop: DREAM_AGENT_UNDO_RECENT_COUNT
(3) undos among changes applied in the last DREAM_AGENT_UNDO_RECENT_DAYS (7)
pause that kind for the owner, alongside the existing 30-day rate rule whose
10-sample floor never protected owners Dream reaches weekly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aise

Review fixes: demotion and outcome records use the change's edit_kind (memory-
target spelling keys 'memory'; accepted proposals are re-keyed agent:user:);
an accepted proposal counts as accept even when it wrote nothing new; the main
Undo/Redo path records the transition its transaction committed; telemetry
error accounting is best-effort; the runbook names what is and is not counted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit b0c4430 into main Oct 31, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dream-measure-backstops branch October 31, 2026 13:27
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 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