Repository navigation
Dream: retry short destructive-gate contention at apply instead of discarding the pass - #21966
Conversation
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: ff1ed1526f
ℹ️ 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 isinstance(exc, TimeoutError) and gate_retry_in_progress: | ||
| exc = ValueError('dream_gate_contention') |
There was a problem hiding this comment.
Preserve executor timeout lease fencing during retries
If the overall pass deadline expires while a retried run_blocking effect is still executing, gate_retry_in_progress is still true, so this rewrites the cancellation from TimeoutError to ValueError('dream_gate_contention'). run_pass consequently calls dream_store.finish(..., release=True) and releases the capacity slot, whereas ordinary executor timeouts deliberately retain both because cancelling run_in_executor does not stop the worker. A slow two-phase memory effect can therefore continue after its lease has been cleared and a new pass has been admitted; only convert timeouts known to occur during the backoff sleep, or otherwise preserve the timeout/release semantics while an executor attempt is outstanding.
AGENTS.md reference: backend/AGENTS.md:L125-L125
Useful? React with 👍 / 👎.
| raise ValueError('agent_user_memory_requires_review') | ||
| validate_edit(edit, records, authority=authority) | ||
| if authority == 'dream' and gate_retry: | ||
| key = edit_key(edit, records) |
There was a problem hiding this comment.
Resume person merges after pre-journal bootstrap writes
When a merge_people edit targets legacy people whose knowledge_nodes are absent, merge_review_entities first creates those nodes in ensure_nodes and only afterward enters the gate-protected journal transaction. If that later transaction raises the retryable contention, no review_changes journal exists, so this retry path falls through; the second attempt then compares the original None node fences against the nodes created by the first attempt and returns invalid_evidence instead of completing the verified merge. The retry needs to make the bootstrap write atomic with the journal or explicitly recognize and resume nodes created by the failed attempt.
Useful? React with 👍 / 👎.
| and change.get('undone', False) is False | ||
| ): | ||
| return 'applied' | ||
| refs = {base_ref(ref) for ref in [edit.target, *edit.evidence, *([edit.other] if edit.other else [])]} |
There was a problem hiding this comment.
Resume post-commit transcript projection work
If a transcript correction commits and a retryable destructive gate starts before sync_transcript_chunks reaches its fenced Pinecone upsert, the chunk deletion has already run and the upsert raises DestructiveOperationInProgress. On retry, this early return sees the committed journal and reports applied without rerunning sync_transcript_chunks, leaving that conversation's transcript vectors deleted while the pass is recorded as successful. A committed-journal retry must resume the idempotent post-commit projection work rather than returning immediately.
AGENTS.md reference: backend/AGENTS.md:L125-L125
Useful? React with 👍 / 👎.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The 2026-10-17 02:00Z Dream pass on the allowlisted owner ran 40 turns ($0.69), verified its findings, and then failed at apply with
DestructiveOperationInProgress, so nothing was applied (error_type=other). The account-wide gate (legal_hold_deletion_gates/{uid}) was held by anexplicit_memory_deletionoperation for a short window. Conversation reprocessing takes that gate every few minutes while sync backfill drains.explicit_memory_deletion,retention_cleanup,audio_conversation_deletion).dream_gate_contention_retry_allowedinlegal_holds.py, does two point reads; it is called only by Dream, and a failed read means no retry.dream_gate_contentionand releases the lease, instead oferror_type=other.apply_verified_editjournal written during this pass's lease counts asapplied, so an ambiguous commit is not applied twice. First attempts and journals from earlier passes still go through full revalidation.Product invariants
Verification
tests/unit/test_dream_harness_runtime.py, 21 tests viabackend/test.sh:dream_gate_contention;invalid_evidence).Failure-Class: none
🤖 Generated with Claude Code