sisi done, sisi pick and measured retros: nothing starts before done is recorded, a delegation needs a pick from the wheel, every record carries its numbers, and the objective is the spec's

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-23 20:05:42 -07:00
1 parent acde97798b
commit 2e94c44ebb
8 files changed
+514 -53

No files matched your search

+97 -3
View File
@@ -2,7 +2,7 @@
A research worker writes it, the lead reads it to route, and `sisi judge` adds how each delegation went so the
next research knows. The table is plain text a person can read and correct."""
import json, os, time
import json, os, re, time
from . import rules, store
RESEARCH = """You are a worker. Do this task yourself; do not delegate it further.
@@ -21,8 +21,10 @@ the table an engineering lead will route by.
Answer with exactly this and nothing else. First a markdown table of at most 40 rows, the cheapest capable
worker first within each level, with these columns:
| worker | how to call it | use for | cost | good at, bad at | notes |
"use for" is one or more of: routine, ordinary, hard. "how to call it" is exact: the host's subagent model
name, or the full command line with <brief> where the brief goes.
"use for" is one or more of: routine, ordinary, hard. "how to call it" is exact: where the host has its own
tool for starting workers on other harnesses (T3 Code's delegate_task), the provider and the model id to give
it; the host's subagent model name where it has subagents; the full command line with <brief> where the brief
goes only for a worker the host's tool cannot reach.
Then one line starting "Fallback order:" that says who takes over when a worker is out, level by level.
=== The table now ===
@@ -59,6 +61,98 @@ def stale():
return ""
def rows(text):
"""The table's worker rows, each a list of six cells: worker, how to call it, use for, cost, good, notes."""
out = []
for line in text.splitlines():
c = [x.strip() for x in line.strip().strip("|").split("|")] if line.startswith("|") else []
if len(c) >= 5 and c[0].lower() != "worker" and not set(c[0]) <= set("-: "):
out.append((c + [""] * 6)[:6])
return out
def short(cell):
w = str(cell).split()
return w[0].lower() if w else ""
def maker(name, call=""):
"""Who made a worker: claude for the host's subagents, else the leading letters of the model's own name."""
m = re.match(r"[a-z]+", name.rsplit("/", 1)[-1])
return "claude" if "host subagent" in call.lower() else m.group() if m else name
def command(row):
"""A row that is called by a shell command line (it has <brief> in it, and is not a host subagent)."""
return "<brief>" in row[1] and "host subagent" not in row[1].lower()
def is_call(command_line):
"""Does this shell command start one of the workers in the table?"""
words = command_line.split()
return bool(words) and os.path.basename(words[0]) in {r[1].replace("`", "").split()[0] for r in rows(store.read(table())) if command(r)}
def claim(s, text):
"""Spend the pick that this delegation's model text names; False when none of the picks fits."""
for name in s.get("picked") or []:
if name in text.lower() or name.rsplit("/", 1)[-1] in text.lower():
s["picked"].remove(name)
s.setdefault("workers_since", []).append(name)
return True
return False
def choose(text, cls, skip=(), review=None, rand=None, today=None):
"""One worker of this class, by a wheel weighted by table order (the first of n has weight n, the last 1)."""
table_rows, today = rows(text), today or time.strftime("%Y-%m-%d")
bad = None
if review:
bad = next((maker(short(r[0]), r[1]) for r in table_rows if short(r[0]) == short(review)), maker(short(review)))
left = [r for r in table_rows if cls in r[2].lower() and short(r[0]) not in skip and maker(short(r[0]), r[1]) != bad
and not any(d > today for d in re.findall(r"out until (\d{4}-\d{2}-\d{2})", " ".join(r).lower()))]
if not left:
return None
if rand is None:
import random
rand = random.random
x = rand() * len(left) * (len(left) + 1) / 2
for weight, r in zip(range(len(left), 0, -1), left):
x -= weight
if x < 0:
return r
return left[-1]
def pick(args, cwd=None, rand=None):
"""`sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...]`: the wheel gives one worker."""
cls, skip, review, i = (args[0] if args and args[0] in ("routine", "ordinary", "hard") else None), set(), None, 1
while cls and i < len(args):
if args[i] == "--not" and i + 1 < len(args):
skip.add(short(args[i + 1]))
elif args[i] == "--review-of" and i + 1 < len(args):
review = args[i + 1]
else:
cls = None
i += 2
if not cls:
print("usage: sisi pick routine|ordinary|hard [--review-of WORKER] [--not WORKER ...]")
return 1
r = choose(store.read(table()), cls, skip, review, rand)
if not r:
print("sisi pick: every worker of that class is out or excluded.")
return 1
sid = store.current_session(cwd)
if sid:
with store.session(sid) as s:
s.setdefault("picked", []).append(short(r[0]))
print("worker: %s (model id: %s)\nstart it with the host's delegation tool; one pick buys one delegation" % (r[0], short(r[0])))
if store.config()["shell_workers"] or not command(r):
print("how to call it: " + r[1])
print("good at, bad at: %s\nnotes: %s" % (r[4], r[5]))
return 0
def outcomes(n):
out = []
for line in store.read(store.data("outcomes.jsonl")).splitlines()[-n:]: