Repository navigation
fix(outbound): a delivery mirrored into another session is silently dropped - #134083
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 7:58 AM ET / 11:58 UTC. ClawSweeper reviewWhat this changesThe PR scopes transcript writer fences to the session receiving each outbound mirror so cross-session deliveries are recorded instead of being rejected as rebound writes. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: this is a source-proven P1 repair for silent transcript-state loss, and current main still has the unscoped fence reads. The patch scopes the sender’s writer claim to the destination session without weakening the full-target commit guard. Priority: P1 Review scores
Verification
How this fits togetherOutbound delivery sends a payload through a channel and then records it in the destination session transcript. Writer fences protect active session writes, so a mirror must not pass a sending run’s fence to a different destination session. flowchart LR
A[Agent run] --> B[Outbound delivery]
B --> C[Channel send]
B --> D[Transcript mirror]
D --> E[Destination session]
E --> F[Writer fence check]
F --> G[Transcript event]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +39, Tests +176. Total +215 across 7 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the destination-key-scoped fence lookup after exact-head checks complete; it preserves same-session fencing and prevents foreign-session fence inheritance without adding another delivery path. Do we have a high-confidence way to reproduce the issue? Yes. The supplied real-store before/after trace reproduces the cross-session drop, and fetched main retains the same unscoped lookup and Is this the best way to solve the issue? Yes. The repair corrects the fence lookup at the ownership boundary while retaining strict full-target matching where callers can express a target. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 43e9a3d81776. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…into Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
c5e55d8 to
1f34a7c
Compare
|
Maintainer adoption verification for
VACInc assignment is verified on this PR, canonical issue #132766, and predecessor issue #125885. PR #132852 is the incomplete duplicate; #134498 is a separate post-send rebound race with its own durable-recovery product decision. No merge or automerge action was taken. |
|
Merged via squash.
|
…into (openclaw#134083) Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
Closes #132766
What Problem This Solves
A message the user has already received can be missing from the transcript of the session it was delivered into. When a run in one session delivers an outbound payload addressed to another session, the mirror that records it in the receiving session's transcript is refused, the refusal is logged at
warnafter the channel send has already succeeded, and it is never retried. The user sees the message; the receiving session never learns it happened, and every later turn in that session answers from a history that is missing it.Nothing surfaces this. There is no error, no retry, and no counter — the reporter of #132766 found it only by auditing mirror counts against their gateway journal, where it had been happening for four days across five session keys and three agents, on one channel for 8 of 8 deliveries.
The same drop sits on five delivery paths, not one: the generic outbound mirror, the plugin-handled send mirror, the source-reply mirror, and both of the gateway's internal source-reply persistence points.
Why This Change Was Made
Each of those paths asked for the current writer claim without saying which session it was about to write into, so it inherited whichever run happened to be executing. When that run belonged to a different session, the transcript guards correctly refused a claim that did not describe the target — which is why the symptom is a
session reboundrefusal rather than a corrupted write.Every one of the five now names the session it writes into. Naming it is only half the repair: the ownership test compares full targets, and a delivery mirror holds a session key but not that session's store path, so a key-only request could not be answered at all and would have been refused even when the run did own the session. The fence lookup now has its own ownership test that compares session keys when the caller cannot form a target and defers to the existing target comparison whenever it can. The shared
contextMatchesused by the initial-writer inheritance and the commit assertion is untouched, so those two paths keep their exact semantics.Boundaries. A same-session mirror still inherits the run's fence — the guard is scoped, not removed. The unscoped lookup still returns the ambient claim and is kept for the one caller that legitimately asks "which run is writing right now" rather than "may I write into this session". The issue's secondary ask — making the four
session reboundemit sites distinguishable in the log — is not addressed here; it is a change to a shared refusal string on a much hotter path and stands on its own.User Impact
A message delivered into another session is now recorded in that session's transcript instead of being silently dropped, so the receiving session answers from the history the user actually sees. Sessions that were quietly desynchronised stop drifting further apart. Nothing changes for a delivery into the running session's own transcript, and nothing changes about when a channel send succeeds or fails.
Evidence
Behavior addressed: an outbound payload mirrored into a session other than the delivering run's own is refused as
session rebound, logged atwarnafter a successful send, and lost permanently.Real environment tested: a real temporary state directory with the real SQLite session store, the real exported
mirrorDeliveredPayloads, and the realappendAssistantMessageToSessionTranscriptguards that issue the refusal. Only the channel send is absent; the defect is entirely in the mirror that runs after it. Node v24.18.0 on Windows 11.Exact steps or command run after this patch: create two real sessions in one store, give the delivering session an active writer run the way a live turn does, leave the receiving session unowned (the ordinary state of a session that is not mid-turn), then mirror one payload into each from inside the delivering run's transcript-write context.
Evidence after fix:
Observed result after fix: the cross-session mirror lands, and the same-session mirror is unchanged — the fence is scoped, not dropped. No
warnline is emitted.Before evidence: the identical script against the same commit with
src/config/sessions/transcript-write-context.tsandsrc/infra/outbound/deliver-transcript.tsreverted toorigin/main:That
warnline is the reporter's production line, verbatim down to the format. The same-session control passes on both sides, so the difference is the cross-session case alone.Additional review: the unit tests fail without the fix. Reverting only
src/infra/outbound/deliver-transcript.tstoorigin/mainand rerunningsrc/infra/outbound/deliver-transcript.writer-fence.test.tsfails withexpected { agentId: 'wolf', …(8) } to not have property "expectedWriterRunId"/Received "run-running"— the delivering run's claim, on a mirror into another session. Restoring the fix returns 3/3.src/config/sessions/transcript-write-context.test.tsadds four cases that pin both halves and the unchanged target path, and its ten pre-existing cases still pass (14/14).Checks run on the exact head:
tsgo -p tsconfig.core.jsonwith no diagnostics; the sharded core test-type lane, which caught aTS2493in the new test file on its first run — fixed by giving the mock its parameter type rather than adding a cast, which also let an existing assertion be deleted;lint:core;oxfmt --checkon all seven touched files;check:assertion-safety --base origin/mainandcheck:max-lines-ratchet --base origin/main, both OK;check:import-cycles, 0 cycles.What was not tested: no live gateway drove a real cross-session announce or handoff; the proof drives the same exported mirror entry point directly. The channel send itself is not exercised, which is deliberate — the send already succeeds in the reported failure.
Proof limitations or environment constraints: this host has three suites that fail before this change and fail identically with
src/config/sessions/transcript-write-context.ts,src/gateway/internal-source-reply-persistence.ts,src/infra/outbound/deliver-transcript.ts,src/infra/outbound/outbound-send-service.tsandsrc/infra/outbound/source-reply-mirror.tsreverted toorigin/main, so they are pre-existing here and not caused by this change:src/plugin-sdk/session-transcript-runtime.test.ts(21 failures, allEPERM ... syscall: 'rm'while removing a temp directory inafterEach; identical 21 failed / 3 passed on both sides),src/config/sessions/transcript.test.ts(suite-levelEPERMin the same cleanup shape, so all 65 tests are skipped and none actually runs), and one 120s timeout insrc/agents/tools/sessions.test.ts(sessions_send gating > keeps an exact-incarnation send synchronous to its scoped lifecycle grant, 120074ms on this branch versus 120064ms on reverted source). Everything else in the touched and neighbouring set passes.