Files
ruflo/v3/@claude-flow
rUv 5f3f4df408 fix(policy): retry transient rename failures in writeJsonAtomic, never orphan the temp file (#3398) (#3404)
On Windows, renameSync over .claude-flow/policy/state.json fails with
EPERM/EBUSY/EACCES while another process briefly holds the destination open.
writeJsonAtomic made a single attempt with no cleanup, so the whole MCP call
failed and state.json.<pid>.<uuid>.tmp was left behind.

- Retry transient rename errors with a bounded async backoff (~1.3s total,
  inside the 5s state.lock wait; async so the MCP event loop is not blocked).
- try/finally removes the temp file on any final failure.
- A final failure still fails the call: the state carries the hash-chained
  receipt ledger and consumed approval uses; dropping the write would return
  a phantom receipt and let a one-shot approval be reused.

Fixes #3398
2026-09-23 14:26:50 +00:00
..