Repository navigation
Dream: run on the 3.8 reservation and ramp to paid owners - #23016
Conversation
The Vertex reservation moved from gemini-2.5-flash to gemini-3.8-flash around 2026-10-20 23:00Z. Since then it has served only reservation probes, while the allowlisted owner's passes ran on paid on-demand capacity. - DREAM_ON_DEMAND_ENABLED=false on prod backend services, listen and pusher, so every Dream pass uses the reservation; reservation headroom is Dream's global cap. - DREAM_AGENT_PASSES_PER_DAY 6 -> 48 on backend, backend-sync and backfill, restoring the pre-switch cadence. - New DREAM_AGENT_PAID_PERCENT: a stable per-owner bucket (salted sha256 % 100) under ELIGIBILITY=paid. Unset means all paid owners; malformed admits none. Listed owners stay eligible at any percent and are checked against the cached member list, not with a per-owner read. - Prod eligibility allowlist -> paid at 5%. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ices One declaration source per ramp key: DREAM_AGENT_PAID_PERCENT lives in the prod Cloud Run overlay only. Passes run on backend-sync, so listen and pusher need no roll for this step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ery deletes Co-Authored-By: Claude Opus 5.5 <[email protected]>
Same queries; the transaction now deletes only existing dream_due rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b45a66c5df
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| raw = os.getenv('DREAM_AGENT_PAID_PERCENT', '100').strip() | ||
| if not raw.isascii() or not raw.isdigit() or int(raw) > 100: |
There was a problem hiding this comment.
Restart discovery when widening the paid cohort
When the user collection exceeds one 20-page discovery scan, changing the rollout from 5% to 25% or 100% does not promptly add all newly eligible owners: paid_percent() reads the new value immediately, but dream_scheduler.discover() resumes from its persisted after cursor, so owners in pages already scanned at the lower percentage are not reconsidered until the entire collection wraps; any previous dream_due row for them is also deleted by the new ineligible-row branch. This can omit part of each intended ramp cohort for many hours or days and skew the rollout results, so reset/version the discovery cursor when the configured percentage changes or otherwise retain candidates that may enter on widening.
Useful? React with 👍 / 👎.
| and not uid.startswith('dream-canary-') | ||
| and eligibility() != 'invalid' | ||
| and (eligibility() != 'allowlist' or _allowlisted(uid)) | ||
| and (eligibility() != 'paid' or _paid_cohort(uid)) |
There was a problem hiding this comment.
Reject free bucket members before reserving capacity
When a non-paid owner hashes into the selected percentage and still has a dream_due row, such as after downgrading while queued, _paid_cohort() makes may_be_eligible() return true even though the authoritative eligible() check will reject the owner. Consequently run_pass() claims a reserved-capacity slot and executes the full dream_seed.load() history read before dream_store.acquire() checks the plan; that denial reschedules the due row instead of removing it, so subsequent sweeps repeat the expensive reads. Enough stale free-owner rows can fill the 5,000-owner candidate page and delay the actual paid cohort, so check authoritative paid eligibility and remove the row before claiming capacity or loading the seed.
Useful? React with 👍 / 👎.
| in_paid_ramp(uid) | ||
| and (user.get('subscription') or {}).get('plan', user.get('plan', '')) in PAID_PLAN_IDS |
There was a problem hiding this comment.
Apply the canonical subscription validity check
With production now using the paid policy, an expired account is admitted whenever its stored plan remains in PAID_PLAN_IDS, because this check ignores subscription status and current_period_end. The repository's canonical config.plan_catalog.resolve_subscription_entitlements() explicitly resolves a paid-plan row with a missing or elapsed period to basic, and resolves inactive rows to basic once their period closes; candidate_page() does not even project those fields. These churned accounts can therefore receive full Dream passes, consume reserved capacity, and contaminate the paid-owner ramp, so project the validity fields and use the canonical entitlement result rather than raw plan membership.
Useful? React with 👍 / 👎.
…s shadow env reads (M3 merge)
- backend/deploy/ops/{prod,staging}.yaml: DREAM_AGENT_PASSES_PER_DAY 6 -> 48 on
backend-sync-backfill, matching main's #23016 manifest change; test_config_train
requires the ops file and the prod manifest to agree.
- batch_stage_env_baseline.json: main's batch shadow reads (compute_client.shadow_from_env,
ShadowRunner.__init__), annotated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The Vertex reservation moved from gemini-2.5-flash to gemini-3.8-flash at about 2026-10-20 23:00Z. Vertex
online_servingmetrics show:Since then the 3.8 reservation has served only our reservation probes, about 7–10 calls an hour. Dream's real passes for the allowlisted owner ran on paid on-demand 3.8 instead, about 4–6M tokens an hour between 00:00Z and 05:00Z. The reservation's own probe state flipped 2.5 to
inactive (exclusive_order_moved)at 01:11Z, and dedicated 3.8 probes return 200.This change puts Dream on the reservation and starts a ramp to paid owners. David approved the ramp on 2026-10-21.
DREAM_ON_DEMAND_ENABLED=falseon prod backend, backend-sync, backfill and integration. Passes run on backend-sync's hourly sweep, so every pass now takes the reserved path, which is gated on the reservation probe and headroom (DREAM_DEDICATED_UTILIZATION_LIMIT, default 0.7). When the reservation is full, Dream waits. The gateway flag is untouched; with no on-demand requests arriving, it doesn't matter.allowlist, so this PR needs no listen roll to take effect. TheirDREAM_ON_DEMAND_ENABLEDis also set to false here. The backend-listen image mounts the manual-run route, so this closes the last on-demand path on their next roll. The cost: live-capture writes enqueue only the listed owner. Other ramp owners enter through discovery and backend/backend-sync writes. Moving listen and pusher topaidgoes in a later listen roll, before step 3 of the ramp.DREAM_AGENT_PASSES_PER_DAYgoes from 6 to 48 on backend, backend-sync and backfill. backend/deploy: cap Dream at 6 passes/day until the reservation switch #22066 cut it to 6 while we waited for the reservation switch.DREAM_AGENT_PAID_PERCENT. UnderDREAM_AGENT_ELIGIBILITY=paid, an owner is eligible when they are on a paid plan and their stable bucket,sha256('dream-agent-paid:'+uid) % 100, is below the percent.DREAM_AGENT_UID_ALLOWLIST) stay eligible at any percent. They are checked against the cached member list, never with a per-owner Firestore read.allowlisttopaidat 5%. Auto-apply stays limited to title, overview and vocabulary.Ramp plan
dream_capacity_decisionprobe_failedstorm; 3.8 dedicated utilization stays under the 0.7 headroom limit (waits are expected and fine); no 2.5/3.8 on-demand Dream spendDREAM_AGENT_UNDO_RATE(0.2)DREAM_AGENT_PAID_PERCENTunset)Target: 100% of paid owners by 2026-10-22 12:00Z. Rollback is
DREAM_AGENT_PAID_PERCENT=0, which leaves only the listed owner. The kill switch is the existingdream_control/globaldocument orDREAM_AGENT_ENABLED=false.Review
GLM-5.3 (zcode) reviewed this and returned SHIP-WITH-NITS. Follow-ups:
dream_duefor every ineligible scanned row. Underpaidthat is about 10k no-op deletes per sweep. It now deletes only rows that exist.GLM verified that
allowlistbehaviour is unchanged, that a malformed percent fails closed, that widening only adds owners, and that the paid branch adds no per-owner read. It also traced the reserved-only path across admission, capacity, transport and gateway.Verification
backend/test.shwithBACKEND_UNIT_TEST_FILE_LIST, undernice -n 19 taskpolicy -bwith 2 workers:backend/deploy/runtime_env.yamlwas regenerated withcompose_runtime_env.py.scripts/check_feature_flag_registry.pyreports OK, and the registry doc was re-rendered.dream_capacity_decisionreasons switch fromallowlisted_on_demandtofresh_reservation_saturation_clear;dedicatedinvocations and consumed throughput rise above the probe floor;sharedstays at 0.Product invariants affected
Matched only because
backend/deploy/runtime_env.yamlchanged. The change touches Dream eligibility, capacity and cadence values; memory intake and promotion paths are unchanged.Failure class
Failure-Class: none
🤖 Generated with Claude Code