Put the release's tools on PATH of every claude the loop starts, and name them bare in the prose
CI / tests (pull_request) Successful in 4m36s

This commit is contained in:
2026-12-03 12:49:56 +01:00
parent fb1dd763e2
commit 0653c2744e
64 changed files with 306 additions and 169 deletions
+5 -4
View File
@@ -23,6 +23,7 @@ from project_config.settings import Notifier
from text_files.file_writes import replace_file
from forge.commands import Run, runner
from machine_load.slots import slot_folder
from loop_state.paths import with_release_tools
# Seconds before a Python script loop-claude runs is stopped, so a hung one, such as chunk-preflight, cannot hold the loop.
PYTHON_TIMEOUT = 600
@@ -83,7 +84,7 @@ class Effects:
class StreamingClaude:
def __init__(self, args: list[str], cwd: str, env: dict[str, str]) -> None:
self.proc = subprocess.Popen(["claude", *args], cwd=cwd, env={**os.environ, **env}, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, bufsize=0)
self.proc = subprocess.Popen(["claude", *args], cwd=cwd, env=with_release_tools({**os.environ, **env}), stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, bufsize=0)
def lines(self, idle: float) -> typing.Iterable[str | None]:
# Reads the pipe's file descriptor itself. select cannot see what a buffered reader holds.
@@ -115,12 +116,12 @@ class StreamingClaude:
def system_effects(home: pathlib.Path, env: typing.Mapping[str, str], backends: typing.Mapping[Notifier, Backend[typing.Any]] = BACKENDS, forge_timeout: float = FORGE_TIMEOUT) -> Effects:
"""The effects on this machine: the configs of its DM are under home, and tmux runs in env.
"""The effects on this machine: the configs of its DM are under home, and tmux and the headless claude run in env. Every claude starts with the release's tools first on its `PATH`.
A test hands in `backends` that don't send anything, in place of the notifiers loop-claude's DM goes through. It hands in a short `forge_timeout`, so a command that outlasts it ends quickly.
"""
return Effects(
claude=lambda args, cwd, stdin: subprocess.run(["claude", *args], capture_output=True, cwd=cwd, input=stdin, text=True),
claude=lambda args, cwd, stdin: subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=with_release_tools(env), input=stdin, text=True),
claude_on_terminal=claude_on_terminal,
discard_typed=lambda: termios.tcflush(sys.stdin, termios.TCIFLUSH),
dm=lambda text, directory: notify(text, directory, home, backends),
@@ -147,7 +148,7 @@ def claude_on_terminal(args: list[str], cwd: str, env: dict[str, str]) -> int:
# A Python handler, unlike SIG_IGN, is reset to the default as claude starts, so Ctrl-C still reaches claude.
previous = signal.signal(signal.SIGINT, lambda number, frame: None)
try:
return subprocess.run(["claude", *args], cwd=cwd, env={**os.environ, **env}).returncode
return subprocess.run(["claude", *args], cwd=cwd, env=with_release_tools({**os.environ, **env})).returncode
finally:
signal.signal(signal.SIGINT, previous)