Item 5: recency breaks ties (recorded release date, else version inside a class); the rule in rule 6, the playbook and docs/workers.md; session start asks for release dates. done / next: class order and sisi workers classes (item 7)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-23 16:28:05 -07:00
1 parent 64a45cfccd
commit 7db6584388
8 files changed
+152 -21

No files matched your search

+3 -1
View File
@@ -81,7 +81,9 @@ wrong work.
You own the whole outcome; workers are specialists whose reports are evidence for you to judge.
Give each task to the least expensive worker that is capable enough, counting rework as cost,
and keep your own context for judgement. Use the host's own delegation first. Run independent
and keep your own context for judgement. Always use the most recently released model of a class
when it is usable, never an older version of it; classify a maker's models before comparing them,
because different classes are different things. Use the host's own delegation first. Run independent
work in parallel when it shortens the critical path. Brief a worker with a contract
(`sisi delegate brief`), check what comes back in proportion to the risk, and record the
judgement (`sisi delegate judge`). `sisi route` recommends a worker from that record, and
+10
View File
@@ -33,6 +33,16 @@ present; nothing here names one. Read on demand: `sisi delegate guide`.
routine work measured proof outranks a benchmark: the cheapest worker with a judged
record wins, and standing decides only when nobody has one. A thin record is a
reason for care, not a verdict.
- Always use the most recently released model of a class when it is usable, and never an older
version of it: newer models are almost always better and almost always cheaper, so neither a
better old record nor a cheaper old plan brings an older version back. A new version starts
from its predecessor's judged record until it has its own. Two exceptions only: the newer model
is unusable right now (down, out of allowance, avoided), or its class is not known yet. Classes
are not versions of each other: a maker's "flash" is a different thing from its standard model,
and a maker's separately named lines are different classes. Determine the class of a model
before comparing it with another (`sisi workers fact W --class NAME`), and a maker's classes,
most capable first, with `sisi workers classes`. A newer model that measures badly is replaced
by a different class or maker, never by its older version.
- Ask `sisi route --kind K --difficulty N` before delegating; `--explain` says
why. Difficulty is 1 routine, 2 ordinary, 3 hard. Say the guess out loud;
the record shows how good the guesses were.
+28
View File
@@ -82,6 +82,34 @@ instead, so cheaper options gather evidence. The choice is deterministic for one
`--explain` prints one line for the evidence behind the choice (which of a to d, with the numbers),
one per group of workers passed over as not capable enough, and names an exploration or a fallback.
## Newest version of a class, always
Newer models are almost always better and almost always cheaper, so `sisi route` always uses the
most recently released model of a class that is usable, and never an older version of it. A
model's identity is its maker, its line and its class, read from the id by `sisi/modelid.py`
(version numbers compared numerically, a date in the id as a date, tier words such as a "flash" or
"mini" from `canon/model-words.json`) and overridden by what the lead agent records:
`sisi workers fact WORKER --class NAME [--family NAME] [--maker M] [--released YYYY-MM-DD] --source S`.
A recorded release date beats version numbers for recency. The same model through two providers is
one model: if its newest version is usable through any provider, older versions do not compete
through any provider, and the existing cost comparison picks the provider. There is no exception for
a better old record or a cheaper old plan. The older version competes again only while the newer is
unusable (marked down, allowance spent, avoided by the user, or limited away), or when its class is
unknown. A newer model with a thick bad record is not replaced by its older version either: routing
moves to another class or maker by the usual rules. Different classes are different things and never
supersede each other. A class read from the id with confidence takes part at once
(`route.supersede_guessed`, default true; false lets only recorded classes take part); a class that
cannot be read (no version, or a word the data does not know) never does, and `sisi route` adds one
line asking the lead agent to record it.
A new version starts from its predecessor's judged record: a model with no thick record of its own
for a kind and difficulty inherits, as evidence, the thick record of the closest older version of
its maker and class (one version back at a time), named in `--explain`. It ranks below the model's
own record and above a benchmark, counts as a judged record for the rule that proof comes before
benchmark, stops once the model has a thick record of its own, and a predecessor's bad record is not
inherited. A discovered model with no data of its own is routable when its predecessor is. Where the
arithmetic falls back to a stable tie-break, the more recently released model wins first.
## Costs and failures
Tokens and cost are captured where the worker's output reports them, and marked `unavailable`
+7 -11
View File
@@ -192,14 +192,10 @@ def compare(a, b):
return 0
def recency_key(l):
"""A tuple that sorts the more recently released first, for tie-breaks: recorded release date, then version
inside one line (the line first, so versions of different lines are never compared), then the id's date."""
if not l:
return (0, 0, "", (), 0)
rel = l.get("released") or ""
days = int(rel[0:4]) * 372 + int(rel[5:7]) * 31 + int(rel[8:10]) if len(rel) >= 10 and rel[:4].isdigit() else 0
ver = tuple(-x for x in (tuple(l.get("version") or ()) + (0,) * 6)[:6])
d = l.get("date") or ""
dd = int(d[0:4]) * 372 + int(d[5:7]) * 31 + int(d[8:10]) if len(d) >= 10 else 0
return (0 if l.get("alias") else 1, -days, "|".join(l.get("key") or ()), ver, -dd)
def days(date):
"""A YYYY-MM-DD date as a number of days that sorts correctly (months of 31 days: only the order matters); 0 when
there is no date."""
d = str(date or "")
if len(d) >= 10 and d[:4].isdigit() and d[5:7].isdigit() and d[8:10].isdigit():
return int(d[0:4]) * 372 + int(d[5:7]) * 31 + int(d[8:10])
return 0
+33 -7
View File
@@ -51,12 +51,14 @@ The rule, in order:
unknown is never compared.
8. Load balancing: within the same price tier and price, the worker that has taken the least work
relative to its remaining allowance goes first (recorded uses divided by allowance left, an
unknown allowance counting as half). Ties break on the worker id.
unknown allowance counting as half). Ties break on the more recently released model (a recorded
release date, else the version inside one maker's class), then on the worker id.
Candidates reach here already restricted to workers with a judged record, a known price or a
benchmark standing (see workers.routable_candidates); on a cold start none qualifies and every
usable worker is offered, with the explanation saying so.
"""
import functools
import re
from . import modelid
@@ -187,7 +189,9 @@ def _versions_newest_first(models):
"""[[workers of one version], ...] from the newest version to the oldest (one model through several
providers is one version)."""
out = []
for d in sorted(models, key=lambda d: (modelid.recency_key(_lineage(d)), d["worker"])):
ordered = sorted(models, key=lambda d: d["worker"])
ordered.sort(key=functools.cmp_to_key(lambda a, b: modelid.compare(_lineage(b), _lineage(a))))
for d in ordered:
if out and modelid.compare(_lineage(out[-1][0]), _lineage(d)) == 0:
out[-1].append(d)
else:
@@ -421,7 +425,7 @@ def superseded_by(pool, opts=None):
for c in group:
newer = [d for d in group if modelid.compare(_lineage(d), _lineage(c)) > 0]
if newer:
out[c["worker"]] = min(newer, key=lambda d: (modelid.recency_key(_lineage(d)), d["worker"]))["worker"]
out[c["worker"]] = _versions_newest_first(newer)[0][0]["worker"]
return out
@@ -491,7 +495,26 @@ def _assess_all(eligible, stats, kind, difficulty, floors):
for c in eligible}, best)
def _make_key(stats, kind, difficulty, prefer):
def recency_order(candidates):
"""{worker: (recorded release date as days, negated; position among the versions of its class, newest first)}.
Smaller sorts first, so the more recently released model goes first; what cannot be compared is (0, 0).
A recorded release date counts across makers; the version only inside one maker's class."""
out = {c["worker"]: (0, 0) for c in candidates}
groups = {}
for c in candidates:
l = _lineage(c)
if l and l.get("key"):
groups.setdefault(tuple(l["key"]), []).append(c)
for group in groups.values():
for i, level in enumerate(_versions_newest_first(group)):
for d in level:
out[d["worker"]] = (-modelid.days(_lineage(d).get("released")), i)
return out
def _make_key(stats, kind, difficulty, prefer, recency=None):
recency = recency or {}
def rate(c):
cell = _cell(stats, c["worker"], kind, difficulty)
return (cell["good"] / cell["n"]) if cell["n"] else None
@@ -515,9 +538,10 @@ def _make_key(stats, kind, difficulty, prefer):
standing_key(c),
load_ratio(c),
-(r if r is not None else -1.0),
recency.get(c["worker"], (0, 0)),
c["worker"])
return key, rate, load_ratio
return key, rate, load_ratio, recency
def _prefer_judged(capable, assessments, difficulty):
@@ -562,7 +586,7 @@ def choose(candidates, records, availability, kind, difficulty, review_of=None,
eligible, passed, stats, author_maker, superseded = _prepare(candidates, records, availability, now, exclude,
avoid, review_of, opts)
assessments, best = _assess_all(eligible, inherit_stats(candidates, stats, opts), kind, difficulty, floors)
key, rate, load_ratio = _make_key(stats, kind, difficulty, prefer)
key, rate, load_ratio, recency = _make_key(stats, kind, difficulty, prefer, recency_order(eligible))
pool, basis = _select(eligible, assessments, difficulty) if eligible else ([], "none")
detail = {}
@@ -617,6 +641,8 @@ def choose(candidates, records, availability, kind, difficulty, review_of=None,
r, cr = rate(c), rate(choice)
reason = ("lower measured accepted rate for this kind and difficulty"
if r is not None and cr is not None and r < cr else
"equal on price and load; the choice is the more recently released"
if recency.get(choice["worker"], (0, 0)) < recency.get(c["worker"], (0, 0)) else
"equal on price and load; the choice came first in worker-id order")
passed.append((w, reason))
judged_first = basis == "capable" and _prefer_judged(pool, assessments, difficulty)[1]
@@ -695,7 +721,7 @@ def retry_choice(candidates, records, availability, kind, difficulty, rejected,
avoid, review_of, opts)
eff = inherit_stats(candidates, stats, opts)
assessments, best = _assess_all(eligible, eff, kind, difficulty, floors)
key, _rate, _load = _make_key(stats, kind, difficulty, prefer)
key, _rate, _load, _recency = _make_key(stats, kind, difficulty, prefer, recency_order(eligible))
out = {"choice": None, "step": None, "passed_over": passed, "stats": stats, "author_maker": author_maker,
"assessments": assessments, "best_standing": best, "kind": kind, "difficulty": difficulty,
"rejected": rejected, "rejections": rejections}
+2 -1
View File
@@ -907,7 +907,8 @@ def facts_line(now=None):
return ("sisi: %s: ask a fast, cheap worker to research current prices and "
"software-engineering benchmark standing for the workers found here (`sisi workers`) "
"and record each with its source: `sisi workers fact WORKER --price N --source S` "
"and `sisi workers fact WORKER --standing N --source S`. Until then routing "
"and `sisi workers fact WORKER --standing N --source S`; also the release date of each "
"worker that lacks one: `sisi workers fact WORKER --released YYYY-MM-DD --source S`. Until then routing "
"goes by the judged record alone." % what)
+69
View File
@@ -0,0 +1,69 @@
"""Recency breaks ties: where the arithmetic falls back to a stable order, the more recently released model wins
first (a recorded release date, else the version within one line, else the old tie-break by worker id), and the
rule is in the text agents and people read. Requirement ids: R-7.2-1, R-7.2-2."""
import os, unittest
from support import *
from sisi import routing
from test_model_supersession import cand, pick
class RecencyTieBreakTests(unittest.TestCase):
def test_a_recorded_release_date_decides_a_tie_between_unrelated_models(self):
a = cand("prov/aaa-1.0", cost=1.0, fact={"released": "2026-01-10"}, maker="aaa")
b = cand("prov/bbb-2.0", cost=1.0, fact={"released": "2026-08-01"}, maker="bbb")
who, r = pick([a, b])
self.assertEqual(who, "prov/bbb-2.0")
self.assertIn(("prov/aaa-1.0", "equal on price and load; the choice is the more recently released"), r["passed_over"])
def test_the_version_inside_one_line_decides_when_nothing_supersedes(self):
old, new = cand("prov/abc-5.9", cost=1.0), cand("prov/abc-5.10", cost=1.0)
who, r = pick([old, new], opts={"supersede_guessed": False})
self.assertEqual(who, "prov/abc-5.10")
self.assertEqual(pick([new, old], opts={"supersede_guessed": False})[0], "prov/abc-5.10")
def test_unknown_recency_keeps_the_old_tie_break(self):
a, b = cand("prov/aaa-1.0", cost=1.0, maker="aaa"), cand("prov/bbb-9.0", cost=1.0, maker="bbb")
who, r = pick([a, b])
self.assertEqual(who, "prov/aaa-1.0")
self.assertIn(("prov/bbb-9.0", "equal on price and load; the choice came first in worker-id order"), r["passed_over"])
def test_price_and_load_still_come_before_recency(self):
cheap_old = cand("prov/aaa-1.0", cost=0.5, fact={"released": "2026-01-10"}, maker="aaa")
dear_new = cand("prov/bbb-2.0", cost=1.0, fact={"released": "2026-08-01"}, maker="bbb")
self.assertEqual(pick([cheap_old, dear_new])[0], "prov/aaa-1.0")
class TextTests(unittest.TestCase):
def read(self, *parts):
with open(os.path.join(REPO, *parts), encoding="utf-8") as f:
return f.read()
def test_the_rule_is_in_the_always_loaded_rulebook_the_playbook_and_the_docs(self):
core = self.read("canon", "core.md")
rule6 = core[core.index("## 6. Orchestrate"):core.index("## 7.")]
self.assertIn("most recently released", rule6)
self.assertIn("never an older version", rule6)
self.assertIn("class", rule6)
for path in (("canon", "orchestration.md"), ("docs", "workers.md")):
text = self.read(*path).lower()
self.assertIn("most recently released", text, path)
self.assertIn("different classes", text, path)
self.assertIn("cheaper", text, path) # the reason: newer models are better and cheaper
def test_the_rulebook_is_inside_its_budget(self):
from sisi import overlay
lines, chars = overlay.size(self.read("canon", "core.md"))
self.assertLessEqual(lines, overlay.MAX_LINES)
self.assertLessEqual(chars, overlay.MAX_CHARS)
class SessionLineTests(SisiCase):
def test_session_start_asks_for_the_release_date_of_each_worker_that_lacks_one(self):
from sisi import workers
line = workers.facts_line()
self.assertIn("release date", line)
self.assertIn("--released", line)
if __name__ == "__main__":
unittest.main()
-1
View File
@@ -112,7 +112,6 @@ class ParseTests(unittest.TestCase):
self.assertEqual(modelid.compare(a, b), -modelid.compare(b, a), ident)
if a["source"] == "unknown":
self.assertIsNone(a["key"])
modelid.recency_key(a)
if __name__ == "__main__":