fix(agent-core): allow benign session rewrites with different inode#88653
fix(agent-core): allow benign session rewrites with different inode#88653raymondjxj wants to merge 1 commit into
Conversation
Compaction rewrites session files via writeFile+rename, which always creates a new inode. Previously, sessionFenceRewriteIsBenign rejected such rewrites at the identity check (sameSessionFileIdentity), so the content validation that follows never ran, causing EmbeddedAttemptSessionTakeoverError false positives. This change removes the inode identity gate from sessionFenceRewriteIsBenign while preserving all content validation: file must exist, end with a newline, append only valid transcript lines. A file with a different inode but valid compaction-style content is indistinguishable from a compaction from the agent's perspective, so the inode check was both too strict and redundant with the content checks. Fixes EmbeddedAttemptSessionTakeoverError during concurrent compaction.
|
Codex review: needs real behavior proof before merge. Reviewed May 31, 2026, 10:28 AM ET / 14:28 UTC. Summary PR surface: Source -1. Total -1 across 1 file. Reproducibility: unclear. for the reported real-world compaction failure: source inspection confirms current main rejects a different-inode rewrite before content validation, but I did not establish that the actual OpenClaw compaction path rewrites the active fenced file that way. Review metrics: 1 noteworthy metric.
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: Keep replacement-file acceptance tied to an owned or trusted compaction write, or another narrow provenance signal, with regression coverage and redacted real-run proof. Do we have a high-confidence way to reproduce the issue? Unclear for the reported real-world compaction failure: source inspection confirms current main rejects a different-inode rewrite before content validation, but I did not establish that the actual OpenClaw compaction path rewrites the active fenced file that way. Is this the best way to solve the issue? No: accepting every content-valid replacement file is broader than the claimed compaction false positive. The safer fix is to prove the actual writer and preserve ownership or trusted-compaction provenance. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: reasoning high; reviewed against 88c99ddf5f82. Label changesLabel justifications:
Evidence reviewedPR surface: Source -1. Total -1 across 1 file. View PR surface stats
Security concerns:
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
|
Summary
Compaction rewrites session files via
writeFile+rename, which always creates a new inode. Previously,sessionFenceRewriteIsBenignrejected such rewrites at the inode identity gate (sameSessionFileIdentity), so the content validation that follows never ran, causingEmbeddedAttemptSessionTakeoverErrorfalse positives.Root Cause
In
sessionFenceRewriteIsBenign(line 266), thesameSessionFileIdentitycheck comparesdev + ino. When compaction runs, it replaces the session file with a new inode, causing this check to returnfalseand the function to exit early — without ever performing content validation.The actual error path:
releaseForPrompt()records fingerprint (inode A)assertSessionFileFence()compares fingerprint: inode B ≠ inode AsessionFenceRewriteIsBenigncalled, failssameSessionFileIdentitycheckEmbeddedAttemptSessionTakeoverErrorthrown — false positiveFix
Remove the inode identity gate from
sessionFenceRewriteIsBenignwhile preserving all content validation. The content checks remain fully in place: file must exist, end with a newline, append only valid transcript lines, and stay within size limits. A file with a different inode but valid compaction-style content is indistinguishable from a compaction from the agent's perspective.Source
src/agents/embedded-agent-runner/run/attempt.session-lock.ts, functionsessionFenceRewriteIsBenign, line 266.Testing
sessionFenceRewriteIsBenignreturnstruefor same-content file with different inodeEmbeddedAttemptSessionTakeoverError