fix(auto-reply): serialize reply session initialization#96847
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 25, 2026, 3:31 PM ET / 19:31 UTC. Summary PR surface: Source +84, Tests +114. Total +198 across 7 files. Reproducibility: yes. at source level: current main reads the reply-session initialization snapshot before the guarded commit serializes the store mutation, allowing same-session initializers to share a stale revision. I did not run the failing path locally because this was a read-only review. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this after session/reply owner review confirms the reentrant writer scope and refreshed validation, while keeping Telegram spool backoff and skillsSnapshot fixes tracked separately. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main reads the reply-session initialization snapshot before the guarded commit serializes the store mutation, allowing same-session initializers to share a stale revision. I did not run the failing path locally because this was a read-only review. Is this the best way to solve the issue? Yes, this appears to be the right owner-boundary fix for the in-process race because it keeps the snapshot read and guarded commit in the session-store writer lane. The remaining judgment is whether the broader writer scope is acceptable or should be narrowed before landing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1aa7cafc35a1. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +84, Tests +114. Total +198 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
|
7d6b1ec to
1c229d4
Compare
1c229d4 to
a7e88b4
Compare
What Problem This Solves
Telegram isolated-ingress replay could loop forever when reply-session initialization hit a repeated stale-snapshot conflict before the agent turn started. The conflict escaped as a retryable handler failure, so the same spooled Telegram update was released and replayed again.
Why This Change Was Made
The stale-snapshot guard was checking a snapshot that was read outside the session-store writer queue. Multiple same-session initializers could compute from the same entry and then race through the guarded commit. This makes the snapshot read and guarded commit one logical writer-lane operation, while allowing the nested commit path to re-enter the same store writer without deadlocking.
User Impact
Telegram turns no longer get stuck replaying the same spooled update because normal in-process session initialization now serializes before reading the guarded snapshot. True external/cross-process conflicts still fail loudly through the existing guard.
Evidence
node scripts/run-vitest.mjs src/config/sessions/store-writer.test.ts src/auto-reply/reply/session.test.tscheck:changed:tbx_01kw03ae1gwfxnf4xp3x14s88r, https://github.com/openclaw/openclaw/actions/runs/2819447180439444, observed threaded SUT reply39445withOPENCLAW_E2E_OK, mock OpenAI requests1