Repository navigation
fix(dream): sequence full samples and honor segment targets - #21423
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
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. |
There was a problem hiding this comment.
💡 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".
| 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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 👍 / 👎.
| 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')] |
There was a problem hiding this comment.
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 👍 / 👎.
| 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') |
There was a problem hiding this comment.
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 👍 / 👎.
Failure-Class: FC-per-hop-timeout
There was a problem hiding this comment.
💡 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".
| if deadline - clock() < FULL_MODEL_SECONDS: | ||
| break |
There was a problem hiding this comment.
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 👍 / 👎.
| if '#' in edit.target and segment != selected_segment: | ||
| continue |
There was a problem hiding this comment.
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 👍 / 👎.
| inspected = {item['collection'] + '/' + item['id'] for item in [*consumed, *unavailable]} | ||
| seeded.update(set(records) - inspected) # Retrieval-only refs have no inspected dirty version. |
There was a problem hiding this comment.
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 👍 / 👎.
| edit.kind == 'spelling' | ||
| and '#' in edit.target | ||
| and not verbatim_quote(edit.before, cited_value(edit.target, records)) | ||
| ): |
There was a problem hiding this comment.
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 👍 / 👎.
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.
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.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:
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.