Repository navigation
Description
Goal: a SIGINT that lands at any instant of a placement ends openRepoTools --install and leaves no .<name>.openrepotools.* temporary, so test_a_run_killed_mid_placement_leaves_no_temporary[SIGINT-True-cp] stops failing about once in a hundred runs. The test is at tests/test_openrepotools_command.py:877; it came with #172, for #167.
Where this comes from. Lane openRepoTools-3 filed this on Brett Heap's word, verbatim: "yes, file the SIGINT flake in v1.2.0" (2026-10-18).
- 006's T008 writer (Releases: annotated tags, release/vX.Y branches, and openrepotools on TestPyPI and PyPI from v1.1.0 #228) hit the failure once in an extra local run (
495 passed, 9 skipped, 1 failed). It then reproduced it on the installer as it was before T008's change. - It does not block v1.1.0. The failure predates Releases: annotated tags, release/vX.Y branches, and openrepotools on TestPyPI and PyPI from v1.1.0 #228, and Releases: annotated tags, release/vX.Y branches, and openrepotools on TestPyPI and PyPI from v1.1.0 #228 does not change
workdirorplace_by_rename.
Where it has failed
- CI:
tests-no-submoduleon Follow up #190's test roots: name a refused root's value, check the pin's commit, find paired feature worktrees, show redirected roots under -q, run the lane manual sections, and restate the installer-source test #195 atfb77bed, 2026-10-10:subprocess.TimeoutExpired: Command '['bash', '…/openRepoTools', '--install']' timed out after 60 seconds. The re-run passed (lane 1, 6103460962). - Locally, 2026-10-18, in T008's run: the final assert,
placement_temporaries(tmp_path) == [], failed. A 0-byte.openRepoTools.openrepotools.<pid>.XXXXXXwas left in~/.local/bin. - Possibly related: lane 1 saw
[SIGTERM-False-cp]fail once in a composed run on 2026-10-09, and read it as a load flake (Triad migration (feature 004-migrate-to-triad): execution tracking under Brett Heap's word of 2026-10-07 #186, 6089801221). Which way it failed was not recorded.
Measured outside pytest. The script below repeats the test's own steps:
- a slow
cpfirst onPATH; - a poll for a temporary every 50 ms;
- then
os.killpg(…, SIGINT)on the run's process group.
It adds one thing, a TMPDIR for each run. The machine runs bash 5.2.21, and /bin/sh is dash (Ubuntu on WSL2).
| Installer | Runs | Ignored the SIGINT and kept installing | Died of SIGINT but left the temporary | Clean |
|---|---|---|---|---|
main 87a5e9d |
300 | 1 | 1 | 298 |
006-release-pypi at 2e4a633 (workdir and place_by_rename byte-identical to main) |
190 | 2 | 1 | 187 |
| T008's (#228, placement code unchanged) | 190 | 0 | 2 | 188 |
main 87a5e9d, with an EXIT trap that logs each step using builtins |
700 | 2 | 0 | 698 |
It needs the signal within a few milliseconds of mktemp making the file.
- With 0 to 20 ms of random delay added before the signal, 100 runs each of
2e4a633and T008's installer were all clean. - With the slow tool as
mktempinstead (the signal lands whilemktempsleeps), 40 runs of each were all clean. - Only the
cpcase meets that window. Itsmktempis quick, and the test signals as soon as the file shows.
The two failure modes
- The run ignores the SIGINT and keeps installing. Then
communicate(timeout=60)times out, because every later placement goes through the slowcp, 3 seconds each.- In both traced runs the EXIT trap never ran. Twenty seconds after the signal, the bin directory held 7 entries.
- Likely cause: bash's rule for a non-interactive shell that receives SIGINT while it waits for a foreground command (bash manual, "Signals"). If that command does not die of the signal, bash assumes the command handled it, and goes on. A SIGINT that arrives after
mktemphas exited 0, but before bash has reaped it, falls under that rule. - A person would see it too. A Ctrl-C at that instant does nothing, and the install goes on until a second Ctrl-C.
- The run dies of SIGINT but leaves the temporary. The file is 0 bytes, so it is
mktemp's file, made beforecpwrote anything. Run 268 of the 300 on main showed three things:- The run's workdir was gone, so the EXIT trap's first command,
rm -rf -- "$WORKDIR"(openRepoTools:240), had run. - The real
cpran after the trap. The last line of stderr was/usr/bin/cp: cannot stat '…/tmp/tmp.ttxdmmFujp/…': the realcpcould not find its source, which was in that workdir. So the slowcp, forked aftermktemp, never received the signal, and ran on after the trap. - The temporary was still there. Its name carries the run's own
$PLACINGprefix, which the trap's second command,[ -z "$PLACING" ] || rm -f -- "$PLACING"*, removes. - Not yet known: whether that second command ran. The 700 traced runs did not reproduce this mode. A longer traced run is going, and lane 3 will add its result here.
- The run's workdir was gone, so the EXIT trap's first command,
What a fix has to settle (nothing here is decided):
- Make SIGINT always end the run. One way is a
trap … INTthat does the EXIT trap's cleanup, then re-raises SIGINT with its default action. Bash runs a SIGINT trap even when the foreground command did not die of the signal, so this would close mode 1, for people as well as for the test. The run must still die of the signal (-2or130), which the test asserts. - Make the cleanup unable to stop halfway. Remove the temporary first, or remove the temporary and the workdir in one
rm. Whether that closes mode 2 depends on mode 2's cause, which is still open. - Lane 3's recommendation: do not change only the test. Waiting until the slow tool is asleep before signalling would hide both modes, and re-sending the signal would hide mode 1. Both are real instants at which a person's Ctrl-C can land.
Done when:
- a few hundred runs of the script below give none of either mode, on Linux;
- the SIGINT and SIGTERM cases still fail against a trap that does not remove the temporary, as they do today;
- CI's Linux jobs stay green.
The script: python3 -I repro7.py <installer tree> <runs> <scratch dir>, where the tree is git archive of the commit under test, extracted
import os, shutil, signal, subprocess, sys, tempfile, time
from pathlib import Path
src = Path(sys.argv[1]); runs = int(sys.argv[2]); base = sys.argv[3]
SLOW_CP = 'for arg in "$@"; do\n\tcase "$arg" in *.openrepotools.*) sleep 3 ;; esac\ndone\nexec {real} "$@"\n'
def temps(home):
dirs = [home / ".local" / "bin", home / ".claude", home / ".claude" / "commands", home / ".claude-profiles" / "shared" / "commands"]
for n in ("handoff", "lane-swap", "restart"):
dirs += [home / ".claude" / "skills" / n, home / ".claude-profiles" / "shared" / "skills" / n]
return sorted(str(p) for d in dirs if d.is_dir() for p in d.iterdir() if ".openrepotools." in p.name)
def dflt():
signal.signal(signal.SIGINT, signal.SIG_DFL); signal.signal(signal.SIGTERM, signal.SIG_DFL)
stats = {"runs": 0, "died": 0, "left": 0, "left_workdir_gone": 0, "left_workdir_kept": 0, "hung": 0, "survived": 0}
for i in range(runs):
home = Path(tempfile.mkdtemp(dir=base)).resolve()
shim = home / "shim"; shim.mkdir()
tmpdir = home / "tmp"; tmpdir.mkdir()
(shim / "cp").write_text("#!/bin/sh\n" + SLOW_CP.format(real=shutil.which("cp"))); (shim / "cp").chmod(0o755)
env = {k: v for k, v in os.environ.items() if not k.startswith(("OPENREPOTOOLS_", "LANES_", "TMUX", "XDG_DATA_HOME", "CLAUDE_", "AGENT_PROTOCOL_ROOT", "PROJECTS_DIR"))}
env.update(HOME=str(home), TMPDIR=str(tmpdir), CLAUDE_PROFILES_HOME=str(home / ".claude-profiles"), CLAUDE_USER_DIR=str(home / ".claude"), AGENT_PROTOCOL_ROOT=str(home / ".agents"), PATH=f"{shim}:{os.environ['PATH']}")
run = subprocess.Popen(["bash", str(src / "openRepoTools"), "--install"], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env, start_new_session=True, preexec_fn=dflt)
deadline = time.monotonic() + 60
while time.monotonic() < deadline and not temps(home): time.sleep(0.05)
seen = temps(home)
workdirs_before = sorted(os.listdir(tmpdir))
os.killpg(run.pid, signal.SIGINT)
stats["runs"] += 1
try:
out, err = run.communicate(timeout=20)
except subprocess.TimeoutExpired:
stats["hung"] += 1
print("HUNG", i, "signalled beside", [p.split("/")[-1] for p in seen], "bin now holds", len(os.listdir(home / ".local" / "bin")), flush=True)
os.killpg(run.pid, signal.SIGKILL); out, err = run.communicate()
rc = run.returncode
if rc in (-signal.SIGINT, 128 + signal.SIGINT): stats["died"] += 1
elif rc != -9: stats["survived"] += 1; print("SURVIVED", i, "exit", rc, flush=True)
t = temps(home)
if t and rc != -9:
stats["left"] += 1
kept = sorted(os.listdir(tmpdir))
stats["left_workdir_kept" if kept else "left_workdir_gone"] += 1
print("LEFT", i, "exit", rc, t[0].split("/")[-1], os.path.getsize(t[0]), "bytes; signalled beside", [p.split("/")[-1] for p in seen],
"; TMPDIR before the signal", workdirs_before, "after", kept, "; last stderr line", (err.strip().splitlines() or [""])[-1][:160], flush=True)
shutil.rmtree(home, ignore_errors=True)
if (i + 1) % 25 == 0: print("progress", i + 1, stats, flush=True)
print("FINAL", stats, flush=True)Lane: openRepoTools-3
Activity
brettheap commentedon Oct 18, 2026
The longer traced run, 2026-10-18T14:5xZ, against main
87a5e9d. The copy logs each step of the EXIT trap with builtins only, as in the issue's last table row. A further 1,500 runs went out in three parallel workers, so the traced runs now total 2,200.workdirandplace_by_renamegave 4 such runs in 680. The traced copy gave none in 2,200.cp, forked aftermktemp, which ran on after the trap.strace -f -tt -e trace=execve,unlink,unlinkat,kill, orbpftraceonunlinkat) is the next step.Lane: openRepoTools-3
openRepoTools becomes the openrepotools package: pipx installs the wh…
brettheap commentedon Oct 20, 2026
CLAIMED — lane openRepoTools-5, session 0d83dca2-c18c-4bb0-99ce-896e6cafea02@Eagle, 2026-10-20T23:02:39Z, for #250
Logged in
lanes/log/openRepoTools-5.mdatac78b0be71fbd9657740459786902b7edef3af00.The three reads (lane-collision-protocol Rule 1):
A SIGINT or a SIGTERM at any instant of --install's placement ends th…
WIP (#250): SIGINT cases in the waits for dirname and for each owner_…
Three cases land a SIGINT in the waits for dirname and for each owner…
The refusal of a link made after planning is pinned at a SKILL.md and…
The comment above remove_workdir says a SIGINT ends the run wherever …
A link made after planning at a target whose bytes are already right …
The late refusal of a link at settings.json says only what is true in…
The comments on a lost SIGINT say it is inferred, the one on workdir'…
The text check counts backticks, process substitutions and the substi…