Gate: a turn may end while only a lead-class node is ready
The lead's own join node no longer blocks the end of turn; worker nodes ready and undispatched still block. The lead may be waiting on its own background job. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9ae16c17d0
commit
caefb1eaa6
3 files changed
+15
-7
No files matched your search
+4
-2
@@ -271,10 +271,12 @@ def gate(p, for_subagent=False):
|
|||||||
if isinstance(x, list) and len(x) == 2 and x[1] in (starts.get(x[0]) if isinstance(starts.get(x[0]), list) else ())]
|
if isinstance(x, list) and len(x) == 2 and x[1] in (starts.get(x[0]) if isinstance(starts.get(x[0]), list) else ())]
|
||||||
late = models.overdue({"starts": {w: [t for t in v if [w, t] not in seen] for w, v in starts.items() if isinstance(v, list)}, "meta": s.get("meta")})
|
late = models.overdue({"starts": {w: [t for t in v if [w, t] not in seen] for w, v in starts.items() if isinstance(v, list)}, "meta": s.get("meta")})
|
||||||
reason, demand = " ".join("sisi: " + LATE % (w, time.strftime("%H:%M", time.localtime(t))) for w, t in late), False
|
reason, demand = " ".join("sisi: " + LATE % (w, time.strftime("%H:%M", time.localtime(t))) for w, t in late), False
|
||||||
if not reason and isinstance(s.get("plan"), dict): # ready nodes not started: dispatch them before the turn ends
|
held = False
|
||||||
|
if not reason and isinstance(s.get("plan"), dict): # ready worker nodes not started: dispatch them before the turn ends
|
||||||
from . import plan
|
from . import plan
|
||||||
reason = plan.gate(s)
|
reason = plan.gate(s)
|
||||||
if not reason and not s.get("paused"):
|
held = not reason and bool(plan.ready(plan.get(s) or {"nodes": []})) # only a lead node is ready: the lead may be waiting on its own job
|
||||||
|
if not reason and not s.get("paused") and not held:
|
||||||
checks = (s.get("done") or {}).get("checks") or []
|
checks = (s.get("done") or {}).get("checks") or []
|
||||||
unsaid = ["%d. %s" % (i, c["text"]) for i, c in enumerate(checks, 1) if not c["verdict"]]
|
unsaid = ["%d. %s" % (i, c["text"]) for i, c in enumerate(checks, 1) if not c["verdict"]]
|
||||||
failed = [str(i) for i, c in enumerate(checks, 1) if c["verdict"] == "fail"]
|
failed = [str(i) for i, c in enumerate(checks, 1) if c["verdict"] == "fail"]
|
||||||
|
|||||||
+1
-3
@@ -331,13 +331,11 @@ def concurrent(s, i):
|
|||||||
|
|
||||||
|
|
||||||
def gate(s):
|
def gate(s):
|
||||||
"""End of turn: the ready nodes not started, as a message, or ""."""
|
"""End of turn: the ready worker nodes not started, as a message, or ""."""
|
||||||
p = get(s)
|
p = get(s)
|
||||||
rd = ready(p) if p else []
|
rd = ready(p) if p else []
|
||||||
go = [i for i in rd if node(p, i)["cls"] != "lead"]
|
go = [i for i in rd if node(p, i)["cls"] != "lead"]
|
||||||
if go:
|
if go:
|
||||||
return "sisi: nodes %s are ready and not started: pick and dispatch them all now in one message (%s)." % (
|
return "sisi: nodes %s are ready and not started: pick and dispatch them all now in one message (%s)." % (
|
||||||
", ".join(go), " ".join("`sisi pick --node %s`" % i for i in go))
|
", ".join(go), " ".join("`sisi pick --node %s`" % i for i in go))
|
||||||
if rd:
|
|
||||||
return "sisi: node %s is yours and ready: %s. Do it, then `sisi plan --done %s \"<evidence>\"`." % (rd[0], node(p, rd[0])["check"], rd[0])
|
|
||||||
return ""
|
return ""
|
||||||
+10
-2
@@ -579,12 +579,20 @@ class Plan(unittest.TestCase):
|
|||||||
self.assertEqual(self.decision(self.agent(m, self.pick_header(n))), {})
|
self.assertEqual(self.decision(self.agent(m, self.pick_header(n))), {})
|
||||||
self.assertEqual(self.hook("gate")[1], "")
|
self.assertEqual(self.hook("gate")[1], "")
|
||||||
|
|
||||||
def test_gate_names_the_lead_join_when_only_it_is_ready(self):
|
def test_gate_lets_the_turn_end_when_only_the_lead_join_is_ready(self):
|
||||||
self.ready_plan()
|
self.ready_plan()
|
||||||
for n in ("a", "b", "c"):
|
for n in ("a", "b", "c"):
|
||||||
self.assertEqual(self.sisi("plan", "--done", n, "done by hand and tested", sid="s1")[0], 0)
|
self.assertEqual(self.sisi("plan", "--done", n, "done by hand and tested", sid="s1")[0], 0)
|
||||||
out = self.hook("gate")[1]
|
out = self.hook("gate")[1]
|
||||||
self.assertIn("node join is yours and ready: full suite passes", out)
|
self.assertNotIn('"block"', out)
|
||||||
|
|
||||||
|
def test_gate_still_blocks_on_a_ready_worker_node_beside_a_ready_lead_node(self):
|
||||||
|
self.ready_plan()
|
||||||
|
self.assertEqual(self.sisi("plan", "--done", "c", "done by hand and tested", sid="s1")[0], 0)
|
||||||
|
self.assertEqual(self.sisi("plan", "--done", "a", "done by hand and tested", sid="s1")[0], 0)
|
||||||
|
out = self.hook("gate")[1]
|
||||||
|
self.assertIn('"block"', out)
|
||||||
|
self.assertIn("nodes b are ready and not started", out)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in new issue
Block a user