Skip to content

fix(dream): sequence full samples and honor segment targets - #21423

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/dream-fullctx-5
Oct 13, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/dream-fullctx-5

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Full Dream samples currently burst the reserved route, and a settlement fault replaces the real full-pass diagnostics with a generic zeroed failure report. Rung 1.3 runs the same independent samples sequentially and accepts precise transcript fragments on edit targets.

  • Each sample retries a capacity rejection once after the existing 120-second cooldown, only if another full 480-second model window fits the shared pass deadline. Shared/local cooldown state is rechecked. Majority is computed over returned plans; capacity-rejected samples never increment the dirty-record failure circuit. A capacity retry carries any known billed malformed-response usage into the same sample token budget. No PAYG route or new inference provider is added.
  • Default K remains 3. Full pass: 1620s, drain/manual outer/slot fence: 1680s, HTTP middleware: 1710s, production sweep Scheduler attempt deadline in backend/deploy/scheduler/jobs.yaml: 1740s. This allows three 480s windows, one 120s cooldown and 60s for effects; observed 200–265s calls leave room for more retries. Extra samples/retries use survivors if another complete window cannot fit. The Scheduler bound stays below 1800s. Bounded and canary deadlines stay unchanged.
  • Read-only managed service-account metadata on 2026-10-14 confirms prod backend-sync Cloud Run timeout 3600s, sufficient for 1710s. No live service settings or rollout flags were changed. Dev's previously recorded 300s requires an operator change before full-mode HTTP enablement.
  • Fake-turn reproduction: K=3, two CapacityWait samples and one plan succeed with a simple plan; when the survivor defers a retrieval-only context ref after 32 dirty inspection slots are filled, finish raises dream_settlement_limit. Retrieval-only refs now use review metadata without adding an uninspected dirty key. Acquire/settlement failures retain the real mode/counts, and the pass line includes only exact allowlisted internal dream_* ValueError codes. The old production logs did not include a code proving this was that live pass's exact trigger.
  • Fragment target authorization/document reads use the base ref. A spelling fragment must resolve uniquely and contain the wrong term, and replacement touches only that segment. Other segments, titles and summaries stay unchanged. The encoded before/after transcript is journaled for Undo; the fragment stays on the change label and equivalent ID/time selectors share suppression. Evidence remains fragment-aware, and another segment of the same conversation cannot independently ground an automatic correction.

Context caching investigation: Google's Provisioned Throughput guide supports implicit/explicit caching in Preview and applies the input discount through reduced reservation burndown. The model table lists 0.1 cached-input burndown for the declared Gemini 3.8 Flash model. Our reserved adapter has no cachedContent forwarding or cache create/delete lifecycle. A private per-pass cache needs tenant isolation, model/location binding across reserved recovery, expiration/deletion and accounting; it is not a small toggle. No explicit caching is built and no cache hit is assumed.

CI follow-up: the deadline regression allowed only 10ms of real-clock input preparation before its first 480s sample window. Under CI load it skipped every sample and correctly raised CapacityWait. The regression now uses an injected monotonic clock shared by plan/retry deadline checks, fresh local capacity state per test, an explicit saturated-state assertion and exact boundary coverage. Production still defaults to the event-loop monotonic clock. The combined run also exposed module-scope authentication mutation in a shard-6 neighbour and random history cleanup in a retrieval fixture; those tests now use app-local dependency overrides and an explicitly cleanup-free lease.

Validation:

  • Follow-up: all 30 test_dream_* files plus the three non-Dream shard-6 neighbours on either side (36 files, 790 passed, 1 integration deselected) passed in one pytest process through backend/test.sh, with file isolation and xdist disabled. The same set also passed in reverse file order. Neighbours: test_dev_goals_limit_include_inactive, test_developer_from_segments_idempotency, test_dg_start_guard, test_durable_queue, test_encryption_key_cache and test_episode_claim_read_validation. The changed HTTP neighbour also passed alone (61 tests).
  • All 33 affected Dream, timeout, Scheduler and reserved-schema unit suites passed through backend/test.sh: 746 tests, including the local HTTP reserved schema-translation proof.
  • 15 integration tests passed through backend/test.sh against an isolated loopback Firestore emulator, anonymous credentials and synthetic demo project. Segment replacement, encrypted journal, real Undo and equivalent-selector suppression all passed. Emulator stopped afterward.
  • Canonical app-client OpenAPI export refreshed for the one changed target description; compatibility and export checks passed.
  • Backend typecheck: zero errors; warnings remain. Required make preflight passed; final push-time repository preflight passed all 31 selected checks. All four PR metadata checks and all normal pre-push hooks passed.
  • No production customer data, credentials in code/PR text, live inference or deployment. A random cleanup path in an existing synthetic retrieval fixture is now explicitly disabled; intentional cleanup tests retain their own seams.

Product invariants affected

none

Failure-Class: FC-per-hop-timeout

The request-wide monotonic deadline is shared across sequential samples and capacity retries; an additional model call must fit its remaining budget. Behavioral guards are in test_dream_consensus.py, test_dream_queue.py, test_dream_tools.py and the real Dream emulator suite.

View guided diff Turn on auto-fix

@mintlify

mintlify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Oct 13, 2026, 5:57 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T18:35:57.148131Z e4c34ff New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3dee687e2d

ℹ️ 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".

Comment on lines +142 to +143
accounts on 2026-10-13 (prod reconfirmed 2026-10-14): `backend-sync` in `us-central1` is 31620 seconds in prod
and 300 seconds in dev. Prod covers the required 1710 seconds; dev does not.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct the production Cloud Run timeout

