Repository navigation
Description
What happens
hook_write_settings writes ~/.claude/settings.json through a temporary beside it (openRepoTools:3548-3560 at main 33ce26d): mktemp makes settings.json.openrepotools.XXXXXX (:3552), cp fills it (:3554), chmod 600 (:3556), and mv -f moves it into place (:3558). It removes the temporary on each failure it sees, in the three || { rm -f -- "$hook_tmp"; die … } arms (:3555, :3557, :3559). Those arms run only when the command fails and the shell goes on. A run killed by a signal between the mktemp and the mv never reaches them, as the probe below shows.
Nothing else knows its name. The only trap is the EXIT trap workdir sets (:248-253): rm -rf -- "$WORKDIR"; [ -z "$PLACING" ] || rm -f -- "$PLACING"*. PLACING (:85) is set only by place_by_rename (:2027) and cleared after its mv (:2062), so it is empty when hook_write_settings runs, and hook_write_settings never sets it. The next --install makes a new temporary and looks at none of the old ones: the template appears in code at :3552 and nowhere else. hook_write_settings is reached from both hook arms (:3610, :3636) and from wip init through place_hook_pair (:4223).
Measured (main 33ce26d, bash 5.2.21; an --install run from an export of that commit, which fetches nothing; a sandbox HOME, CLAUDE_USER_DIR and TMPDIR; a hook target that answers guard; a cp first on PATH that sleeps 3 s when handed a settings.json.openrepotools.* path; SIGINT to the process group, as Ctrl-C sends it, once the temporary exists)
- The run dies of SIGINT (the harness reports -2), the
EXITtrap removes the workdir, and~/.claude/settings.json.openrepotools.X600kTis left behind: empty, at 0600. - With
chmodas the stalled tool instead, so the signal lands aftercp: the leftover is 528 bytes at 0600 and holds the merged settings,hookskey included.
SIGTERM and SIGHUP take the same path by reading; they were not probed.
Does #250 change it? No. #250's branch (14695e1; issue #250 is still open) adds an INT trap (:289) that runs remove_workdir (:281-284) and then dies of the signal as before. remove_workdir removes $WORKDIR and $PLACING*, the same two things main's EXIT trap removes. hook_write_settings is the same text at 14695e1 (:3614-3626) and sets no PLACING. The same probe at 14695e1 left the same file: killed by SIGINT, the workdir gone, and settings.json.openrepotools.hhXzCu behind. The comment there names what the trap leaves, the $(…) waits and the SIGTERM window (14695e1:openRepoTools:262-277), and not this write. #250's title, "A SIGINT at any instant of --install's placement ends the run and leaves no temporary", is true of place_by_rename's temporaries and not of this one.
Why it matters
Low. No installed state is wrong: settings.json itself is only ever renamed over, so it is whole or untouched. What remains is a file named like a temporary in ~/.claude, one per interrupted run, which no later run removes. Where the signal lands after the cp, it is a full copy of the person's merged settings, at 0600 because mktemp made it so. It is the fault #167 closed for place_by_rename's temporaries; this is the one temporary --install makes that the trap was never taught.
Suggested fix (nothing here is decided)
- Give the temporary a prefix the trap knows, as
place_by_renamedoes (:2027-2062):PLACING="$(dirname -- "$settings")/settings.json.openrepotools.$$."before themktemp,mktemp -- "${PLACING}XXXXXX", andPLACING=""after themvand in each failure arm. The pid keeps the prefix this run's own, so the trap'srm -f -- "$PLACING"*cannot take another run's temporary. No test names thesettings.json.openrepotools.template (searchedtests/at33ce26d). - Or place the settings through
place_by_rename, one temporary mechanism for every file this installer writes. It would also change the temporary's name and add its owner check and refusal text. - A case for it:
test_a_run_killed_mid_placement_leaves_no_temporary(tests/test_openrepotools_command.py:905) signals as soon as the first*.openrepotools.*appears (SLOW_TOOLS,:888). On a fresh home that is the first bin file's, so the settings write is never where it lands, thoughplacement_temporaries(:535-545) already lists~/.claude. A second case could run--installtwice, withsettings.jsonremoved before the second so that the settings temporary is the only one, send SIGINT to the group and SIGTERM to the shell, and assertplacement_temporaries(home) == []. It should fail on main and on14695e1, as the probe does.
Not run: the shell suite; the fix; SIGTERM or SIGHUP at this write; wip init's path; any platform but Linux. The second case above is a sketch, and whether anything else in that second run makes a temporary was not checked.
See also #331, the late-link gap in the same write to settings.json.
Found by: the probe of #250's 14695e1 made while drafting #250's follow-ups (2026-10-23), re-run against main 33ce26d for this issue. Filed on Brett Heap's word of 2026-10-23T18:52:34Z, by multiple choice.
Lane: openRepoTools-5
Activity
brettheap commentedon Oct 24, 2026
CLAIMED — lane openRepoTools-5, session 0d83dca2-c18c-4bb0-99ce-896e6cafea02@Eagle, 2026-10-24T14:19:38Z, for #332
Logged in
lanes/log/openRepoTools-5.mdat9e4a3521ca05f865d7bbc58e7b435bdbb8e32b5c.The three reads (lane-collision-protocol Rule 1):
A failed mktemp -d for the workdir ends --install with exit 1 from ev…
The late refusal of a link at settings.json says only what is true in…
The note wip init prints beside a refused hook pair says the refusal …
The installer's comments say that one $(…) to a command closes the wa…
The text check counts backticks, process substitutions and the substi…