Repository navigation
fix(gateway): preserve targetless media session ownership - #124111
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 4:45 AM ET / 08:45 UTC. ClawSweeper reviewWhat this changesThe PR carries the agent and session-store ownership resolved during Gateway restart recovery into generated-media transcript persistence, preventing targetless Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the patch is a focused owner-boundary repair and no blocking correctness finding was identified. It remains maintainer-owned and should wait for its exact-head merge/CI state before landing. Priority: P2 Review scores
Verification
How this fits togetherGateway restart recovery loads queued session work and resolves its canonical key, owning agent, and store before resuming generated-media delivery. That delivery records recovered attachments in the owning session transcript. flowchart LR
A[Queued media delivery] --> B[Restart recovery]
B --> C[Resolve session owner]
C --> D[Generated media delivery]
D --> E[Transcript persistence]
E --> F[Owning agent transcript]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +90. Total +91 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep a single resolved owner tuple from restart-session loading through transcript persistence, retain the two-store Do we have a high-confidence way to reproduce the issue? Yes in source: two agents with separate stores can share a targetless Is this the best way to solve the issue? Yes. Propagating the owner tuple already chosen by restart recovery is narrower and safer than asking transcript persistence to infer ownership again from an ambiguous key. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5d601233df88. LabelsLabel changes:
Label 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
|
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where an internally generated attachment recovered after a Gateway restart could be persisted through the wrong agent/session store when the durable delivery used a targetless
globalsession key. Two agents can legally have the same literal key in separate stores, so re-deriving ownership from the key can misroute or lose the transcript attachment.Why This Change Was Made
The restart sentinel already resolves the authoritative
agentId, canonical key, and store path together when it loads the queued session. This change carries those resolved facts into generated-media transcript persistence and removes the later redundant agent re-resolution. It does not change delivery/replay behavior, routing, config, protocol, schema, retention, or security policy.Production code is net +1 line: the new owner arguments are absorbed by deleting the redundant resolver path. Tests are net +90 lines. No changelog entry is needed because this is internal restart-recovery correctness with no public surface change.
User Impact
Targetless generated media recovered after restart now appears exactly once in the resolved owning agent's transcript. Another agent with the same
globalkey remains untouched.Evidence
pnpm buildpassed against the synchronized three-file source hashes.src/gateway/server-restart-sentinel.test.ts.globalkey. The non-mainopsowner received one stable attachment event; themaindecoy received zero. The 68-byte attachment hash was4b5c5c92cec3b23e6a294fc0eea43234ef5126c5a64f4c6c531ac8430ab0b844.completed_permanentwith retry count 0, no pending or failed rows, and no defer/advance/dead-letter metadata. A second Gateway start preserved the same event ID without duplication; both processes exited 0 and state/port cleanup passed.