Answer stability round 1: 0 🔴, 2 🟡 (0 misread); name the signed-out check beside its message, and report a signal as a shell does; the 🟢 for a claude that cannot start is declined, as the home's build fails first

This commit is contained in:
2026-12-04 06:01:58 +01:00
parent ba4cc2c90f
commit 0cd46f95aa
4 changed files with 21 additions and 9 deletions
+6 -1
View File
@@ -19,7 +19,7 @@ LINKED = ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills")
CLONE = "{clone}" CLONE = "{clone}"
# Stands for the reports folder, which holds every chunk's review folder, in the clone's settings.json. Every value that holds it is a path, so unlike CLONE it isn't shell-quoted. # Stands for the reports folder, which holds every chunk's review folder, in the clone's settings.json. Every value that holds it is a path, so unlike CLONE it isn't shell-quoted.
REPORTS = "{reports}" REPORTS = "{reports}"
# What `unready` says first where nobody has signed in to the home yet; `claude-release` runs there anyway, since /login is typed in that claude. # What `unready` says first where nobody has signed in to the home yet.
SIGNED_OUT = "nobody is signed in to the loop's Claude home" SIGNED_OUT = "nobody is signed in to the loop's Claude home"
# The file in the home that names the clone, its commit and the reports folder the home was built from. # The file in the home that names the clone, its commit and the reports folder the home was built from.
BUILT_FROM = "built-from" BUILT_FROM = "built-from"
@@ -50,6 +50,11 @@ def unready(home: pathlib.Path, clone: pathlib.Path, reports: pathlib.Path, clau
return f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR={shlex.quote(str(home))} claude` and type /login there, once" return f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR={shlex.quote(str(home))} claude` and type /login there, once"
def only_signed_out(reason: str) -> bool:
"""Whether a reason `unready` gave is that nobody has signed in yet, which is typed away in a claude that runs in the home."""
return reason.startswith(SIGNED_OUT)
def signed_in(status: str) -> bool | None: def signed_in(status: str) -> bool | None:
"""Whether `claude auth status` printed that someone is signed in, by a /login or by a token in the environment; None where it printed no such answer.""" """Whether `claude auth status` printed that someone is signed in, by a /login or by a token in the environment; None where it printed no such answer."""
try: try:
+3 -1
View File
@@ -8,7 +8,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from failure import Failure from failure import Failure
from claude_home.home import unready from claude_home.home import only_signed_out, unready
SETTINGS = { SETTINGS = {
"enabledPlugins": {"code-review@official": True, "frontend-design@official": False, "lsp@other": True}, "enabledPlugins": {"code-review@official": True, "frontend-design@official": False, "lsp@other": True},
@@ -141,6 +141,7 @@ class Home(unittest.TestCase):
self.status = SIGNED_OUT self.status = SIGNED_OUT
self.assertEqual(self.unready(), f"nobody is signed in to the loop's Claude home; run `CLAUDE_CONFIG_DIR={self.home} claude` and type /login there, once") self.assertEqual(self.unready(), f"nobody is signed in to the loop's Claude home; run `CLAUDE_CONFIG_DIR={self.home} claude` and type /login there, once")
self.assertTrue(only_signed_out(self.unready() or ""))
def test_a_status_that_says_nobody_is_signed_in_or_out_quotes_what_claude_said(self) -> None: def test_a_status_that_says_nobody_is_signed_in_or_out_quotes_what_claude_said(self) -> None:
for stdout, stderr, said in (("", "Error: the settings\nare broken\n", "Error: the settings are broken"), ("Not logged in\n", "", "Not logged in"), ('{"authMethod": "none"}', "", '{"authMethod": "none"}'), ("3", "", "3"), ('{"loggedIn": "yes"}', "", '{"loggedIn": "yes"}'), ("", "", "it printed nothing and exited 1")): for stdout, stderr, said in (("", "Error: the settings\nare broken\n", "Error: the settings are broken"), ("Not logged in\n", "", "Not logged in"), ('{"authMethod": "none"}', "", '{"authMethod": "none"}'), ("3", "", "3"), ('{"loggedIn": "yes"}', "", '{"loggedIn": "yes"}'), ("", "", "it printed nothing and exited 1")):
@@ -192,6 +193,7 @@ class Home(unittest.TestCase):
reason = unready(self.home, self.clone, self.reports, missing, lambda *args, cwd=None: "1a2b3c\n") reason = unready(self.home, self.clone, self.reports, missing, lambda *args, cwd=None: "1a2b3c\n")
self.assertEqual(reason, f"could not build the loop's Claude home, {self.home}: [Errno 2] No such file or directory: 'claude'") self.assertEqual(reason, f"could not build the loop's Claude home, {self.home}: [Errno 2] No such file or directory: 'claude'")
self.assertFalse(only_signed_out(reason))
def test_a_claude_that_is_stopped_after_its_time_stops(self) -> None: def test_a_claude_that_is_stopped_after_its_time_stops(self) -> None:
def stalled(args: list[str]) -> subprocess.CompletedProcess[str]: def stalled(args: list[str]) -> subprocess.CompletedProcess[str]:
+8 -6
View File
@@ -2,15 +2,17 @@ import pathlib
import sys import sys
from loop_effects.effects import Effects from loop_effects.effects import Effects
from claude_home.home import SIGNED_OUT from claude_home.home import only_signed_out
# The spelling, a command of its own beside build-release: a panel of readers seated as the README's audience rejected `build-release claude`, since build-release reads every word after its name as a task, so a task that starts with "claude" would mean something else. They picked the name that opens with the word they look for. # A command of its own, since `build-release claude` would take a task that starts with "claude" for this command.
def main(argv: list[str], cwd: pathlib.Path, effects: Effects) -> int: def main(argv: list[str], cwd: pathlib.Path, effects: Effects) -> int:
"""Runs claude on the terminal in cwd with argv as its arguments, in the loop's Claude home with the release's tools first on `PATH`, which the effect sets for every claude it starts. Returns claude's exit code, or 1 where the home cannot be built.""" """Runs claude on the terminal in cwd with argv as its arguments, in the loop's Claude home. Returns claude's exit code as a shell reports it, or 1 where the home isn't ready for a reason other than a missing sign-in."""
not_ready = effects.claude_home() not_ready = effects.claude_home()
# Where nobody has signed in yet, the login is typed in this claude. # A missing sign-in doesn't stop it: the login is typed in this claude.
if not_ready and not not_ready.startswith(SIGNED_OUT): if not_ready and not only_signed_out(not_ready):
print(not_ready, file=sys.stderr) print(not_ready, file=sys.stderr)
return 1 return 1
return effects.claude_on_terminal(argv, str(cwd), {}) code = effects.claude_on_terminal(argv, str(cwd), {})
# subprocess reports a claude that a signal ended as minus the signal's number, which sys.exit would turn into 256 minus it.
return 128 - code if code < 0 else code
+4 -1
View File
@@ -21,7 +21,7 @@ class ClaudeRelease(unittest.TestCase):
fake = FakeEffects(on_terminal_claude=[0]) fake = FakeEffects(on_terminal_claude=[0])
code, err = self.run_main(["--resume", "abc", "--model", "opus", "-p", "hi"], fake) code, err = self.run_main(["--resume", "abc", "--model", "opus", "-p", "hi"], fake)
self.assertEqual((code, err, fake.made("claude_on_terminal"), fake.terminal_folders), (0, "", [["--resume", "abc", "--model", "opus", "-p", "hi"]], ["/project"])) self.assertEqual((code, err, fake.made("claude_on_terminal"), fake.terminal_folders), (0, "", [["--resume", "abc", "--model", "opus", "-p", "hi"]], ["/project"]))
# The effect adds the home and the tools' PATH to the environment; the command adds nothing of its own. # The effect adds the home and the tools' PATH to the environment; the command doesn't add anything.
self.assertEqual(fake.terminal_environments, [{}]) self.assertEqual(fake.terminal_environments, [{}])
def test_exits_with_the_code_of_claude(self): def test_exits_with_the_code_of_claude(self):
@@ -32,6 +32,9 @@ class ClaudeRelease(unittest.TestCase):
fake.home_unready = f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR=/h claude` and type /login there, once" fake.home_unready = f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR=/h claude` and type /login there, once"
self.assertEqual((self.run_main([], fake)[0], len(fake.made("claude_on_terminal"))), (0, 1)) self.assertEqual((self.run_main([], fake)[0], len(fake.made("claude_on_terminal"))), (0, 1))
def test_exits_as_a_shell_reports_a_claude_that_a_signal_ended(self):
self.assertEqual(self.run_main([], FakeEffects(on_terminal_claude=[-15]))[0], 143)
def test_stops_where_the_home_cannot_be_built(self): def test_stops_where_the_home_cannot_be_built(self):
fake = FakeEffects() fake = FakeEffects()
fake.home_unready = "could not build the loop's Claude home, /h: disk full" fake.home_unready = "could not build the loop's Claude home, /h: disk full"