diff --git a/sisi/hooks.py b/sisi/hooks.py index 937d303..8f0b212 100644 --- a/sisi/hooks.py +++ b/sisi/hooks.py @@ -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 ())] 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 - 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 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 [] 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"] diff --git a/sisi/plan.py b/sisi/plan.py index 4fa3a1e..db1759e 100644 --- a/sisi/plan.py +++ b/sisi/plan.py @@ -331,13 +331,11 @@ def concurrent(s, i): 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) rd = ready(p) if p else [] go = [i for i in rd if node(p, i)["cls"] != "lead"] if go: 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)) - if rd: - return "sisi: node %s is yours and ready: %s. Do it, then `sisi plan --done %s \"\"`." % (rd[0], node(p, rd[0])["check"], rd[0]) return "" diff --git a/tests/test_plan.py b/tests/test_plan.py index ae0891e..3d166ee 100644 --- a/tests/test_plan.py +++ b/tests/test_plan.py @@ -579,12 +579,20 @@ class Plan(unittest.TestCase): self.assertEqual(self.decision(self.agent(m, self.pick_header(n))), {}) 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() for n in ("a", "b", "c"): self.assertEqual(self.sisi("plan", "--done", n, "done by hand and tested", sid="s1")[0], 0) 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__":