Answer product-owner round 2: 0 🔴, 1 🟡 (0 misread); judge a shell again once it used CPU and went idle, retry a failed judgment, and name a process without a command line
This commit is contained in:
@@ -29,10 +29,12 @@ def sign(run, quiet, idle=True):
|
||||
|
||||
|
||||
class StuckWorkers(unittest.TestCase):
|
||||
def worker_with(self, *events, held=(), replies=(), archive=None):
|
||||
"""Runs a worker whose claude prints events and holds the shells held, while each investigation replies in turn; returns the claude, the fake, what was said on stdout and stderr and the record's text. The archive folder is archive, or else one that doesn't exist yet, as for a project's first stop."""
|
||||
def worker_with(self, *events, held=(), replies=(), archive=None, each_check=None):
|
||||
"""Runs a worker whose claude prints events and holds the shells held, while each investigation replies in turn; returns the claude, the fake, what was said on stdout and stderr and the record's text. The archive folder is archive, or else one that doesn't exist yet, as for a project's first stop. Where each_check is given, each check finds the next of its shells alone."""
|
||||
clock = [NOW]
|
||||
streamed = Streamed(0, *events, clock=clock, held=held)
|
||||
if each_check:
|
||||
streamed.shells = lambda: [each_check.pop(0)]
|
||||
fake = FakeEffects(streams=[streamed], claude=replies)
|
||||
effects = dataclasses.replace(fake.effects(), now=lambda: clock[0])
|
||||
with tempfile.TemporaryDirectory() as folder, contextlib.redirect_stdout(io.StringIO()) as said, contextlib.redirect_stderr(io.StringIO()) as failed:
|
||||
@@ -53,6 +55,25 @@ class StuckWorkers(unittest.TestCase):
|
||||
self.assertEqual(record, f"- {utc(NOW + 600)} {line}\n")
|
||||
self.assertEqual(streamed.stopped, [])
|
||||
|
||||
def test_a_judged_shell_is_judged_again_only_after_it_used_cpu_and_went_idle_once_more(self):
|
||||
cpu = [2.0, 2.0, 2.0, 3.0, 3.0]
|
||||
_, fake, _, _, record = self.worker_with(ASSISTANT, *[None] * 5, each_check=[shell(cpu=each) for each in cpu], replies=[verdict("working", 8, "the tests run"), verdict()])
|
||||
self.assertEqual(len(fake.made("claude")), 2)
|
||||
self.assertEqual([line.split(" ")[1] for line in record.splitlines() if line.startswith("- ")], [utc(NOW + 600), utc(NOW + 1500)])
|
||||
|
||||
def test_an_old_shell_that_keeps_using_cpu_is_judged_once(self):
|
||||
_, fake, _, _, _ = self.worker_with(ASSISTANT, None, None, None, each_check=[shell(cpu=each, started=NOW - stuck_workers.OLD) for each in (2.0, 3.0, 4.0)], replies=[verdict()])
|
||||
self.assertEqual(len(fake.made("claude")), 1)
|
||||
|
||||
def test_a_shell_whose_investigation_failed_is_judged_at_the_next_check(self):
|
||||
_, fake, said, _, _ = self.worker_with(ASSISTANT, None, None, None, held=[shell()], replies=[ran(code=1, stderr="no model"), verdict()])
|
||||
self.assertEqual(len(fake.made("claude")), 2)
|
||||
self.assertIn(f"<{NOW + 900}> stuck check: a headless claude judged the worker stuck", said)
|
||||
|
||||
def test_a_named_process_without_a_command_line_is_said_so(self):
|
||||
_, _, said, _, _ = self.worker_with(ASSISTANT, None, None, held=[shell(processes=("8 Z 0.0 s ",))], replies=[verdict()])
|
||||
self.assertIn("naming process 8 (no command line):", said)
|
||||
|
||||
def test_hands_the_investigation_none_for_a_shell_without_processes_or_output(self):
|
||||
_, fake, _, _, _ = self.worker_with(ASSISTANT, None, None, held=[shell(processes=(), output="")], replies=[verdict()])
|
||||
[(_, prompt)] = fake.made("claude")
|
||||
|
||||
Reference in New Issue
Block a user