Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 30, 2026, 9:57 AM ET / 13:57 UTC. ClawSweeper reviewWhat this changesThe branch passes each outbound mirror’s destination session key into the transcript writer-fence lookup and adds regression coverage for cross-session versus same-session behavior. Merge readiness⛔ Blocked until stronger real behavior proof is added - 4 items remain Keep open: current main still applies an ambient writer fence to outbound mirrors, while the branch scopes it to the destination and preserves same-session fencing. The code and focused regression coverage support the repair, but the external PR still lacks inspectable real after-fix behavior proof. Priority: P1 Review scores
Verification
How this fits togetherOutbound delivery sends a payload through a channel and then mirrors the delivered content into a session transcript. The transcript writer fence carries an admitted run’s concurrency claim only when that transcript destination is the admitted session. flowchart LR
A[Admitted run] --> B[Writer fence context]
C[Channel delivery] --> D[Outbound mirror]
D --> E[Destination session key]
B --> F{Destination matches admitted session?}
E --> F
F -->|yes| G[Claimed transcript append]
F -->|no| H[Unclaimed destination append]
G --> I[Session transcript]
H --> I
Before merge
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +160. Total +172 across 7 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the direct destination-key lookups and shared matcher, then demonstrate the cross-session destination append and same-session stale-writer rejection through the real transcript store. Do we have a high-confidence way to reproduce the issue? Yes: current main’s zero-argument lookup returns the ambient claim, and a mirror then supplies that claim while appending to its destination session. The supplied focused tests model the cross-session and same-session cases, though this review did not execute untrusted contributor code. Is this the best way to solve the issue? Yes: destination-scoped lookup at each independently owned mirror boundary, with the existing full-target matcher retained, is the narrowest coherent repair found. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1505218b3e42. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
…ination Outbound mirror writes fetched the ambient transcript writer fence with no destination scoping, and the ambient context carries the sending run's session target, so every session-key-only call failed the store-identity match and silently dropped the fence. Mirror appends then lost optimistic-concurrency protection against the owning writer. Match the fence to the mirror's destination session key instead, and let session-key-only callers resolve the ambient claim through the context's target session key. Co-Authored-By: Claude <[email protected]>
2d6c3f5 to
f612443
Compare
|
Superseded by #134083, merged to The landed repair covers all five destination-scoped writer-fence lookups, including the internal replay path, while keeping the shared full-target comparator strict. This PR leaves that replay lookup unscoped and changes broader matching semantics, so closing it as the incomplete duplicate. |
What Problem This Solves
mirrorDeliveredPayloadsand its three sibling mirror boundaries write a delivered payload into the destination session's transcript, but acquired their transcript writer fence by callinggetOwnedSessionTranscriptWriterFence()with no arguments.That function only runs its
contextMatchesgate when it was given parameters, so the zero-arg call skipped the gate and returned the ambient admitted run'sexpectedWriterRunId/expectedLifecycleRevision— a writer claim about the sending run's session, not the session receiving the mirror. The transcript guards then refused the append assession rebound, the refusal waswarn-only, and the channel send had already succeeded, so the mirror was never retried. The receiving session kept answering while having silently lost every mirrored delivery.Reported with 18 occurrences across 5 session keys and 3 agents in a real multi-agent gateway, including 8 of 8 deliveries on one channel across four consecutive days. A
sessions.reseton the target key (rotatinglifecycleRevision, clearingactiveWriterRunId) restored mirroring on the very next delivery, which is what isolated the mechanism.Why This Change Was Made
Two connected defects share one invariant: a transcript write may only inherit the admitted run's writer claim when the write's destination is that run's session.
src/infra/outbound/deliver-transcript.ts,src/infra/outbound/outbound-send-service.ts,src/infra/outbound/source-reply-mirror.ts, andsrc/gateway/internal-source-reply-persistence.ts(the fourth zero-arg call site, same invariant, found while reading the fence's consumers).contextMatchesrejected a session-key-only request outright whenever the ambient context carried asessionTarget: the branch condition wasparams.context.sessionTarget || params.sessionTarget, so a request without a target producedrequestedTarget === undefinedand returnedfalsefor every destination, including the correct one. Fixing only (1) would have stripped the fence from same-session mirrors too.The fix names the destination session at all four boundaries and teaches the gate to match session-key-only requests against the owning run's session identity. Callers that pass a full
sessionTargetstill require the exact store identity (sessionKey+storePath), so the SQLite write scopes (withOwnedSessionTranscriptWriterFenceat the four sync write sites andrunWithOwnedSessionTranscriptWriteat the turn boundaries) are byte-for-byte unaffected.User Impact
Cross-session outbound mirrors (announce/handoff from another session,
messagesends into another session key) now land in the destination session's transcript instead of being silently discarded. Same-session mirrors keep their writer-claim protection, so a concurrent writer change is still detected. No config, default, or operator action changes.Evidence
Reproduction and regression tests (pre-fix failure confirmed by running before the fix):
src/infra/outbound/deliver-transcript.test.ts— drives the realmirrorDeliveredPayloadsunder an ambient admitted-run context for session A while mirroring into session B. Pre-fix, the append receivedexpectedWriterRunId: "run-agent:main:discord:c:1"(session A's claim) for a write into session B. Post-fix it receives no claim. The companion case pins that a mirror into the run's own session still forwardsexpectedWriterRunIdandexpectedLifecycleRevision, guarding against over-correction.src/config/sessions/transcript-write-context.test.ts— pins the gate invariant: session-key-only requests match the owning session, reject a different destination, and full-target requests still require an exact store-identity match. The third case failed before the gate change for the owning session too, which is why the gate relaxation is part of this fix rather than an optional extra.Sibling coverage (no regression):
node scripts/run-vitest.mjs run src/infra/outbound/— 100 files, 1653 tests passed. Coversmessage-action-runner, which is the sole consumer ofpersistInternalSourceReply.node scripts/run-vitest.mjs run src/config/sessions/session-accessor.conformance.test.ts src/config/sessions/transcript.test.ts— 111 tests passed.node scripts/run-vitest.mjs run src/agents/tools/sessions.test.ts— 95 tests passed.node scripts/run-vitest.mjs run src/infra/heartbeat-wake.transcript-context.test.ts— passed (ambient-context isolation).node scripts/run-tsgo.mjs -p tsconfig.core.jsonclean;oxlintandoxfmt --checkclean on all touched files.Production diff: 5 files, +18/−6. The growth is the destination identity threaded into four independent mirror boundaries plus the gate's session-identity branch and its invariant comment; there is no wrapper or helper that absorbs it, and deleting the same-session fence (the only way to reach net zero) would remove real writer-claim protection.
Rebase onto current main (2026-08-30)
main(b4f8510) has since introduced the initial-writer lease (InitialSessionTranscriptWriter+assertCommitAllowed) as the custody mechanism around these same boundaries. This branch was rewritten onto that baseline as a single commit (f612443); the CONFLICTING state is resolved.persistInternalSourceReplynow sits insidemain's media-cleanuptry/finally; the read-side zero-arg fence lookup at the replay/idempotency probe is intentionally untouched, matching the original scope.AssertionError: expected undefined to deeply equal { …(2) }— with the old gate, the owning session key resolves no claim whenever the ambient context carries a session target (1 failed | 12 passed; post-fix 13 passed). This pins why the gate relaxation is part of the fix rather than an optional extra.transcript-write-context.test.ts13 passed,internal-source-reply-persistence.test.ts47 passed,source-reply-mirror.test.ts10 passed,outbound-send-service+message-action-send.mirror-orderpassed,deliver-transcript.test.ts2 passed.oxlintclean on all touched files.