Answer stability round 1: 1 🔴, 6 🟡 (2 misread); read the scoring rule from the clone, hand windows XDG_DATA_HOME, retry the home check where nobody watches, tell an unreadable sign-in status and settings file apart, and bound the claude commands that build the home
CI / tests (pull_request) Successful in 4m35s

This commit is contained in:
2026-12-04 02:45:02 +01:00
parent 71865e0479
commit 3519922f01
19 changed files with 153 additions and 69 deletions
+5 -3
View File
@@ -30,6 +30,8 @@ from claude_home.home import unready
PYTHON_TIMEOUT = 600
# Seconds a command of the forge's CLI may take, so a stalled one cannot hold the loop.
FORGE_TIMEOUT = 60
# Seconds each `claude` command that builds the loop's Claude home may take, as long as a Python script may, so a stalled plugin download cannot hold every loop that waits on the home's lock.
HOME_TIMEOUT = PYTHON_TIMEOUT
class Streaming(typing.Protocol):
@@ -118,14 +120,14 @@ class StreamingClaude:
return self.proc.wait()
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:
def system_effects(home: pathlib.Path, env: typing.Mapping[str, str], backends: typing.Mapping[Notifier, Backend[typing.Any]] = BACKENDS, forge_timeout: float = FORGE_TIMEOUT, home_timeout: float = HOME_TIMEOUT) -> Effects:
"""The effects on this machine: the configs of its DM are under home, and tmux and the one-shot headless claude run in env, while a streaming claude and one on a terminal run in this process's environment plus what their caller adds. Every claude starts in the loop's Claude home, with the release's tools first on its `PATH`.
A test hands in `backends` that don't send anything, in place of the notifiers build-release's DM goes through. It hands in a short `forge_timeout`, so a command that outlasts it ends quickly.
A test hands in `backends` that don't send anything, in place of the notifiers build-release's DM goes through. It hands in a short `forge_timeout` or `home_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, env=claude_environment(env, home), input=stdin, text=True),
claude_home=lambda: unready(claude_home(env, home), RELEASE_ROOT, lambda args: subprocess.run(["claude", *args], capture_output=True, env=claude_environment(env, home), stdin=subprocess.DEVNULL, text=True), git_repo.git),
claude_home=lambda: unready(claude_home(env, home), RELEASE_ROOT, lambda args: subprocess.run(["claude", *args], capture_output=True, env=claude_environment(env, home), stdin=subprocess.DEVNULL, text=True, timeout=home_timeout), git_repo.git),
claude_on_terminal=claude_on_terminal,
discard_typed=lambda: termios.tcflush(sys.stdin, termios.TCIFLUSH),
dm=lambda text, directory: notify(text, directory, home, env, backends),
+23
View File
@@ -153,6 +153,29 @@ class ClaudeHomeEffect(unittest.TestCase):
self.assertEqual(ran[-1], f"{built} auth status")
self.assertIn(f"{built} plugin install code-review@claude-plugins-official", ran)
def test_a_plugin_that_does_not_install_stops_naming_the_command_and_what_claude_said(self):
with tempfile.TemporaryDirectory() as folder:
claude = pathlib.Path(folder, "claude")
claude.write_text('#!/bin/sh\nif [ "$*" = "plugin install code-review@claude-plugins-official" ]; then echo "no such plugin" >&2; exit 1; fi\n')
claude.chmod(0o755)
home = pathlib.Path(folder, "home")
reason = system_effects(home, without_xdg_folders(os.environ) | {"PATH": f"{folder}:{os.environ['PATH']}"}).claude_home()
self.assertEqual(reason, f"could not build the loop's Claude home, {home}/.local/share/build-release/claude-home: claude plugin install code-review@claude-plugins-official failed: no such plugin")
def test_a_claude_that_outlasts_its_time_is_stopped_and_the_home_is_not_built(self):
with tempfile.TemporaryDirectory() as folder:
claude = pathlib.Path(folder, "claude")
claude.write_text("#!/bin/sh\nexec sleep 5\n")
claude.chmod(0o755)
home = pathlib.Path(folder, "home")
reason = system_effects(home, without_xdg_folders(os.environ) | {"PATH": f"{folder}:{os.environ['PATH']}"}, home_timeout=0.2).claude_home() or ""
self.assertTrue(reason.startswith(f"could not build the loop's Claude home, {home}/.local/share/build-release/claude-home: Command '['claude', 'plugin', "), reason)
self.assertTrue(reason.endswith("' timed out after 0.2 seconds"), reason)
class ForgeEffect(unittest.TestCase):
def test_runs_the_forges_cli_in_the_checkout_it_is_given(self):