Skip to content

feat(dream): add full-context consensus and segment citations (rung 1.2) - #21410

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

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

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Full-context Dream previously accepted each single model plan, so transcript rewrites could survive despite differing between replays. Full mode now runs independent copies of the same reasoning call concurrently and keeps proposals with a strict majority among returned samples (N // 2 + 1). DREAM_AGENT_FULL_SAMPLES defaults to 3 and is bounded to 1–8. Two of three, both of two, or the only surviving sample suffice. Duplicate items within a sample count once. Edits match on kind/target plus NFKC and whitespace-normalized before/after, preserving case so capitalization corrections keep their direction. Questions match on exact source ref/quote; vocabulary matches on kind/spelling; remaining typed items match on complete payload. Schema array caps and existing guards still apply after voting. consensus_rejected counts distinct minority proposals; sample counts and threshold are counts-only metrics.

Every sample uses dedicated reserved Gemini capacity. The internal request policy disables Luna and cross-route recovery for full samples, while bounded requests keep their current behavior. Sample errors are isolated; surviving samples form the plan. Known tokens, each sample's existing one JSON retry, and unknown outcomes are combined without sharing mutable usage trackers. Cancellation retains known usage and unknown billing state. No regex or heuristic guard is added, and no pay-as-you-go Gemini route is introduced.

Evidence/source citations accept a supplied base record followed by #segment-id, exact #start-seconds, or #HH:MM:SS. The base ref authorizes access, and the original fragment remains in proposals. Fragment quotes and independent spelling grounding inspect only the named transcript segment; missing/ambiguous fragments never broaden to the entire record. Proposal snapshots and current-record fences use base refs. Typed task provenance keeps segment IDs and start/end coordinates.

The Edit schema and full prompt explicitly define spelling as a misheard/misspelled name or term, never grammar rewriting, filler removal, or guessing unclear speech. Review IDs and timestamps are overwritten server-side during parsing and at enqueue. IDs retain the Review kind prefix and stable per-user identity so answer dispatch and deduplication continue to work.

The authoritative backend/deploy/runtime_env/prod.overlay.yaml enables full, K=3, and the existing QA owner entry from DREAM_AGENT_UID_ALLOWLIST for prod cloud_run/backend-sync. The selected entry is identified as QA_OWNER_UID in the repository runbook; the allowlist already uses literal code configuration, and the full-mode subset uses that same mechanism. Other services/accounts retain bounded mode. The composed backend/deploy/runtime_env.yaml and flag registry are regenerated. Spelling stays in Review under the existing prod auto-apply kinds. This PR is the code configuration change; no deployment is performed by this work.

Admission reserves both potential requests for every sample: 2 * K * (400000 + 32768) tokens. K=3 reserves 2,596,608 tokens or $25.96608 at the existing conservative $0.00001/token rate. The prod backend-sync cap is raised to $250 with a one-line accounting-only budget-intent comment: 24 per-user hourly passes at $8.2 settled ($200) plus one ~$26 reservation of headroom. The other service retains $60. Current-code caveat: this branch and fresh main use a shared daily reservation ledger and release reservations only on refunds, so $250 currently admits at most nine full reservations before other spend; per-user settlement is needed for the intended 24-hour cadence. At 253k input, three unretried calls plus maximum completions use up to 857,304 tokens ($8.57304 at that upper-bound rate). Thinking remains 16,384 tokens within the 32,768 total output ceiling. Concurrent samples share the existing 480s model, 600s pass, 660s drain, and 690s HTTP bounds; they do not add serial model deadlines.

Validation:

  • Cap follow-up on 16a741e74ee3500c76e8a9021b7fba53798a7847: all 231 sweep/runtime-renderer/runtime-validator tests passed through backend/test.sh; all 38 preflight checks and normal push hooks passed; dev/prod runtime validators and overlay composition passed. The test pins backend-sync at $250 and the other service at $60.
  • Normal push hooks passed on 6e6e775d689d543ccd6fca49144592cb9c89855c, including all 38 manifest checks, runtime-env composition/validation, backend type checking, selected backend unit tests, source closure, OpenAPI/client compatibility and generator freshness. All hooks remained enabled.
  • make preflight: all 38 selected checks passed. PR metadata: all four checks passed.
  • All 34 affected backend suite files passed through backend/test.sh (964 tests). The final focused run passed 72 tests, including the added majority-union cap case, cancellation/partial usage, one-survivor majority, fragment verification/provenance, and real local manual HTTP endpoints at K=1 and K=3 with one admission/lease and retry accounting.
  • Backend type checking: zero errors; warnings remain.
  • Dev/prod runtime-env validators passed with workflow checks. Runtime overlay composition is current. OpenAPI was regenerated; Dart, TypeScript and Swift generators produce no client changes.
  • Tests use synthetic records and fake providers. No production customer reads/writes, live inference, or deployment. Real multi-sample quality, reserved-capacity throughput, and latency remain for the owner's replay after release.

Product invariants affected

  • INV-MEM-4: Dream memory proposals keep the existing canonical Review mutation and admission paths; consensus and citations do not introduce another Long-term promotion authority.

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, 3:27 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-13T15:51:08.086601Z 16a741e 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: 6e6e775d68

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


def item_key(field, item):
if field == 'edits':
return item.kind, item.target, normalized(item.before), normalized(item.after)

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 Include the merge counterpart in consensus keys

For merge_people and merge_memories, before and after are normally empty, so this key treats every merge sharing the same target as an identical proposal even when each sample chooses a different other record. With three samples proposing A+B, A+C, and A+D, the counter records three votes and retains the first arbitrary merge, falsely presenting it as majority consensus; if the resulting Review suggestion is accepted, the wrong records can be merged. Include item.other in the key for merge edits.

Useful? React with 👍 / 👎.

Comment on lines +57 to +60
identity = json.dumps([value.get('kind'), value.get('source_ref'), value.get('quote')], ensure_ascii=False)
return {
**value,
'item_id': str(value.get('kind', 'question')) + ':' + str(uuid5(NAMESPACE_URL, identity)),

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 the proposed spelling in review-item identity

The replacement identity uses only kind, source ref, and quote, so two spelling questions for the same misspelled text but different proposed corrections now receive the same item_id. This overrides the existing hash in spelling_question, which deliberately includes edit.after; once the first card is resolved, enqueue_review_proposal treats a later alternative correction as already_suggested, preventing the user from ever reviewing it. Include the matching typed payload—or at least the spelling options/term ID—in the server-generated identity.

Useful? React with 👍 / 👎.

edits = edits[:25]
slow_tasks = [task for task in plan.slow_tasks if all(ref in records for ref in task.evidence)]
frames = [frame for frame in plan.frames if frame.screen_ref in records]
slow_tasks = [task for task in plan.slow_tasks if all(has_ref(ref, records) for ref in task.evidence)]

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 unresolved fragments before executing slow tasks

In full mode, this filter accepts any SlowTask citation whose base record exists, even when its #segment-id or timestamp is missing or ambiguous. propose_task subsequently resolves the fragment and raises ValueError when it cannot find exactly one segment, but the slow-task effect loop does not isolate that exception, so one malformed model citation fails the entire pass after inference and potentially after earlier effects were applied. Resolve fragment-bearing refs here and drop invalid tasks before reaching the effect phase.

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: 16a741e74e

ℹ️ 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 +19 to +22
if field == 'questions':
return item.source_ref, item.quote
if field == 'vocabulary':
return item.kind, item.spelling

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 Include decision-bearing fields in consensus keys

When two returned samples use the same source/quote for different question payloads, or propose the same vocabulary spelling with different aliases, these reduced keys combine them into majority votes and retain whichever full object appeared first. For example, one spelling question and one same-person question plus an empty third sample produce a “consensus” question, while conflicting vocabulary aliases can be auto-applied arbitrarily. Build the key from the complete decision-bearing payload, excluding only server-generated fields such as item_id and created_at.

Useful? React with 👍 / 👎.

Comment on lines 295 to 298
reason = (
'invalid_evidence'
if full and any(ref not in records for ref in term.evidence)
if full and any(not has_ref(ref, records) for ref in term.evidence)
else vocabulary_rejection(term)

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 unresolved fragments in vocabulary evidence

When a term cites an existing record with a missing or ambiguous fragment such as conversations/x#missing, has_ref checks only conversations/x, so the term passes this guard. In the production configuration vocabulary is auto-applied, and apply_vocabulary receives no records with which to resolve the fragment, allowing unsupported vocabulary to affect future processing despite the exact-fragment contract. Resolve fragment-bearing references with cited_value here and reject them unless exactly one segment matches.

Useful? React with 👍 / 👎.

Comment on lines 780 to +784
# 2026-10-09: hourly dogfood + manual runs; reserve room for both users and canary.
DREAM_AGENT_PASSES_PER_DAY: {value: '24', category: rollout}
DREAM_AGENT_MANUAL_RUNS_PER_DAY: {value: '20', category: rollout}
DREAM_AGENT_DAILY_USD: {value: '60', category: rollout}
# Reserved-capacity accounting-only budget intent: 24 per-user hourly K=3 passes (~$200 settled) plus ~$26 reservation headroom.
DREAM_AGENT_DAILY_USD: {value: '250', category: rollout}

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 Align the shared Dream budget across writer services

The backend-sync scheduler now admits K=3 passes against a $250 cap, but backend still handles Run Now with a $60 cap, while both use the same global dream_spend/{day}.reserved_usd counter in dream_store.acquire. Each successful full pass retains about $25.97 of reservation, so after the third scheduled pass the shared counter exceeds $60 and every subsequent manual run on backend is rejected as dream_budget_unavailable despite the configured allowance of 20 manual runs; spend from other users can trigger this even earlier. Use a consistent cap across these services or partition the ledger by the intended budget scope.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit b1d7951 into main Oct 13, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/dream-fullctx-3 branch October 13, 2026 15:58
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