The runbook now reports the production backend-sync timeout as 31,620 seconds, contradicting both the commit's stated 3,600-second value and this same runbook's later “prod is 3600” guidance. Operators using this section to validate the new 1,710-second request bound would therefore be working from incorrect capacity metadata; restore the verified 3,600-second value.

Useful? React with 👍 / 👎.

otherwise propose a Review spelling question with a custom answer. Proposed vocabulary is not grounding.
Every Review question needs a source_ref and an exact verbatim quote from that supplied record.
Citations may include #segment-id or #start-seconds. A quote with a fragment must occur in that exact segment.
Targets and evidence citations may include #segment-id or #start-seconds. One spelling edit fixes every occurrence in its target; a target fragment restricts replacement to that segment. A quote with a fragment must occur in that exact segment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize fragment aliases before consensus voting

Allowing both segment IDs and start times means independent samples can express the same correction as conversations/c1#s1 and conversations/c1#12.5. However, dream_consensus.item_key() still votes on the raw item.target or source_ref, so these semantically identical edits or questions receive separate votes and can be discarded for failing the majority threshold. Canonicalize resolved fragments before voting, as edit_key() already does for suppression, or require one selector format.

Useful? React with 👍 / 👎.

Comment on lines +34 to +38
target_key: Any = edit.target
if records and edit.kind == 'spelling' and '#' in edit.target:
segment = cited_value(edit.target, records)
if segment is not None:
target_key = [base_ref(edit.target), segment.get('id') or segment.get('segment_id') or segment.get('start')]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject fragments on record-wide edits

Fragment normalization is restricted to spelling keys, while the new schema and base-ref validation also accept fragments on title, overview, merge, task, and entity edits. For example, after a user undoes an auto-applied title edit targeting conversations/c1#s1, the same title targeting conversations/c1#12.5 gets a different raw edit_key and bypasses the durable do-not-redo fence even though both operations modify the same whole-record field. Either reject fragments for non-spelling targets or canonicalize their keys to the base record.

Useful? React with 👍 / 👎.

Comment on lines 178 to +180
if not plans:
raise next(result for result in results if isinstance(result, BaseException))
if any(isinstance(result, dream_transport.CapacityWait) for result in results) or not results:
raise dream_transport.CapacityWait('dream_capacity_wait')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not classify an exhausted pass as capacity rejection

When context retrieval leaves less than one 480-second model window before the request deadline, the loop exits before attempting any sample, leaving results empty. This branch then reports reserved_capacity, causing drain() to stop processing every remaining owner even though capacity was never checked or rejected; a slow retrieval (or any shortened full-pass timeout) can therefore halt the sweep under a false capacity signal. Treat the empty-results case as a deadline/budget failure rather than CapacityWait.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4c34ffdf0

ℹ️ 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".

Comment on lines +137 to +138
if deadline - clock() < FULL_MODEL_SECONDS:
break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reserve effect time before starting another sample

When retrieval, earlier samples, and a cooldown leave between 480 and 539 seconds, this check still starts another request that may consume the entire remaining 480-second model window. That defeats the documented 60-second effect headroom: a successful response can arrive too late for edits and dream_store.finish, so the outer pass times out after incurring model cost and leaves the dirty work unsettled. Require FULL_MODEL_SECONDS plus the effect margin here, or pass planning a deadline already reduced by that margin.

Useful? React with 👍 / 👎.

Comment on lines +313 to +314
if '#' in edit.target and segment != selected_segment:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Coalesce fragment edits for the same conversation

When a plan contains grounded spelling fixes for two different fragments of the same conversation, the first edit writes a new transcript, but the second edit is still fenced against the original records snapshot and is rejected as changed evidence. The pass nevertheless completes and acknowledges the dirty version, so the second correction is lost rather than retried. Group same-conversation fragment replacements into one journaled patch, or refresh the fenced snapshot after each successful write.

Useful? React with 👍 / 👎.

Comment on lines +474 to +475
inspected = {item['collection'] + '/' + item['id'] for item in [*consumed, *unavailable]}
seeded.update(set(records) - inspected) # Retrieval-only refs have no inspected dirty version.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve deferral for unseen dirty context records

When a retrieved context record also has a dirty entry beyond the 32-row inspection window, it is absent from inspected, so this line classifies it as seeded. If an edit is deferred because the suggestion cap is exhausted, settlement then writes only the review-metadata deferral because seeded refs are excluded from deferred_ids; however, dirty admission checks deferred_until only on the dirty document. Once the preceding rows are acknowledged, this record is therefore admitted again the same day and can repeatedly purchase model passes despite being deferred. Distinguish confirmed seeds from uninspected context or make dirty admission honor the review deferral.

Useful? React with 👍 / 👎.

Comment on lines +127 to +130
edit.kind == 'spelling'
and '#' in edit.target
and not verbatim_quote(edit.before, cited_value(edit.target, records))
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate fragment spelling against transcript text

For a fragment target, cited_value returns the entire segment dictionary and verbatim_quote recursively searches every field, so an edit is accepted when before appears only in metadata such as the segment ID or speaker label rather than in segment.text. Application then replaces nothing, produces an empty patch that record_agent_change rejects, and the completed pass can still acknowledge the dirty record, losing the proposed correction. Check the selected segment's text field specifically before admitting a fragment spelling edit.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 1f511de into main Oct 13, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dream-fullctx-5 branch October 13, 2026 18:38
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