Name a signal kill, match the judge's retry line, state worker failure in --help
This commit is contained in:
+9
-5
@@ -11,9 +11,10 @@ An unfinished chunk resumes the same session next cycle; a finished one starts a
|
||||
Cycles continue until that interrupt or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary".
|
||||
|
||||
Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, or the worker or
|
||||
the judge fails three times running. A judge fails when its verdict misses a field or quotes nothing
|
||||
in the transcript. Exit 2: the human is needed and stdin or stdout is not a terminal, or the
|
||||
interrupt ended without them typing anything. Rerunning resumes any open session.
|
||||
the judge fails three times running. A worker fails when claude exits non-zero, is killed, or ends
|
||||
without a result event; a judge when its verdict misses a field or quotes nothing in the transcript.
|
||||
Exit 2: the human is needed and stdin or stdout is not a terminal, or the interrupt ended without
|
||||
them typing anything. Rerunning resumes any open session.
|
||||
|
||||
Each project has one session, "A <path> loop-claude", <path> being the checkout relative to ~/code,
|
||||
or to / outside it, deleted when the chunk finishes. Its transcript is archived under
|
||||
@@ -271,7 +272,10 @@ def run_worker(args):
|
||||
for part in event.get("message", {}).get("content", []):
|
||||
if line := said(part, 160):
|
||||
print(line, flush=True)
|
||||
if code := proc.wait():
|
||||
code = proc.wait()
|
||||
if code < 0:
|
||||
return f"claude killed by signal {-code}"
|
||||
if code:
|
||||
return f"claude exited {code}"
|
||||
return "" if done else "claude exited 0 without a result event"
|
||||
|
||||
@@ -386,7 +390,7 @@ def main():
|
||||
failures += 1
|
||||
if failures == 3:
|
||||
sys.exit(f"the worker failed three times running: {failure}")
|
||||
print(f"the worker failed: {failure} - retrying in a minute", file=sys.stderr)
|
||||
print(f"retrying the worker in a minute: {failure}", file=sys.stderr)
|
||||
time.sleep(60)
|
||||
|
||||
|
||||
|
||||
@@ -283,10 +283,11 @@ class RunWorker(unittest.TestCase):
|
||||
"": 'print(json.dumps({"type": "result"}))',
|
||||
"claude exited 0 without a result event": 'print(json.dumps({"type": "assistant", "message": {"content": [{"type": "text", "text": "worked"}]}}))',
|
||||
"claude exited 3": "sys.exit(3)",
|
||||
"claude killed by signal 9": "os.kill(os.getpid(), 9)",
|
||||
}
|
||||
with unittest.mock.patch.dict(os.environ, {"PATH": f"{bin}:{os.environ['PATH']}"}), unittest.mock.patch.object(sys, "stdout", io.StringIO()):
|
||||
for failure, script in scripts.items():
|
||||
open(stub, "w").write(f"#!/usr/bin/env python3\nimport json\nimport sys\n{script}\n")
|
||||
open(stub, "w").write(f"#!/usr/bin/env python3\nimport json\nimport os\nimport sys\n{script}\n")
|
||||
os.chmod(stub, 0o700)
|
||||
self.assertEqual(loop.run_worker([]), failure)
|
||||
|
||||
@@ -360,7 +361,7 @@ class Main(unittest.TestCase):
|
||||
sleep = stack.enter_context(unittest.mock.patch("time.sleep"))
|
||||
with self.assertRaises(SystemExit) as stopped:
|
||||
loop.main()
|
||||
self.assertIn("the worker failed: claude exited 3 - retrying in a minute", sys.stderr.getvalue())
|
||||
self.assertIn("retrying the worker in a minute: claude exited 3", sys.stderr.getvalue())
|
||||
self.assertEqual(sleep.call_count, 2)
|
||||
self.assertEqual(stopped.exception.code, "the worker failed three times running: claude exited 3")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user