#4798·nanobot

Bug: Concurrent file writes from different sessions not serialized — workspace file corruption

Author: hamb1yCreated Jul 6, 2026Updated Sep 28, 2026

Summary

File tools (ReadFileTool, WriteFileTool, EditFileTool) do not acquire any file-level lock before writing. Two concurrent agent turns in different sessions can write to the same file simultaneously, causing data corruption or interleaved writes.

Affected Code

  • nanobot/agent/tools/filesystem.py:43-101 — no file-level locking in any tool
  • nanobot/agent/tools/apply_patch.py:268-284 — multi-step atomic write pattern vulnerable to concurrent modification

Suggested Fix

  1. Add fcntl.flock() or a workspace-level file lock manager
  2. At minimum, serialize writes per-file within the same workspace