gateway: support user-role chat.inject with idempotent replays#81513
gateway: support user-role chat.inject with idempotent replays#81513aaronclawrsl-bot wants to merge 2 commits into
Conversation
|
Codex review: found issues before merge. Reviewed July 3, 2026, 11:51 PM ET / 03:51 UTC. Summary PR surface: Source +43, Tests +270, Other +8. Total +321 across 7 files. Reproducibility: yes. Source inspection shows current main and Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a refreshed current-main implementation that adds user-role replay and stable idempotency through Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main and Is this the best way to solve the issue? No, not as submitted. The direction is plausible, but the best fix must be rebased or replaced to use the current protocol package and preserve routing, metadata, and idempotency invariants. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e. Label changesLabel justifications:
Evidence reviewedPR surface: Source +43, Tests +270, Other +8. Total +321 across 7 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
0d8ea32 to
493ba69
Compare
61c155f to
e23244a
Compare
e23244a to
5e97965
Compare
5e97965 to
cd2b5da
Compare
cd2b5da to
09ec74e
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: gateway: support user-role chat.inject with idempotent replays This is item 1/1 in the current shard. Shard 8/22. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Summary
chat.injectparams with optionalrole(assistant|user) andidempotencyKeychat.injectreplays return{ ok: true, deduped: true }instead of failingWhy
Telegram relay hooks need a first-class Gateway RPC to append user-role messages into a session transcript without triggering a model run.
Notes
chat.injectcalls withoutroleremain assistant injectionschat.injectauthorization)Real behavior proof
chat.injectmust support user-role transcript append and idempotent replay should not fail.~/.openclaw/agents/*/sessions/*.jsonl.openclaw gateway call chat.inject --json --timeout 30000 --params '{"sessionKey":"agent:druck:telegram:group:-1003846579956:topic:1","role":"user","message":"REAL_PROOF_ROLE_USER_2026-05-13","idempotencyKey":"real-proof-user-20260513-c"}'idempotencyKey.rg -n 'real-proof-user-20260513-c|REAL_PROOF_ROLE_USER_2026-05-13' /home/aaron/.openclaw/agents/druck/sessions/d0b805cb-c944-4079-9351-3d9b620a76d2-topic-1.jsonl && rg -c 'real-proof-user-20260513-c' /home/aaron/.openclaw/agents/druck/sessions/d0b805cb-c944-4079-9351-3d9b620a76d2-topic-1.jsonlidempotencyKeyreturns deduped success; transcript persists exactly one matching entry.failed to write transcript: unknown errorfor this flow.Hardening: race-safe idempotency (commit 9ea70b8)
Third-party review flagged that the original
transcriptHasIdempotencyKeyprecheck happened before acquiring the per-transcript queue+write lock — a TOCTOU window where two concurrent identical requests could both pass the check and persist duplicates. Fixed by moving the dedupe scan inside the locked critical section inappendSessionTranscriptMessageand threadingidempotencyKeythrough as a first-class parameter. Result is returned withdeduped: trueand the canonical existingmessageId, so duplicate broadcasts are suppressed too.Concurrent replay test (added in this PR)
src/gateway/server-methods/chat.inject.parentid.test.ts— 16-wayPromise.allof identical idempotent injects:Asserts:
messageIds.size === 1,dedupedCount === concurrency - 1, and the on-disk transcript contains exactly one entry with the matchingidempotencyKey.Live concurrent evidence (8-way, hot-patched runtime)
The on-disk invariant — at most one persisted entry per
(transcriptPath, idempotencyKey)— holds under true concurrency.Post-update verification (2026-05-15)
Additional in-depth edge-case coverage was added after initial hardening:
Updated local test results on branch head
0d8ea32769: