Merge branch 'reach-plan-col'

This commit is contained in:
swaits committed 2026-12-03 20:42:12 -07:00
commit 68e8acb544
2 files changed
+43 -7

No files matched your search

+9 -6
View File
@@ -7,12 +7,13 @@ import contextlib, fnmatch, hashlib, os, re, time
from . import store
CLASSES = ("routine", "ordinary", "hard", "lead")
COLS = ("node", "class", "needs", "branch", "files", "check", "why")
COLS = ("node", "class", "needs", "branch", "files", "check", "reach", "why")
NODE_LINE = re.compile(r"\W{0,6}sisi node:\s*([a-z0-9-]{1,30})\s*$", re.I)
CHORE_LINE = re.compile(r"\W{0,6}sisi chore:\s*(.+?)(?:\s+([0-9a-f]{8}))?\s*$", re.I)
CHORE_CMD = {"plan": "sisi plan brief", "models research": "sisi models research", "models offered": "sisi models offered < FILE", "rules organize": "sisi rules organize"}
USAGE = ('usage: sisi plan | sisi plan --record FILE | sisi plan brief | sisi plan --done ID "<evidence>" | sisi plan --fail ID "<why>"\n'
" FILE holds one markdown table: | node | class | needs | branch | files | check | why | (why is optional)")
" FILE holds one markdown table: | node | class | needs | branch | files | check | reach | why | (reach and why are optional)")
REACH_LINE = "floor = the check, which alone decides done and merge; reach = a far target: report the measured number you reached toward it, never the reach as met unless shown; floor-only work is judged floor and gets less work"
BRIEF = """sisi chore: plan
You are a worker. Do this task yourself; do not delegate it further.
@@ -26,7 +27,7 @@ Checks that decide success:
Next: %(next)s
Answer with exactly one markdown table and nothing else:
| node | class | needs | branch | files | check | why |
| node | class | needs | branch | files | check | reach | why |
- node: a short id, [a-z0-9-], at most 30 characters, unique.
- class: routine, ordinary, hard, or lead (done by the lead itself: the final join, and judgement only it can make).
- needs: the node ids that must be done first, comma-separated, or -.
@@ -34,6 +35,7 @@ Answer with exactly one markdown table and nothing else:
- files: the paths, folders or globs it may change, comma-separated (- for none). Nodes that can run at the same
time must have disjoint files.
- check: how its result is proven, a check that can fail.
- reach: a target far past the check, a number or a totality, that should feel a little delusional, e.g. "make this 100x faster", "delete half the codebase without breaking anything", "turn every bug we've ever fixed into a property test", "find all implicit invariants, formally prove them or find counterexamples"; the check alone decides done. - when there is no far target.
- why: a few words on the class choice, e.g. "exact spec, test decides" or "design judgement, redo costly".
Shape: maximize parallelism: prefer many small nodes, each specified so exactly that a near-free model does it well
and fast, to a few complex ones. A small node's check is the quick test of its own change; slow checks (the full
@@ -63,14 +65,14 @@ def parse(text):
c = _cells(line)
if c and c[0].lower() == "node":
cols = [x.lower() for x in c]
if cols[:6] != list(COLS[:6]) or cols[6:] not in ([], ["why"]):
return None, "the header must be | node | class | needs | branch | files | check | (and optionally | why |)"
if cols[:6] != list(COLS[:6]) or cols[6:] not in ([], ["why"], ["reach"], ["reach", "why"]):
return None, "the header must be | node | class | needs | branch | files | check | (and optionally | reach | why |)"
elif cols and not set("".join(c)) <= set("-: "):
if len(c) != len(cols):
return None, "row %r has %d cells, the header %d" % (c[0], len(c), len(cols))
r = dict(zip(cols, c))
nodes.append({"id": r["node"], "cls": r["class"].lower(), "needs": _list(r["needs"]), "branch": r["branch"],
"files": _list(r["files"]), "check": store.clean(r["check"]), "why": store.clean(r.get("why", ""))})
"files": _list(r["files"]), "check": store.clean(r["check"]), "reach": store.clean(r.get("reach", "")), "why": store.clean(r.get("why", ""))})
return (nodes, "") if nodes else (None, "no table found (a `| node | class | needs | branch | files | check |` header and rows)")
@@ -276,6 +278,7 @@ def for_pick(args, cwd=None):
def header(p, i):
return "\n".join(["paste at the top of the brief (its first line):", "sisi node: " + i, "branch: %s (its own worktree and build folder)" % (n := node(p, i))["branch"],
"may change: " + (", ".join(n["files"]) or "nothing"), "check: " + n["check"],
"reach: " + (n.get("reach") or "-"), REACH_LINE,
"needs done: " + (", ".join("%s on %s (%s)" % (x, node(p, x)["branch"], p["state"].get(x, {}).get("evidence", "")) for x in n["needs"]) or "-")])
+34 -1
View File
@@ -12,6 +12,7 @@ TABLE = test_core.HEADER + (
"| beta | host subagent model `beta` | ordinary | free | edits | |\n"
"| gamma | host subagent model `gamma` | hard | per use | everything | |\n")
COLS = "| node | class | needs | branch | files | check | why |\n|---|---|---|---|---|---|---|\n"
REACH = "| node | class | needs | branch | files | check | reach | why |\n|---|---|---|---|---|---|---|---|\n"
PLAN = COLS + (
"| a | routine | - | p-a | sisi/a.py | test a passes | exact spec, test decides |\n"
"| b | ordinary | - | p-b | sisi/b.py | test b passes | some judgement |\n"
@@ -123,6 +124,38 @@ class Plan(unittest.TestCase):
out = self.ready_plan(text=six)
self.assertIn("wave 1: a (routine), b (ordinary)", out)
def test_a_reach_column_records_its_cell(self):
self.ready_plan(text=REACH + (
"| a | routine | - | p-a | sisi/a.py | test a passes | make this 100x faster | exact spec, test decides |\n"
"| b | ordinary | - | p-b | sisi/b.py | test b passes | | some judgement |\n"
"| join | lead | a, b | - | - | full suite passes | | the lead merges |\n"))
self.assertEqual([n["reach"] for n in self.state()["plan"]["nodes"]], ["make this 100x faster", "", ""])
def test_tables_without_the_reach_column_record_with_reach_empty(self):
six = "\n".join("|".join(l.split("|")[:-2]) + "|" if l.startswith("|") else l for l in PLAN.splitlines()) + "\n"
for sid, text in (("s1", PLAN), ("s2", six)):
self.ready_plan(sid=sid, text=text)
self.assertEqual({n["reach"] for n in self.state(sid)["plan"]["nodes"]}, {""})
def test_plan_brief_asks_for_the_reach_column_with_its_four_examples(self):
self.ready_plan()
out = self.sisi("plan", "brief", sid="s1")[1]
self.assertIn("| node | class | needs | branch | files | check | reach | why |", out)
for ex in ('"make this 100x faster"', '"delete half the codebase without breaking anything"',
'"turn every bug we\'ve ever fixed into a property test"',
'"find all implicit invariants, formally prove them or find counterexamples"'):
self.assertIn(ex, out)
def test_pick_node_prints_the_reach_and_the_reach_line(self):
from sisi import plan
self.ready_plan(text=REACH + (
"| a | routine | - | p-a | sisi/a.py | test a passes | make this 100x faster | exact spec |\n"
"| b | ordinary | - | p-b | sisi/b.py | test b passes | | some judgement |\n"
"| join | lead | a, b | - | - | full suite passes | | the lead merges |\n"))
out = self.pick("a")
self.assertIn("reach: make this 100x faster", out)
self.assertIn(plan.REACH_LINE, out)
def test_record_line_counts_the_last_twenty_judged_per_class(self):
self.table(TABLE)
line = lambda w, v: json.dumps({"ts": "2026-11-20T10:00:00", "worker": w, "verdict": v, "why": "did it fine"})
@@ -159,7 +192,7 @@ class Plan(unittest.TestCase):
rc, out, _ = self.sisi("plan", "brief", sid="s1")
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 |",
for want in ("export every row without losing any", "1. row counts match", "| node | class | needs | branch | files | check | reach | why |",
"Class by total cost", "routine nodes whenever their", "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)