Keep done and plan on mid-work retros; add deep model class and efficiency rule
- Mid-work retros (when checks have no verdict or a plan node is running) keep done, plan, node states, open jobs, and changed state; only a retro on finished work closes them (fixes faults 29 and 34). - Gate no longer auto-closes work while a plan node runs or demands a closing retro while a non-late delegation is open. - Add fourth model class 'deep' across models, pick (falls back to hard when no deep row exists), plan, judge outcomes, record_line, CLI/hooks, canon/core.md, and research/plan chore briefs, with the efficiency tie-breaking rule. Co-Authored-By: Gemini <noreply@google.com>
This commit is contained in:
1 parent
361a850da5
commit
81cc722400
10 files changed
+221
-46
No files matched your search
+95
-5
@@ -24,6 +24,7 @@ class Plan(unittest.TestCase):
|
||||
setUp, project, sisi, hook, tool, done, table, state, read, write, in_process = (
|
||||
test_core.Core.setUp, test_core.Core.project, test_core.Core.sisi, test_core.Core.hook, test_core.Core.tool, test_core.Core.done,
|
||||
test_core.Core.table, test_core.Core.state, test_core.Core.read, test_core.Core.write, test_core.Core.in_process)
|
||||
records = test_core.Core.records
|
||||
|
||||
def record(self, text, sid="s1"):
|
||||
return self.sisi("plan", "--record", self.write(os.path.join(self.tmp, "plan.md"), text), sid=sid)
|
||||
@@ -124,13 +125,13 @@ class Plan(unittest.TestCase):
|
||||
self.assertIn("wave 1: a (routine), b (ordinary)", out)
|
||||
|
||||
def test_record_line_counts_the_last_twenty_judged_per_class(self):
|
||||
self.table(TABLE)
|
||||
self.table(TABLE + "| delta | host subagent model `delta` | deep | per use | deepest | |\n")
|
||||
line = lambda w, v: json.dumps({"ts": "2026-11-20T10:00:00", "worker": w, "verdict": v, "why": "did it fine"})
|
||||
self.write(os.path.join(self.data, "outcomes.jsonl"), "\n".join(
|
||||
[line("alpha", "bad")] * 5 + [line("alpha", "good")] * 18 + [line("beta", "bad")] + [line("gamma", "out")] + [line("nobody", "good")]) + "\n")
|
||||
[line("alpha", "bad")] * 5 + [line("alpha", "good")] * 18 + [line("beta", "bad")] + [line("gamma", "out")] + [line("delta", "good")] + [line("nobody", "good")]) + "\n")
|
||||
from sisi import plan
|
||||
self.assertEqual(self.in_process(plan.record_line)[0],
|
||||
"record (last 20 judged per class): routine 18/20 good, ordinary 0/1 good, hard none judged yet")
|
||||
"record (last 20 judged per class): routine 18/20 good, ordinary 0/1 good, hard none judged yet, deep 1/1 good")
|
||||
|
||||
def test_rerecording_keeps_the_state_of_unchanged_nodes(self):
|
||||
self.ready_plan()
|
||||
@@ -160,7 +161,8 @@ class Plan(unittest.TestCase):
|
||||
self.assertEqual(rc, 0, out)
|
||||
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)",
|
||||
"routine, ordinary, hard, deep, or lead", "Class by total cost", "routine nodes whenever their",
|
||||
"deep (the dearest tier)", "never inherited as hard or deep", "record (last 20 judged per class)",
|
||||
"prefer many small nodes", "quick test of its own change", "merges its needs, runs them once and fixes what broke"):
|
||||
self.assertIn(want, out)
|
||||
|
||||
@@ -174,10 +176,98 @@ class Plan(unittest.TestCase):
|
||||
self.assertEqual(self.sisi("plan", "--done", n, "test %s ok" % n, sid="s1")[0], 0)
|
||||
self.assertIn("needs done: a on p-a (test a ok), b on p-b (test b ok)", self.pick("merge"))
|
||||
|
||||
def test_a_retro_clears_the_plan(self):
|
||||
def test_a_retro_clears_the_plan_of_finished_work(self):
|
||||
self.ready_plan()
|
||||
for n in (1, 2):
|
||||
self.done("s1", "--pass", str(n), "seen in the test output")
|
||||
self.assertEqual(self.sisi("retro", "--no-gap", "every check passed with the tests shown", *test_core.NG, sid="s1")[0], 0)
|
||||
self.assertNotIn("plan", self.state())
|
||||
self.assertNotIn("done", self.state())
|
||||
self.assertIn("unit", self.records()[-1])
|
||||
|
||||
# a retro recorded while the work is still open
|
||||
|
||||
def running_a(self):
|
||||
self.ready_plan()
|
||||
self.pick("a")
|
||||
self.assertEqual(self.decision(self.agent("alpha", self.pick_header("a"))), {})
|
||||
self.assertEqual(self.sisi("plan", "--done", "b", "done by hand and tested", sid="s1")[0], 0)
|
||||
|
||||
def gap(self):
|
||||
rc, out, _ = self.sisi("retro", "--gap", "the worker ran out of time", "--cause", "the brief was far too wide", "--improve", "Split a wide brief into two nodes",
|
||||
"--term", "time", "--problem", "briefs too wide", "--level", "core", sid="s1")
|
||||
self.assertEqual(rc, 0, out)
|
||||
return out
|
||||
|
||||
def test_a_retro_while_work_is_open_keeps_done_and_the_plan(self): # fault 34
|
||||
self.running_a()
|
||||
self.assertEqual(self.sisi("learn", "--level", "user", "Always split a wide brief", sid="s1")[0], 0)
|
||||
out = self.gap()
|
||||
self.assertIn("the work stays open (checks 1, 2 have no verdict; nodes a are running)", out)
|
||||
self.assertNotIn("no done recorded", self.sisi("done", sid="s1")[1])
|
||||
self.assertIn("a [routine] running (alpha", self.sisi("plan", sid="s1")[1])
|
||||
self.assertEqual(self.nodes(), {"a": "running", "b": "done"})
|
||||
self.assertEqual((self.records()[-1]["open"], "unit" in self.records()[-1]), (True, False))
|
||||
self.assertEqual(self.sisi("judge", "alpha", "good", "did the work well", sid="s1")[0], 0) # the running job is still tracked
|
||||
self.assertEqual(self.nodes(), {"a": "done", "b": "done"})
|
||||
|
||||
def test_node_states_survive_a_retro_and_rerecording_done_and_the_plan(self): # fault 29
|
||||
self.running_a()
|
||||
self.gap()
|
||||
self.done()
|
||||
self.assertEqual(self.record(PLAN)[0], 0)
|
||||
self.assertEqual(self.nodes(), {"a": "running", "b": "done"})
|
||||
self.assertNotIn("nodes a", self.hook("gate")[1])
|
||||
|
||||
def test_rerecording_done_alone_keeps_every_node_state(self):
|
||||
self.running_a()
|
||||
self.done()
|
||||
self.assertEqual(self.nodes(), {"a": "running", "b": "done"})
|
||||
|
||||
def test_passed_checks_do_not_close_work_while_a_node_runs(self):
|
||||
self.running_a()
|
||||
for n in (1, 2):
|
||||
self.done("s1", "--pass", str(n), "seen in the test output")
|
||||
self.hook("gate")
|
||||
self.assertEqual(self.nodes(), {"a": "running", "b": "done"})
|
||||
self.assertIn("nodes a are running", self.gap())
|
||||
self.hook("gate")
|
||||
self.assertEqual(self.nodes(), {"a": "running", "b": "done"})
|
||||
self.assertEqual(len(self.records()), 1)
|
||||
|
||||
def test_midwork_retro_keeps_changed_state_until_work_closes(self):
|
||||
self.running_a()
|
||||
self.tool("Edit")
|
||||
self.gap()
|
||||
self.assertTrue(self.state().get("changed"))
|
||||
self.assertEqual(self.sisi("judge", "alpha", "good", "finished node a cleanly", sid="s1")[0], 0)
|
||||
self.assertEqual(self.sisi("plan", "--done", "c", "done by hand and tested", sid="s1")[0], 0)
|
||||
for n in (1, 2):
|
||||
self.done("s1", "--pass", str(n), "seen in the test output")
|
||||
self.assertIn("no retro yet", self.hook("gate")[1])
|
||||
|
||||
def test_deep_plan_node_picks_deep_or_falls_back_to_hard(self):
|
||||
deep_plan = COLS + (
|
||||
"| d | deep | - | p-d | sisi/d.py | test d passes | novel central mechanism |\n"
|
||||
"| join | lead | d | - | - | full suite passes | the lead merges |\n")
|
||||
self.ready_plan(text=deep_plan)
|
||||
# no deep row in TABLE -> falls back to hard (gamma)
|
||||
out = self.pick("d")
|
||||
self.assertIn("worker: gamma", out)
|
||||
self.assertIn("no deep worker", out)
|
||||
self.assertIn("sisi node: d", out)
|
||||
self.assertEqual(self.decision(self.agent("gamma", self.pick_header("d"))), {})
|
||||
self.assertEqual(self.nodes(), {"d": "running"})
|
||||
self.assertEqual(self.sisi("judge", "gamma", "bad", "try again with deep model", sid="s1")[0], 0)
|
||||
# add a deep row -> pick --node d picks delta directly
|
||||
self.table(TABLE + "| delta | host subagent model `delta` | deep | per use | deepest | |\n")
|
||||
out = self.pick("d")
|
||||
self.assertIn("worker: delta", out)
|
||||
self.assertNotIn("no deep worker", out)
|
||||
self.assertIn("sisi node: d", out)
|
||||
self.assertEqual(self.decision(self.agent("delta", self.pick_header("d"))), {})
|
||||
self.assertEqual(self.sisi("judge", "delta", "good", "designed the central mechanism cleanly", sid="s1")[0], 0)
|
||||
self.assertEqual(self.nodes(), {"d": "done"})
|
||||
|
||||
# pick --node
|
||||
|
||||
|
||||
Reference in new issue
Block a user