Item 2: class, family and release date recorded by the lead agent (sisi workers fact --class/--family/--released) beat the parser; sisi workers shows maker, class and recency of each routable worker, marks guesses. done / next: supersession and the one asking line (item 3)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-23 16:05:53 -07:00
1 parent ce6a5b89b9
commit 8141d2e281
3 files changed
+194 -8

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ LONG = {
'status': ' sisi status [--json] [--learning] recent units with their scorecards, then trends by project, risk profile, model and policy version (median and p95; no single score); --learning prints only the learning report',
'verifiers': ' sisi verifiers [WORDS] [--lang L] [--kind K] [--rung N] [--section S] [--installed] [--json]\n list ways to know work is correct, by section\n sisi verifiers show ID [--trace] one entry in full, and whether its tool is installed here; --trace also prints where each folded lesson lives in it\n sisi verifiers for "<claim>" best-matching verifiers for a claim or piece of work\n sisi verifiers doctor | lint which tools are installed; validate the library',
'done': ' sisi done [ID] [--trace] recipes: which checks make a kind of work done; --trace also prints where each folded lesson lives in the recipe\n sisi done for "<work>" best-matching recipe',
'workers': ' sisi workers [--refresh] the agent tools and models found here, what is usable now and why not, allowance and price where known, delegations waiting for a judgement, and the judged record as three tables\n sisi workers fact W --price N|--standing N --source S record a price (per million tokens) or benchmark standing (0-100), with its source and date\n sisi workers avoid|prefer PATTERN --why TEXT your own routing constraints, honoured by `sisi route`\n sisi workers only PROVIDER PATTERN... --why TEXT | --remove make only the matching models of that provider routable\n sisi workers note PATTERN \"TEXT\" --why SOURCE | --remove a standing fact about workers matching PATTERN, shown with route results\n sisi workers down W --reason limit|auth|missing|error [--until DATE|TIME] | up W mark a worker unavailable / available again\n sisi workers import FILE merge another ledger file into the delegation ledger (row counts printed; safe to repeat)',
'workers': ' sisi workers [--refresh] the agent tools and models found here, what is usable now and why not, allowance and price where known, delegations waiting for a judgement, and the judged record as three tables\n sisi workers fact W --price N|--standing N --source S record a price (per million tokens) or benchmark standing (0-100), with its source and date\n sisi workers fact W --class NAME [--family NAME] [--released DATE] --source S the class, line and release date you decided for a model; beats the parser\n sisi workers avoid|prefer PATTERN --why TEXT your own routing constraints, honoured by `sisi route`\n sisi workers only PROVIDER PATTERN... --why TEXT | --remove make only the matching models of that provider routable\n sisi workers note PATTERN \"TEXT\" --why SOURCE | --remove a standing fact about workers matching PATTERN, shown with route results\n sisi workers down W --reason limit|auth|missing|error [--until DATE|TIME] | up W mark a worker unavailable / available again\n sisi workers import FILE merge another ledger file into the delegation ledger (row counts printed; safe to repeat)',
'route': ' sisi route --kind K --difficulty N [--review-of W] [--explain]\n the most affordable usable worker for this kind and difficulty, and the mechanism to start it with (host subagents, host cross-provider delegation, or sisi delegate); --explain says why',
'delegate': ' sisi delegate brief | check FILE | guide the delegation-contract template (eight parts); which parts a brief lacks; the orchestration playbook\n sisi delegate --kind K --difficulty N --brief FILE [--worker W] [--review-of W] [--cwd DIR]\n run one brief on the chosen worker unattended; prints only its final report, the transcript path, and the judge command; a brief without outcome, acceptance or files it may change is refused\n sisi delegate judge ID --outcome accepted|rejected --check none|diffstat|tests|read|review [--minutes N]\n record your judgement of a delegation run, so the next choice learns from it; judge work run any other way with --worker W --type K --difficulty N instead of ID\n sisi delegate amend ID | recent [-n N] [--project P] mark a judged delegation that later proved wrong; list recent judgements to find an id',
'eval': ' sisi eval list|add|run|compare|shadow|judge|status|import\n the evaluation harness: benchmark cases from real work, isolated\n replay, policy comparison and independent judging (see docs/evaluation.md);\n `sisi eval` alone prints status; run without --tasks replays check cases only',
+119 -7
View File
@@ -21,6 +21,12 @@ Personal files (all in the personal data folder):
model-strength.json worker facts (benchmark standing, a published figure; never the measured
accepted rate): {"models": {"<model or worker>":
{"standing": 0..100, "source": text, "date": "YYYY-MM-DD"}}}
worker-models.json what the lead agent decided about each model: {"models": {"<model or worker>":
{"class": name, "family": name, "maker": name, "released": "YYYY-MM-DD",
"source": text, "date": "YYYY-MM-DD"}}, "classes": {"<maker>": {"order": [class,
most capable first], "source": text, "date": "YYYY-MM-DD"}}}, written by
`sisi workers fact --class ...` and `sisi workers classes`. A recorded
fact always beats what the parser reads from the id (sisi/modelid.py).
worker-prefs.json the user's own routing constraints: {"avoid": [{"pattern", "why"}],
"prefer": [...], "only": [{"provider", "patterns", "why"}]}, written by
`sisi workers avoid|prefer|only`
@@ -33,7 +39,7 @@ researched when they are missing or old. No price, score or model name ships in
import datetime, json, os, re, shutil, statistics, subprocess, sys, time, uuid
from . import brief as brief_contract
from . import paths, routing, store
from . import modelid, paths, routing, store
LIST_TIMEOUT_S = 30
DEFAULT_REFRESH_AFTER_S = 24 * 3600
@@ -568,6 +574,28 @@ def entry_cost(entry):
return float(single) if isinstance(single, (int, float)) and not isinstance(single, bool) else None
def models_path():
return _data_file("worker-models.json")
def load_model_facts():
"""({worker or model: class fact}, {maker: class order}) from worker-models.json."""
d = read_json(models_path())
models = d.get("models") if isinstance(d.get("models"), dict) else {}
classes = d.get("classes") if isinstance(d.get("classes"), dict) else {}
return models, classes
_WORDS = []
def model_words():
"""The tier words and ignored words in canon/model-words.json (data the parser reads; cached)."""
if not _WORDS:
_WORDS.append(read_json(paths.canon("model-words.json")))
return _WORDS[0]
def route_floors():
"""{difficulty: percent of the best usable standing needed} from `route.standing_floor`."""
return routing.standing_floors(route_cfg().get("standing_floor"))
@@ -615,10 +643,11 @@ def build_candidates(disc=None, records=None):
records = read_records() if records is None else records
prices = load_prices()
prior = load_strength_prior()
model_facts = load_model_facts()[0]
disc_tools = disc.get("tools") or []
cands, seen = [], set()
def add(tool, model, usable=True, reason=None, allowance=None, tool_plan=None):
def add(tool, model, usable=True, reason=None, allowance=None, tool_plan=None, host_native=False):
worker = _canonical(tool, model) if tool else str(model)
if worker.lower() in seen:
return None
@@ -628,7 +657,11 @@ def build_candidates(disc=None, records=None):
prior_entry = next((prior[k] for k in (worker, model)
if k and isinstance(prior.get(k), dict)), {})
standing = standing_of(prior_entry)
c = {"worker": worker, "tool": tool, "model": model,
fact = next((model_facts[k] for k in (worker, model) if k and isinstance(model_facts.get(k), dict)), {})
maker_fact = price.get("maker") or prior_entry.get("maker") or fact.get("maker")
lineage = modelid.resolve(worker, model_words(), fact=dict(fact, maker=maker_fact) if maker_fact else fact,
host_native=host_native)
c = {"worker": worker, "lineage": lineage, "tool": tool, "model": model,
"maker": price.get("maker") or prior_entry.get("maker") or routing.maker_of(model or worker),
"plan": price.get("plan") or tool_plan,
"cost": cost,
@@ -664,7 +697,7 @@ def build_candidates(disc=None, records=None):
if "/" not in str(w):
# No provider prefix: the host tool's own subagent model. It needs no discovered
# command-line tool and is usable unless marked down (routing checks that).
c = add(None, str(w), usable=True)
c = add(None, str(w), usable=True, host_native=True)
if c is not None:
c["host_native"] = True
alias_set.add(str(w).lower())
@@ -777,7 +810,7 @@ def notes_for(candidates_by_worker, chosen, passed, notes=None, limit=5):
DATA_FILES = ("delegations.jsonl", "worker-availability.json", "worker-prices.json",
"model-strength.json", "worker-prefs.json", "worker-notes.json")
"model-strength.json", "worker-prefs.json", "worker-notes.json", "worker-models.json")
def _data_state():
@@ -1376,6 +1409,36 @@ def _price_lines(tool_name, models, prices, shown_keys=None):
return lines
def _recency_text(l):
if l.get("alias"):
return "newest of its class (a bare host alias)"
bits = []
if l.get("released"):
bits.append("released %s (recorded)" % l["released"])
if l.get("version"):
bits.append("version %s" % ".".join(str(x) for x in l["version"]))
if l.get("date"):
bits.append("dated %s" % l["date"])
return ", ".join(bits) or "no version or date in the id"
def model_lines(cands, limit=40):
"""One line per routable worker: its maker, class (recorded, or a guess read from the id, or unknown) and
how recent it is. Workers whose class is only a guess say so; unknown ones say how to record it."""
out = []
for c in sorted(cands, key=lambda c: c["worker"]):
l = c.get("lineage") or {}
if l.get("source") == "unknown" or not l:
what = "class unknown: the id does not say it with confidence"
else:
what = "maker %s, class %s (%s)" % (l["maker"], l["label"], "recorded" if l["source"] == "fact"
else "a guess read from the id")
out.append(" %s: %s; %s" % (c["worker"], what, _recency_text(l)))
if len(out) > limit:
out = out[:limit] + [" ... and %d more" % (len(out) - limit)]
return out
def cmd_workers(args=()):
args = list(args)
if args[:1] == ["fact"]:
@@ -1444,6 +1507,12 @@ def cmd_workers(args=()):
for standing, worker, entry in standings:
print(" benchmark standing %g - %s: %s (%s)" % (standing, worker, entry.get("source") or "no source stated",
entry.get("date") or "no date stated"))
routable, cold, _excluded = routable_candidates(build_candidates(disc, records), records)
if routable and not cold:
print("Model lines (the class of each routable worker; a guess is read from the id alone: confirm it "
"with `sisi workers fact WORKER --class NAME --source S`):")
for line in model_lines(routable):
print(line)
down_now = [(k, v) for k, v in sorted(avail.items()) if isinstance(v, dict)]
for k, v in down_now:
if k in {t["name"] for t in disc.get("tools") or []}:
@@ -1880,7 +1949,9 @@ def _cmd_import(args):
def _cmd_fact(args):
usage = ("usage: sisi workers fact WORKER --price-in N --price-out N [--plan flat|per-use] [--maker M] --source S [--date YYYY-MM-DD]\n"
" sisi workers fact WORKER --price N (one blended figure) [--plan ...] [--maker M] --source S\n"
" sisi workers fact WORKER --standing 0..100 --source S [--date YYYY-MM-DD] (--score is the old name)")
" sisi workers fact WORKER --standing 0..100 --source S [--date YYYY-MM-DD] (--score is the old name)\n"
" sisi workers fact WORKER --class NAME [--family NAME] [--maker M] [--released YYYY-MM-DD] --source S\n"
" (the class, family and release date the lead agent decided for a model; a recorded fact beats the parser)")
if not args:
print(usage)
return 1
@@ -1897,10 +1968,13 @@ def _cmd_fact(args):
if not (price_ok and in_ok and out_ok and standing_ok and old_ok):
print(usage)
return 1
model_fact = _model_fact_args(args)
if model_fact is False:
return 1
if (price_in is None) != (price_out is None) or (price is not None and price_in is not None):
print("sisi: record either --price-in with --price-out, or one blended --price, not a mix", file=sys.stderr)
return 1
if price is None and price_in is None and standing is None:
if price is None and price_in is None and standing is None and not model_fact:
print(usage)
return 1
if min([v for v in (price, price_in, price_out) if v is not None] or [0]) < 0:
@@ -1912,6 +1986,16 @@ def _cmd_fact(args):
if standing is not None and not (0 <= standing <= 100):
print("sisi: --standing wants a number from 0 to 100", file=sys.stderr)
return 1
if model_fact:
data = read_json(models_path())
models = data.get("models") if isinstance(data.get("models"), dict) else {}
entry = dict(models.get(worker) or {})
entry.update(model_fact, source=source, date=date)
models[worker] = entry
data["models"] = models
write_json(models_path(), data)
print("recorded for %s: %s (from %s, %s)" % (worker, ", ".join("%s %s" % kv for kv in sorted(model_fact.items())),
source, date))
if price is not None or price_in is not None:
plan = _opt(args, "--plan")
if plan is not None and plan not in ("flat", "per-use"):
@@ -1958,6 +2042,34 @@ def _cmd_fact(args):
return 0
_NAME = re.compile(r"[a-z0-9][a-z0-9.+-]*")
def _model_fact_args(args):
"""{class, family, maker, released} from the command line, {} when none is given, False (after saying why)
when one is malformed. The maker alone belongs to a price or standing fact, so it is read here only
beside a class, family or release date."""
out = {}
for opt, field in (("--class", "class"), ("--family", "family"), ("--released", "released")):
v = _opt(args, opt)
if v is None:
continue
v = v.strip().lower()
if field == "released":
try:
datetime.date.fromisoformat(v)
except ValueError:
print("sisi: --released wants a date as YYYY-MM-DD", file=sys.stderr)
return False
elif not _NAME.fullmatch(v):
print("sisi: %s wants a short name (letters, digits, hyphens)" % opt, file=sys.stderr)
return False
out[field] = v
if out and _opt(args, "--maker"):
out["maker"] = _opt(args, "--maker").strip().lower()
return out
def _cmd_pref(kind, args):
prefs = load_prefs()
if not args:
+74
View File
@@ -0,0 +1,74 @@
"""Model lines in the worker commands: the class a lead agent records beats the parser, and `sisi workers`
shows maker, class and recency for each routable worker. Fixtures are invented ids shaped like real ones.
Requirement ids: R-7.2-1, R-7.2-3."""
import json, os, unittest
from support import *
class ModelCase(SisiCase):
def seed(self, spec, type="impl", difficulty=2):
"""spec: [(worker, attempts, accepted)]"""
os.makedirs(self.data, exist_ok=True)
n = len(self.rows())
with open(os.path.join(self.data, "delegations.jsonl"), "a") as f:
for worker, attempts, accepted in spec:
for i in range(attempts):
n += 1
f.write(json.dumps({"kind": "attempt", "id": "m%d" % n, "ts": 1760000000 + n, "project": "p",
"type": type, "difficulty": difficulty, "worker": worker,
"outcome": "accepted" if i < accepted else "rejected",
"check": "tests", "minutes": 5}) + "\n")
def rows(self):
p = os.path.join(self.data, "delegations.jsonl")
return open(p).read().splitlines() if os.path.exists(p) else []
def env(self):
return dict(PATH="")
def listing(self):
r = self.sisi("workers", env=self.env())
self.assertEqual(r.returncode, 0, r.stderr)
return r.stdout
class FactTests(ModelCase):
def test_a_class_fact_is_recorded_with_its_source_and_shown(self):
"""R-7.2-3: the lead agent's decision about a model is stored, with its source, and shown."""
self.seed([("prov/abc-6.2-sol", 9, 9), ("prov/abc-5.3", 9, 9)])
before = self.listing()
self.assertIn("prov/abc-6.2-sol: class unknown", before)
self.assertIn("prov/abc-5.3: maker abc, class standard (a guess read from the id)", before)
r = self.sisi("workers", "fact", "prov/abc-6.2-sol", "--class", "sol", "--released", "2026-11-01",
"--source", "lead agent, read the maker's page", env=self.env())
self.assertEqual(r.returncode, 0, r.stderr)
stored = json.load(open(os.path.join(self.data, "worker-models.json")))["models"]["prov/abc-6.2-sol"]
self.assertEqual((stored["class"], stored["released"], stored["source"]),
("sol", "2026-11-01", "lead agent, read the maker's page"))
after = self.listing()
self.assertIn("prov/abc-6.2-sol: maker abc, class sol (recorded); released 2026-11-01 (recorded), version 6.2", after)
def test_a_recorded_class_beats_the_parser(self):
self.seed([("prov/abc-5.3-flash", 9, 9)])
self.assertIn("class flash (a guess", self.listing())
self.sisi("workers", "fact", "prov/abc-5.3-flash", "--class", "standard", "--source", "lead", env=self.env())
self.assertIn("class standard (recorded)", self.listing())
def test_bad_input_is_refused_and_nothing_is_recorded(self):
self.seed([("prov/abc-5.3", 9, 9)])
for args in (("--class", "sol"), ("--class", "so l", "--source", "x"), ("--released", "next week", "--source", "x"),
("--released", "2026-13-40", "--source", "x")):
r = self.sisi("workers", "fact", "prov/abc-5.3", *args, env=self.env())
self.assertEqual(r.returncode, 1, args)
self.assertFalse(os.path.exists(os.path.join(self.data, "worker-models.json")))
def test_the_fact_file_is_committed_with_the_other_worker_data(self):
self.seed([("prov/abc-5.3", 9, 9)])
self.sisi("workers", "fact", "prov/abc-5.3", "--class", "standard", "--source", "lead", env=self.env())
import subprocess
out = subprocess.run(["git", "status", "--porcelain"], cwd=self.data, capture_output=True, text=True).stdout
self.assertNotIn("worker-models.json", out)
if __name__ == "__main__":
unittest.main()