Chore briefs carry a one-time id: delegate the first line, worker prints the brief by id
This commit is contained in:
1 parent
62e79b8342
commit
8aa79ab492
5 files changed
+123
-29
No files matched your search
+92
-2
@@ -158,7 +158,7 @@ class Plan(unittest.TestCase):
|
||||
self.ready_plan()
|
||||
rc, out, _ = self.sisi("plan", "brief", sid="s1")
|
||||
self.assertEqual(rc, 0, out)
|
||||
self.assertEqual(out.splitlines()[0], "sisi chore: plan")
|
||||
self.assertRegex(out.splitlines()[0], r"^sisi chore: plan [0-9a-f]{8}$")
|
||||
for want in ("export every row without losing any", "1. row counts match", "| node | class | needs | branch | files | check | why |",
|
||||
"Class by total cost", "routine nodes whenever their", "record (last 20 judged per class)"):
|
||||
self.assertIn(want, out)
|
||||
@@ -283,11 +283,101 @@ class Plan(unittest.TestCase):
|
||||
self.hook("prompt", prompt="tidy up")
|
||||
for args, line in ((("rules", "organize"), "sisi chore: rules organize"), (("models", "research"), "sisi chore: models research")):
|
||||
rc, brief, _ = self.sisi(*args, sid="s1")
|
||||
self.assertEqual((rc, brief.splitlines()[0]), (0, line))
|
||||
self.assertEqual(rc, 0, brief)
|
||||
self.assertRegex(brief.splitlines()[0], r"^%s [0-9a-f]{8}$" % line)
|
||||
self.assertEqual(self.sisi("pick", "routine", sid="s1")[0], 0)
|
||||
self.assertNotIn("permissionDecision", self.decision(self.agent("alpha", brief)), line)
|
||||
self.assertEqual(self.state()["chores"], [])
|
||||
|
||||
def chore_id(self, brief):
|
||||
return brief.splitlines()[0].rsplit(" ", 1)[-1]
|
||||
|
||||
def short_brief(self, brief):
|
||||
return brief.splitlines()[0] + "\nRun `sisi chore show %s` and do what it says." % self.chore_id(brief)
|
||||
|
||||
def test_a_chore_id_is_issued_and_printed_on_the_first_line(self):
|
||||
self.table(TABLE)
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("plan", "brief", sid="s1")[1]
|
||||
cid = self.chore_id(brief)
|
||||
self.assertRegex(cid, r"^[0-9a-f]{8}$")
|
||||
self.assertIn(cid, [x[3] for x in self.state()["chores"]])
|
||||
|
||||
def test_a_short_delegation_with_the_id_passes_once(self):
|
||||
self.table(TABLE)
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("plan", "brief", sid="s1")[1]
|
||||
self.assertEqual(self.sisi("pick", "hard", sid="s1")[0], 0)
|
||||
self.assertEqual(self.decision(self.agent("gamma", self.short_brief(brief))), {})
|
||||
self.assertEqual(self.state().get("chores"), [])
|
||||
|
||||
def test_a_reused_chore_id_is_denied(self):
|
||||
self.table(TABLE)
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("plan", "brief", sid="s1")[1]
|
||||
self.assertEqual(self.sisi("pick", "hard", sid="s1")[0], 0)
|
||||
self.assertEqual(self.decision(self.agent("gamma", self.short_brief(brief))), {})
|
||||
self.assertEqual(self.sisi("pick", "hard", sid="s1")[0], 0)
|
||||
self.denied(self.agent("gamma", self.short_brief(brief)), "is not one sisi printed in this session")
|
||||
|
||||
def test_a_wrong_chore_id_is_denied(self):
|
||||
self.table(TABLE)
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("plan", "brief", sid="s1")[1]
|
||||
cid = self.chore_id(brief)
|
||||
wrong = ("0" if cid[0] != "0" else "1") + cid[1:]
|
||||
self.assertEqual(self.sisi("pick", "hard", sid="s1")[0], 0)
|
||||
why = self.denied(self.agent("gamma", "sisi chore: plan %s\nRun `sisi chore show %s` and do what it says." % (wrong, wrong)),
|
||||
"is not one sisi printed in this session")
|
||||
self.assertIn("sisi plan brief", why)
|
||||
|
||||
def test_another_sessions_chore_id_is_denied(self):
|
||||
self.table(TABLE)
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("plan", "brief", sid="s1")[1]
|
||||
self.hook("prompt", sid="s2", prompt="build it")
|
||||
self.done(sid="s2")
|
||||
self.assertEqual(self.sisi("pick", "hard", sid="s2")[0], 0)
|
||||
self.denied(self.agent("gamma", self.short_brief(brief), sid="s2"), "is not one sisi printed in this session")
|
||||
|
||||
def test_chore_show_prints_the_brief_and_unknown_id_fails(self):
|
||||
self.table(TABLE)
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("plan", "brief", sid="s1")[1]
|
||||
cid = self.chore_id(brief)
|
||||
rc, out, _ = self.sisi("chore", "show", cid, sid="s2")
|
||||
self.assertEqual(rc, 0, out)
|
||||
self.assertEqual(out, brief)
|
||||
rc, out, _ = self.sisi("chore", "show", "deadbeef")
|
||||
self.assertEqual(rc, 1, out)
|
||||
self.assertIn("deadbeef", out)
|
||||
|
||||
def test_a_full_text_delegation_with_the_id_still_passes(self):
|
||||
self.table(TABLE)
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("plan", "brief", sid="s1")[1]
|
||||
self.assertEqual(self.sisi("pick", "hard", sid="s1")[0], 0)
|
||||
self.assertEqual(self.decision(self.agent("gamma", brief)), {})
|
||||
self.assertEqual(self.state().get("chores"), [])
|
||||
|
||||
def test_a_shell_worker_may_carry_the_id_line_on_any_line(self):
|
||||
self.table(test_core.WORKERS)
|
||||
self.write(os.path.join(self.data, "config.json"), json.dumps({"core": {"shell_workers": True, "enforce": True}}))
|
||||
self.hook("prompt", prompt="build it")
|
||||
self.done()
|
||||
brief = self.sisi("models", "research", sid="s1")[1]
|
||||
self.assertEqual(self.sisi("pick", "routine", sid="s1")[0], 0)
|
||||
d = self.decision(self.tool("Bash", tool_input={"command": 'agy --print "\n%s"' % self.short_brief(brief)}))
|
||||
self.assertNotIn("permissionDecision", d)
|
||||
self.assertEqual(self.state()["chores"], [])
|
||||
|
||||
def test_deny_an_unpicked_model(self):
|
||||
self.ready_plan()
|
||||
self.denied(self.agent("alpha", self.pick_header("a")), "the wheel did not give you this worker")
|
||||
|
||||
Reference in new issue
Block a user