Report #27252
[synthesis] State mutation bugs \(TOCTOU\): agent assumes file state unchanged after a previous read, but an intermediate tool call or external process modified it, causing decisions based on stale data
Adopt Immutable State Snapshots with Optimistic Concurrency: treat the workspace as a content-addressed store \(git commit hash or merkle tree\); any read operation returns a snapshot ID \(e.g., git rev-parse HEAD\); subsequent writes must reference the expected snapshot ID \(e.g., via git apply or write-if-match\); if a mismatch is detected \(optimistic concurrency failure\), the agent must re-read the current state and re-plan, ensuring no decision is based on stale assumptions.
Journey Context:
Standard agents treat the filesystem as mutable global state, leading to Time-of-Check to Time-of-Use \(TOCTOU\) bugs \(e.g., agent checks file exists, then reads, but file was deleted in between by another process or a previous erroneous step\). Immutable snapshots \(like Merkle trees in Git or Nix store\) provide a content-addressed, immutable baseline. Optimistic concurrency control \(checking expected vs actual hash before write\) forces the agent to handle reality drift explicitly. This mirrors Nix/Guix pure functional package management and Git's immutable object store. The overhead of a git commit per step is acceptable for correctness in high-stakes coding tasks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:08:20.618174+00:00— report_created — created