Plan graph before delegating: sisi plan, pick --node, deny delegations outside the plan, gate on ready nodes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-12-02 08:59:35 -07:00
1 parent 25b5e90c6b
commit cadae3cc8c
8 files changed
+753 -35

No files matched your search

+18 -13
View File
@@ -48,6 +48,8 @@ REAL_HOME = os.path.expanduser("~")
class Core(unittest.TestCase):
ENFORCE = False
def setUp(self):
before = tree()
self.addCleanup(lambda: self.assertEqual(tree(), before, "a test wrote into the product tree"))
@@ -72,6 +74,9 @@ class Core(unittest.TestCase):
for name in ("SISI_SESSION_ID", "CLAUDE_ENV_FILE", "XDG_DATA_HOME", "XDG_STATE_HOME", "CODEX_HOME"):
self.env.pop(name, None)
self.proj = self.project("alpha")
if not self.ENFORCE: # these tests hold the reminders; tests/test_plan.py holds the denials
os.makedirs(self.data, exist_ok=True)
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False}}))
def project(self, name):
path = os.path.join(self.tmp, name)
@@ -1204,7 +1209,7 @@ class Core(unittest.TestCase):
self.assertNotIn("could not be recorded", out, (rnd, out))
self.assertNotIn("commit failed", out, (rnd, out))
self.assertFalse(os.path.exists(old_c), rnd)
dirty = [l for l in subprocess.run(["git", "status", "--porcelain"], cwd=self.data, capture_output=True, text=True, check=True).stdout.splitlines() if not l.startswith(("?? generated/", "?? locks/"))]
dirty = [l for l in subprocess.run(["git", "status", "--porcelain"], cwd=self.data, capture_output=True, text=True, check=True).stdout.splitlines() if not l.startswith(("?? generated/", "?? locks/", "?? config.json"))]
self.assertEqual(dirty, [], rnd)
def test_concurrent_learns_hold_project_lock_through_store_commit(self):
@@ -2215,7 +2220,7 @@ cli.main(["tick"])
def test_a_worker_called_from_the_shell_is_never_marked_unknown(self):
marker = self.lead(WORKERS)
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"shell_workers": True}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "shell_workers": True}}))
err = self.note(self.tool("Bash", tool_input={"command": 'opencode run -m other/model "fix the login bug in auth.py"'}))
self.assertEqual(("the wheel did not give you" in err, os.path.exists(marker)), (True, False))
self.assertNotIn("login bug", self.hook("tick", sid="s2")[1])
@@ -2265,7 +2270,7 @@ cli.main(["tick"])
self.assertIn("do not shell out to a worker", self.note(self.tool("Bash", tool_input=shell))) # warned even with a pick
self.assertEqual(self.sisi("pick", "ordinary", sid="s1")[0], 0)
self.assertEqual(self.tool("mcp__t3__delegate_task", tool_input={"target": {"model": "zai-coding-plan/glm-5.4"}}), (0, "", ""))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"shell_workers": True}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "shell_workers": True}}))
self.assertIn("opencode run -m zai-coding-plan/glm-5.4", self.sisi("pick", "ordinary", sid="s1")[1])
self.assertIn("the wheel did not give you", self.note(self.tool("Bash", tool_input={"command": 'opencode run -m other/model "x"'})))
self.assertEqual(self.tool("Bash", tool_input=shell), (0, "", ""))
@@ -2813,11 +2818,11 @@ cli.main(["tick"])
bash = lambda c: self.tool("Bash", tool_input={"command": c})
err = self.note(bash('opencode run -m x "y"')) # a shell worker before done
self.assertEqual(("do not shell out" in err, "sisi done --goal" in err), (True, True))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"shell_workers": True}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "shell_workers": True}}))
err = self.note(bash('opencode run -m x "y"'))
self.assertEqual(("sisi done --goal" in err, "do not shell out" in err), (True, False))
self.done()
os.remove(os.path.join(self.data, "config.json"))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False}}))
for c in ('cd /tmp && opencode run -m x "y"', 'nohup opencode run -m x "y" &', 'echo x; opencode run -m x "y"',
'FOO=1 env time /usr/bin/agy --print "y"', 'ls | agy --print "y"'):
self.assertIn("do not shell out", self.note(bash(c)), c)
@@ -3056,7 +3061,7 @@ cli.main(["tick"])
self.assertNotIn("changed things", out)
def test_sisi_with_quoted_operators_is_free_and_real_operators_are_not(self):
self.write(self.mkdir(self.data) + "/config.json", json.dumps({"core": {"direct_calls": 0}}))
self.write(self.mkdir(self.data) + "/config.json", json.dumps({"core": {"enforce": False, "direct_calls": 0}}))
self.hook("tick")
self.hook("prompt", prompt="go")
bash = lambda c: self.tool("Bash", tool_input={"command": c})
@@ -3132,7 +3137,7 @@ cli.main(["tick"])
def test_the_gate_blocks_on_a_worker_that_was_started_and_never_reported(self):
self.table(WORKERS)
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"worker_minutes": 15}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "worker_minutes": 15}}))
self.hook("tick")
self.hook("prompt", prompt="go")
self.done()
@@ -3196,7 +3201,7 @@ cli.main(["tick"])
def test_retro_row_records_session_id_and_demand_to_record_seconds(self):
self.table(WORKERS)
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"worker_minutes": 15}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "worker_minutes": 15}}))
self.hook("tick")
self.hook("prompt", prompt="go")
self.done()
@@ -3294,7 +3299,7 @@ cli.main(["tick"])
def test_a_lead_waiting_on_a_worker_that_is_not_late_is_not_stopped_for_open_checks(self):
self.table(WORKERS)
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"worker_minutes": 15}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "worker_minutes": 15}}))
self.hook("tick")
self.hook("prompt", prompt="go")
self.done()
@@ -3341,7 +3346,7 @@ cli.main(["tick"])
self.assertIn("no retro yet", work("f", -1)) # a clock that went backwards: the retro
self.assertIn("no retro yet", work("d", 4, delegate=True)) # a delegation: the retro
self.assertEqual(len(self.records()), 1)
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"retro_minutes": 10}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "retro_minutes": 10}}))
self.assertEqual(work("e", 6), "") # the limit is a setting
self.assertEqual(len(self.records()), 2)
@@ -3387,7 +3392,7 @@ cli.main(["tick"])
self.hook("tick", sid="w1")
self.hook("prompt", sid="w1", prompt="You are a worker. Do this task yourself.")
self.assertEqual(self.hook("gate", sid="w1")[1], "") # worker skipped
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"gate": False}}))
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"enforce": False, "gate": False}}))
self.assertEqual(self.hook("gate", sid="s2")[1], "") # gate setting off
def test_faults_shown_on_tick_prompt_retro_meter_free_and_scoped_to_project(self):
@@ -3414,7 +3419,7 @@ cli.main(["tick"])
self.assertIn("linker crashed ten times", rep)
self.assertIn("scratch folder filled up", rep)
# meter lets `sisi fault ...` through even with direct_calls=0
self.write(self.mkdir(self.data) + "/config.json", json.dumps({"core": {"direct_calls": 0}}))
self.write(self.mkdir(self.data) + "/config.json", json.dumps({"core": {"enforce": False, "direct_calls": 0}}))
self.assertEqual(self.tool("Bash", sid="s2", tool_input={"command": 'sisi fault "new crash in test runner"'})[0], 0)
# a different project's faults are not shown or gated
beta = self.project("beta")
@@ -3684,7 +3689,7 @@ cli.main(["tick"])
wt5 = self.mkdir(p5, ".git", "worktrees")
for i in range(10):
self.mkdir(wt5, "w%d" % i)
self.write(self.mkdir(self.data) + "/config.json", json.dumps({"core": {"disk_free_percent": 0, "disk_drop_percent": 0, "checkouts": 0}}))
self.write(self.mkdir(self.data) + "/config.json", json.dumps({"core": {"enforce": False, "disk_free_percent": 0, "disk_drop_percent": 0, "checkouts": 0}}))
self.env["SISI_TEST_STATVFS"] = "1000000000000:50000000000"
self.assertEqual(self.hook("prompt", sid="off1", cwd=p5, prompt="all off")[1], "")
self.assertIn("no open faults", self.sisi("fault", cwd=p5)[1])