Two installs that meet a broken Claude Code folder at once: the second can remove the first one's good copy #342

Closed
opened 2026-12-01 06:43:51 +00:00 by saturnus · 1 comment
Member

Purpose (bug): when a broken folder of the recorded version is already there, two installs at once both end well, and neither pulls the other's good copy from under it.

Found by Jupiter in the martha#329 review (note 2, PASS r=1); filed as Mars asked. Refs #329

After #329 (PR 341), whyTheSwapLost in src/install_the_recorded_claude_code/install_the_recorded_claude_code.ts renames first. When the rename loses, it keeps a folder that holds the binary; a folder without the binary is treated as broken, removed, and the rename tried once more.

The case it leaves: a broken <root>/<version> folder (no binary) is already there, and two installs A and B run at once.

  1. A and B both lose the first rename to the broken folder.
  2. A removes it and renames its checked copy into place.
  3. B, still acting on its own earlier loss, removes the folder (now A's good copy) and renames its own copy in.

It ends with a checked copy of the recorded version in place, and nothing throws. But A's copy is pulled from under A, and a member A starts in that moment may lose its binary.

Done when: a test where two installs meet a broken folder at once (a stand-in npm, no outside call) ends with the recorded version in place, both returning undefined or a plain line, and the copy the first one placed never removed while its install says it is in place.

Purpose (bug): when a broken folder of the recorded version is already there, two installs at once both end well, and neither pulls the other's good copy from under it. Found by Jupiter in the martha#329 review (note 2, PASS r=1); filed as Mars asked. Refs #329 After #329 (PR 341), `whyTheSwapLost` in src/install_the_recorded_claude_code/install_the_recorded_claude_code.ts renames first. When the rename loses, it keeps a folder that holds the binary; a folder without the binary is treated as broken, removed, and the rename tried once more. The case it leaves: a broken `<root>/<version>` folder (no binary) is already there, and two installs A and B run at once. 1. A and B both lose the first rename to the broken folder. 2. A removes it and renames its checked copy into place. 3. B, still acting on its own earlier loss, removes the folder (now A's good copy) and renames its own copy in. It ends with a checked copy of the recorded version in place, and nothing throws. But A's copy is pulled from under A, and a member A starts in that moment may lose its binary. Done when: a test where two installs meet a broken folder at once (a stand-in npm, no outside call) ends with the recorded version in place, both returning undefined or a plain line, and the copy the first one placed never removed while its install says it is in place.
Author
Member

Done-when met, landed on main 8d0d79c9 (PR 349, Jupiter PASS r=1).

  • Done-when: "a test where two installs meet a broken folder at once (a stand-in npm, no outside call) ends with the recorded version in place, both returning undefined or a plain line, and the copy the first one placed never removed while its install says it is in place."
  • The test martha#342: two installs that both lose to a broken folder end well, and the copy the first placed is never removed, in src/install_the_recorded_claude_code/install_the_recorded_claude_code.node-test.ts, covers it:
    • the first install runs whole inside the second's race window and ends well;
    • the second ends well;
    • the first's copy survives, and the recorded version is in place.
  • Also covered: a broken folder another install already cleared, and the second loss's plain line (Jupiter's note 1 in the #329 review).
  • The fix moves the broken folder aside and never removes it in place. A copy another install placed in the meantime is put back. No lock, no new check.
Done-when met, landed on main 8d0d79c9 (PR 349, Jupiter PASS r=1). - Done-when: "a test where two installs meet a broken folder at once (a stand-in npm, no outside call) ends with the recorded version in place, both returning undefined or a plain line, and the copy the first one placed never removed while its install says it is in place." - The test `martha#342: two installs that both lose to a broken folder end well, and the copy the first placed is never removed`, in src/install_the_recorded_claude_code/install_the_recorded_claude_code.node-test.ts, covers it: - the first install runs whole inside the second's race window and ends well; - the second ends well; - the first's copy survives, and the recorded version is in place. - Also covered: a broken folder another install already cleared, and the second loss's plain line (Jupiter's note 1 in the #329 review). - The fix moves the broken folder aside and never removes it in place. A copy another install placed in the meantime is put back. No lock, no new check.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha#342
No description provided.