Repository navigation
fix(cron): skip delivery mirror for routed peer sessions to prevent session lock races - #84603
NianJiuZst wants to merge 2 commits into
Conversation
…ession lock races
|
Codex review: needs real behavior proof before merge. Reviewed June 24, 2026, 6:13 AM ET / 10:13 UTC. Summary PR surface: Source +16, Tests +1, Other +201. Total +218 across 3 files. Reproducibility: yes. source-level: current main and v2026.6.10 still resolve explicit cron delivery to a routed peer session and append a transcript mirror there. I did not run the live Telegram race in this read-only review. Review metrics: 1 noteworthy metric.
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:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a refreshed current-main fix that suppresses only unsafe routed peer transcript mirrors, preserves main and threaded-main behavior across alias/global scopes, keeps target-session awareness intact, and proves the cron/channel race with redacted real behavior evidence. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main and v2026.6.10 still resolve explicit cron delivery to a routed peer session and append a transcript mirror there. I did not run the live Telegram race in this read-only review. Is this the best way to solve the issue? Not yet as submitted. The caller-side guard is the right layer for the narrow cron path, but it needs conflict resolution, canonical main/thread classification, restored coverage, and real cron/channel proof before it is the best mergeable fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e9720c27fa69. Label changesLabel justifications:
Evidence reviewedPR surface: Source +16, Tests +1, Other +201. Total +218 across 3 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
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
Summary
Fixes #84583: cron delivery mirror appending to a routed per-channel-peer session could race the embedded runner session lock, triggering
EmbeddedAttemptSessionTakeoverErrorand aborting the user's in-flight chat response.resolveDirectCronDeliverySessionKeynow returns the resolved outbound route alongside the session key, so the dispatch path can distinguish per-channel-peer sessions from threaded main-session variants. Delivery mirror is skipped for routed peer sessions (channel-mapped, non-main) while awareness still reaches the main session queue; the direct channel send is unaffected.Changes
src/cron/isolated-agent/delivery-dispatch.ts:resolveDirectCronDeliverySessionKeyreturns{ sessionKey, route: OutboundSessionRoute | null }instead ofstring, exposing whether the session was resolved through outbound routingdeliverySessionIsRoutedPeerSessionchecks: is this a routed session that is not the main session AND not a threaded main-session variant? UsesparseThreadSessionSuffixto correctly distinguish per-channel-peer sessions from threaded main sessions!deliverySessionIsRoutedPeerSessionsrc/cron/isolated-agent/delivery-dispatch.double-announce.test.ts:Real behavior proof
Behavior addressed: Cron jobs with explicit delivery targets and
session.dmScope="per-channel-peer"that resolve to a channel peer session (agent:<agent>:<channel>:direct:<peer>) trigger a session takeover error when the embedded runner has that same session active, because the direct transcript mirror mutates the session file between the prompt lock release and re-acquire.Real environment tested: macOS Darwin 25.4.0 (arm64), Node.js v24.14.1, OpenClaw main branch
Exact steps or command run after this patch:
Evidence after fix:
Unit test results:
Observed result after fix:
deliverySessionIsRoutedPeerSession = truedeliverySessionBaseIsMainSession = truecorrectly identifies it as a main-session variantdeliveryWillReachAwarenessMainSession), unchangedroute = nullso guard does not firecanonicalizeMainSessionAliasfromsrc/config/sessions/main-session.js,parseThreadSessionSuffixfromsrc/sessions/session-key-utils.js)git diff --checkcleanWhat was not tested: Live cron job delivering to a Telegram/WhatsApp/Discord channel while the same per-channel-peer session is held by an active embedded runner (requires live channel credentials, a configured cron job, and a concurrent embedded session). Same root pattern confirmed across cron and subagent announce paths (#84059).
🤖 Generated with Claude Code