From 6a5ed356a24ab081979cb911efd9431386bee68d Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Tue, 24 Nov 2026 13:32:13 -0700 Subject: [PATCH] A lead waiting on a delegation that is open and not late is not stopped for checks without a verdict Co-Authored-By: Claude Sonnet 5.5 --- sisi/hooks.py | 2 +- sisi/models.py | 5 +++++ tests/test_core.py | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/sisi/hooks.py b/sisi/hooks.py index b657ea1..0f99777 100644 --- a/sisi/hooks.py +++ b/sisi/hooks.py @@ -208,7 +208,7 @@ def gate(p, for_subagent=False): from . import retro retro.record(s, cwd, {}) # every check passed and nothing changed: the work closes itself return 0 - reason = OPEN % "; ".join(unsaid) if unsaid else GATE if worked else FAILED % ", ".join(failed) if failed else "" + reason = "" if unsaid and models.waiting(s) else OPEN % "; ".join(unsaid) if unsaid else GATE if worked else FAILED % ", ".join(failed) if failed else "" if not reason or s.get("blocks", 0) >= 2: return 0 s["blocks"] = s.get("blocks", 0) + 1 diff --git a/sisi/models.py b/sisi/models.py index cf7ef04..c11ab93 100644 --- a/sisi/models.py +++ b/sisi/models.py @@ -141,6 +141,11 @@ def overdue(s): return [(w, min(old(v))) for w, v in (starts.items() if isinstance(starts, dict) and type(mins) in (int, float) else []) if old(v)] +def waiting(s): + """A delegation of this piece of work is open: started and not yet judged.""" + return isinstance(s.get("starts"), dict) and any(isinstance(v, list) and v for v in s["starts"].values()) + + def out(r, skip, bad, today): """Why this worker is off the wheel, "" when it is on.""" until = [d for d in re.findall(r"out until (\d{4}-\d{2}-\d{2})", " ".join(r).lower()) if d > today] diff --git a/tests/test_core.py b/tests/test_core.py index f9c7858..9c4a589 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1428,6 +1428,27 @@ class Core(unittest.TestCase): self.assertEqual(self.sisi("judge", "sonnet", "bad", "cancelled, never reported", sid="s1")[0], 0) self.assertFalse(late()) + def test_a_lead_waiting_on_a_worker_that_is_not_late_is_not_stopped_for_open_checks(self): + self.table(WORKERS) + self.hook("tick") + self.hook("prompt", prompt="go") + self.done() + self.assertIn("no verdict yet", self.hook("gate")[1]) # no delegation open: blocked as before + self.assertEqual(self.sisi("pick", "hard", sid="s1")[0], 0) + self.assertEqual(self.tool("Agent", tool_input={"model": "sonnet"})[0], 0) + for turn in range(5): # each wake-up of the lead is a request + self.hook("prompt", prompt="the delegated task finished %d" % turn) + self.assertEqual(self.hook("gate")[1], "", turn) # started, not judged, not late: waiting + with open(os.path.join(self.tmp, "state", "core-sessions", "s1.json"), "r+") as f: + st = json.load(f) + st["starts"]["sonnet"] = [time.time() - 16 * 60] + f.seek(0), f.truncate(), json.dump(st, f) + self.hook("prompt", prompt="still nothing") + self.assertIn("has not reported", self.hook("gate")[1]) # late: the LATE message as before + self.assertEqual(self.sisi("judge", "sonnet", "good", "reported and was checked", sid="s1")[0], 0) + self.hook("prompt", prompt="judged") + self.assertIn("no verdict yet", self.hook("gate")[1]) # judged: no delegation open again + def test_the_spec_is_unchanged(self): for line in self.read(REPO, "docs", "spec", "SHA256SUMS").splitlines(): digest, rel = line.split()