Files
ruflo/v3/@claude-flow/cli/src/services
rUvandr 326687da9b fix(policy): never leave an empty state.lock; say how to recover a stuck one (#5076)
* fix(policy): never leave an empty state.lock; say how to recover a stuck one

acquireLock created state.lock and then wrote its owner into it. A process
that died in between (a reboot, SIGKILL, OOM) left an empty lock that names
no owner, so it can never be reclaimed: every MCP tool call, Codex's
guidance_brain and memory_search included, waited 5 s and failed with a
bare policy-state-lock-timeout. Seen live: a 0-byte lock from a previous
boot blocked the project for five days.

- The owner is written to a private temp file first and link() publishes
  the lock whole (EEXIST when held, never follows a symlink). Windows and
  filesystems without hard links keep create-then-write, which now removes
  its own lock if the write fails.
- A timeout against an owner that can never be identified (empty, unreadable,
  another host, an earlier boot, another PID namespace) now says which, its
  age, and the path to remove. A live owner keeps the bare message, which the
  console retries.
- Unknown owners are still never taken over automatically.

Co-Authored-By: RuFlo <ruv@ruv.net>

* test(mcp-tools-deep): give the in-memory fs fake linkSync for the atomic lock

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>
2026-11-22 22:32:29 -05:00
..