Item 1: the cheapest worker that is capable enough for the kind and difficulty, from the best evidence about each (judged record, nearest judged evidence, benchmark standing against other standings only, unknown for difficulty 1). done / next: item 2, two scales kept apart

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-23 14:13:09 -07:00
1 parent 2ecbfea7e9
commit 14ac903a65
6 files changed
+715 -89

No files matched your search

+8
View File
@@ -10,5 +10,13 @@
},
"retro": {
"required": true
},
"route": {
"standing_floor": {
"1": 0,
"2": 60,
"3": 85
},
"price_blend_input_parts": 3
}
}
+393 -80
View File
@@ -1,8 +1,14 @@
"""Choosing a worker: pure arithmetic over the delegation record. No model call, no file access.
A candidate is a plain dict: worker (canonical id), tool, model, maker, plan ("flat", "per-use" or
None), cost (a comparable per-use price or None), allowance_pct_left (0..100 or None), usable,
reason (why not usable), and aliases (every spelling the record may use for this worker).
None), cost (a comparable blended per-million-token price or None), allowance_pct_left (0..100 or
None), usable, reason (why not usable), standing (a published benchmark's figure or None, with
standing_source and standing_date), and aliases (every spelling the record may use for this worker).
Two scales are kept apart. A benchmark standing is a figure from outside; an accepted rate is what
this organization measured by judging delegations. They are never compared with each other: a
standing is compared only with other workers' standings, a rate only with the bar and with other
rates. Judged evidence outranks the benchmark wherever both exist.
The rule, in order:
1. Never a model whose id contains "contributor" (those tiers train on prompts).
@@ -11,36 +17,46 @@ The rule, in order:
that would leave nobody.
3. For a review, never the author's maker while another maker is available. A stored `maker`
fact wins; otherwise the maker is derived from the model id (see maker_of).
4. Among the rest, a worker is proven for a kind and difficulty with MIN_ATTEMPTS judged attempts
and an accepted rate of at least MIN_ACCEPTED_RATE (accepted and not later found wrong). Above
difficulty 1, proven workers are preferred; at difficulty 1, workers with a thin record stay in
the pool so they gather attempts on low-stakes work. A worker proven bad (enough attempts, rate
below the bar) is passed over whenever anything else remains.
5. Cheapest first: a flat-rate plan with allowance left costs nothing more per task, so it comes
before anything billed per use; per-use workers order by their known price; an unknown price is
treated as the most expensive until learned. A stored benchmark prior (`prior_score`) ranks
within the same price, so a thin record is ordered by price and prior, never arbitrarily.
A user's `prefer` patterns put a worker first within the eligible pool.
4. Capable enough. For a kind and difficulty each remaining worker is judged by the best
evidence about it, in this order (see `assess`):
a. its judged record for that kind and difficulty: MIN_ATTEMPTS judged attempts and an
accepted rate of at least MIN_ACCEPTED_RATE (accepted and not later found wrong);
b. the nearest judged evidence: the same kind at a harder difficulty proves an easier one;
then all kinds at that difficulty (or a harder one). The same kind at an easier
difficulty is only weak evidence, used when no usable worker is capable otherwise;
c. benchmark standing as a prior, against other workers' standing only: at least a share of
the best standing among the usable workers (`standing_floor`: 85 percent at difficulty 3,
60 percent at difficulty 2, none at difficulty 1);
d. nothing known: capable for difficulty 1 only, as an exploration.
A worker with a thick bad record (MIN_ATTEMPTS attempts, rate under the bar) for the kind at
this or an easier difficulty is never capable, so never rides on a benchmark. A thin record
that already shows repeated rejections also cancels the benchmark prior.
5. Among the capable workers the cheapest wins: a flat-rate plan with allowance left first
(it costs nothing more per task), then the blended price (an unknown price counts as most
expensive), then the benchmark standing, then load. A user's `prefer` patterns come first.
If no worker is capable, the weak evidence decides; failing that, the strongest known usable
worker is recommended and the explanation says plainly that none is proven for this.
6. About one low-stakes task in ten (difficulty 1, every tenth judged attempt for that kind and
difficulty) goes to a cheaper worker with a thin record instead, so cheaper options keep
gathering evidence. The slot is a function of the record, so the choice stays deterministic
for one fixed record.
gathering evidence. The slot is a function of the record, so the choice stays deterministic.
7. 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). Because every delegation is recorded, the choice rotates
as work is done, yet stays deterministic for one fixed record. Ties break on the worker id.
unknown allowance counting as half). Ties break on the worker id.
Candidates reach here already restricted to workers with a judged record, a known price or a
benchmark prior (see workers.routable_candidates); on a cold start none qualifies and every usable
worker is offered, with the explanation saying so.
benchmark standing (see workers.routable_candidates); on a cold start none qualifies and every
usable worker is offered, with the explanation saying so.
"""
import re
MIN_ATTEMPTS = 8 # below this, a worker's record for a kind and difficulty is thin
MIN_ACCEPTED_RATE = 0.6 # "good enough" among workers with at least MIN_ATTEMPTS attempts
CONTRADICTION_REJECTIONS = 2 # a thin record with this many rejections below the bar cancels a prior
UNKNOWN_ALLOWANCE = 50.0 # allowance weight when a tool reports none
STRONG_BAND = 10.0 # strength points from the best still counts as among the strongest
STRONG_BAND = 10.0 # standing points from the best still counts as among the strongest
EXPLORE_EVERY = 10 # about one low-stakes task in ten tries a cheaper thin-record worker
DEFAULT_STANDING_FLOOR = {1: 0.0, 2: 60.0, 3: 85.0} # percent of the best usable standing needed
DEFAULT_PRICE_BLEND = 3.0 # parts of input price to one part of output price in a blended price
def maker_of(name):
@@ -53,6 +69,30 @@ def maker_of(name):
return re.split(r"[-_:. ]", model)[0] or model
def standing_floors(configured=None):
"""{difficulty: percent of the best usable standing needed}, the defaults overridden by whatever
valid entries the configured mapping has (keys 1..3, values 0..100)."""
table = dict(DEFAULT_STANDING_FLOOR)
if isinstance(configured, dict):
for k, v in configured.items():
try:
d, pct = int(k), float(v)
except (TypeError, ValueError):
continue
if d >= 1 and 0 <= pct <= 100:
table[d] = pct
return table
def _floor_pct(floors, difficulty):
table = standing_floors(floors)
if difficulty in table:
return table[difficulty]
if difficulty is None or difficulty < min(table):
return 0.0
return table[max(table)]
def _pattern_match(c, patterns):
"""The (pattern, why) a candidate matches, or None. A pattern matches as a substring of the
worker, model or tool name, case aside."""
@@ -129,12 +169,133 @@ def _cell(stats, worker, kind, difficulty):
return stats.get(worker, {}).get("by_cell", {}).get((kind, difficulty), {"n": 0, "good": 0})
def choose(candidates, records, availability, kind, difficulty, review_of=None, now=0.0, exclude=(),
avoid=None, prefer=None):
"""Pick one candidate, or none. Returns {"choice", "passed_over", "stats", "author_maker"}.
`passed_over` is [(worker, plain reason)] covering every candidate not chosen. `avoid` and
`prefer` are the user's own [{"pattern", "why"}] constraints."""
now = float(now or 0)
# ---------------------------------------------------------------- capability evidence
_TIER_RANK = {"a": 0, "b-higher": 1, "b-all": 2} # smaller is closer to the request
_NO_CELL = {"n": 0, "good": 0}
def _thick(cell):
return cell["n"] >= MIN_ATTEMPTS
def _rate(cell):
return cell["good"] / cell["n"] if cell["n"] else None
def _proven(cell):
return _thick(cell) and _rate(cell) >= MIN_ACCEPTED_RATE
def _poor(cell):
return _thick(cell) and _rate(cell) < MIN_ACCEPTED_RATE
def _contradicts(cell):
"""A thin record that already shows repeated rejections below the bar."""
return (not _thick(cell) and cell["n"] - cell["good"] >= CONTRADICTION_REJECTIONS
and _rate(cell) < MIN_ACCEPTED_RATE)
def _by_difficulty(stats, worker, kind):
"""({difficulty: cell} for this kind, {difficulty: cell} pooled over every kind), whole numbers only."""
own, pooled = {}, {}
for (k, d), cell in stats.get(worker, {}).get("by_cell", {}).items():
if not isinstance(d, int) or isinstance(d, bool):
continue
if k == kind:
own[d] = cell
p = pooled.setdefault(d, {"n": 0, "good": 0})
p["n"] += cell["n"]
p["good"] += cell["good"]
return own, pooled
def assess(stats, worker, kind, difficulty, standing=None, best_standing=None, floors=None):
"""What the evidence says about one worker for a kind and difficulty. Returns a dict:
tier "a", "b-higher", "b-all", "standing", "unknown" or "none"
capable whether the evidence says it is capable enough
bad a thick bad record for this kind at this or an easier difficulty: never capable
weak a proven record for this kind at an easier difficulty (weak evidence, last resort)
contradicted a thin record for this kind that already shows repeated rejections
level 3 judged proof, 2 benchmark, 1 weak, 0 nothing, -1 bad: never rises with difficulty
n, good, at the judged cell behind a, b-higher, b-all and the weak tier (and its difficulty)
share, needed, floor for the standing tier: percent of the best, the figure needed, the floor
Standing is compared only with the best standing; a rate only with the bar."""
d = difficulty
own, pooled = _by_difficulty(stats, worker, kind)
out = {"tier": "none", "capable": False, "bad": False, "weak": False, "contradicted": False,
"level": 0, "standing": standing, "measure": None}
easier = sorted(k for k in own if isinstance(d, int) and k <= d)
out["bad"] = any(_poor(own[k]) for k in easier)
if out["bad"]:
k = next(k for k in easier if _poor(own[k]))
out.update(level=-1, at=k, n=own[k]["n"], good=own[k]["good"], measure=_rate(own[k]))
return out
out["contradicted"] = any(_contradicts(own[k]) for k in easier)
easier_proven = [k for k in easier if k < d and _proven(own[k])]
out["weak"] = bool(easier_proven)
if easier_proven:
k = max(easier_proven)
out.update(weak_at=k, weak_n=own[k]["n"], weak_good=own[k]["good"], weak_rate=_rate(own[k]))
proof = None
if isinstance(d, int):
exact = own.get(d, _NO_CELL)
if _proven(exact):
proof = ("a", d, exact)
else:
higher = sorted(k for k in own if k > d and _proven(own[k]))
if higher:
proof = ("b-higher", higher[0], own[higher[0]])
else:
wide = sorted(k for k in pooled if k >= d and _proven(pooled[k]))
if wide:
proof = ("b-all", wide[0], pooled[wide[0]])
if proof is not None:
tier, at, cell = proof
out.update(tier=tier, capable=True, level=3, at=at, n=cell["n"], good=cell["good"], measure=_rate(cell))
return out
if standing is not None and not out["contradicted"]:
pct = _floor_pct(floors, d)
needed = (best_standing or 0.0) * pct / 100.0
share = 100.0 * standing / best_standing if best_standing else None
capable = standing >= needed - 1e-9
out.update(tier="standing", capable=capable, level=2 if capable else (1 if out["weak"] else 0),
floor=pct, needed=needed, share=share, best=best_standing)
return out
if standing is None and d == 1 and not out["contradicted"]:
out.update(tier="unknown", capable=True, level=0)
return out
if out["weak"]:
out["level"] = 1
return out
def strength(a):
"""How strong the evidence about a worker is, as a tuple that orders workers from weakest to
strongest. Kinds of evidence are ordered first (judged proof, then benchmark, then weak, then
nothing); only inside one kind are figures compared, so a standing never meets a rate."""
if a["bad"]:
return (-1, 0, 0.0)
if a["tier"] in _TIER_RANK:
return (4, -_TIER_RANK[a["tier"]], a["measure"])
if a["standing"] is not None and not a["contradicted"]:
return (3, 0, float(a["standing"]))
if a["weak"]:
return (2, 0, a["weak_rate"])
return (1, 0, 0.0)
def _standing_of(c):
s = c.get("standing")
return float(s) if isinstance(s, (int, float)) and not isinstance(s, bool) else None
# ---------------------------------------------------------------- the pool, then the choice
def _prepare(candidates, records, availability, now, exclude, avoid, review_of):
"""The workers that may be recommended at all: (eligible, passed, stats, author_maker)."""
exclude = {str(x) for x in exclude}
stats = candidate_stats(candidates, records)
passed = []
@@ -186,39 +347,22 @@ def choose(candidates, records, availability, kind, difficulty, review_of=None,
else:
rest.append(c)
eligible = rest
return eligible, passed, stats, author_maker
def _assess_all(eligible, stats, kind, difficulty, floors):
"""({worker: assessment}, best standing among the usable workers)."""
standings = [s for s in (_standing_of(c) for c in eligible) if s is not None]
best = max(standings) if standings else None
return ({c["worker"]: assess(stats, c["worker"], kind, difficulty, _standing_of(c), best, floors)
for c in eligible}, best)
def _make_key(stats, kind, difficulty, prefer):
def rate(c):
cell = _cell(stats, c["worker"], kind, difficulty)
return (cell["good"] / cell["n"]) if cell["n"] else None
def proven_good(c):
cell = _cell(stats, c["worker"], kind, difficulty)
return cell["n"] >= MIN_ATTEMPTS and rate(c) is not None and rate(c) >= MIN_ACCEPTED_RATE
def proven_bad(c):
cell = _cell(stats, c["worker"], kind, difficulty)
return cell["n"] >= MIN_ATTEMPTS and rate(c) is not None and rate(c) < MIN_ACCEPTED_RATE
pool = list(eligible)
if difficulty and difficulty > 1:
good = [c for c in eligible if proven_good(c)]
if good:
for c in eligible:
if c not in good:
cell = _cell(stats, c["worker"], kind, difficulty)
passed.append((c["worker"],
"record too thin for this difficulty (%d of %d attempts) while a proven worker is available"
% (cell["n"], MIN_ATTEMPTS) if cell["n"] < MIN_ATTEMPTS
else "accepted rate below the bar for this kind and difficulty"))
pool = good
if pool:
bad = [c for c in pool if proven_bad(c)]
if bad and len(bad) < len(pool):
for c in bad:
passed.append((c["worker"], "accepted rate below the bar over %d attempts"
% _cell(stats, c["worker"], kind, difficulty)["n"]))
pool = [c for c in pool if c not in bad]
def load_ratio(c):
left = c.get("allowance_pct_left")
if left is None and c.get("host_native"):
@@ -226,40 +370,90 @@ def choose(candidates, records, availability, kind, difficulty, review_of=None,
weight = float(left) if left else UNKNOWN_ALLOWANCE
return stats.get(c["worker"], {}).get("uses", 0) / max(weight, 1.0)
def prior_key(c):
score = c.get("prior_score")
return -float(score) if isinstance(score, (int, float)) else 1.0
def standing_key(c):
s = _standing_of(c)
return -s if s is not None else 1.0
def key(c):
r = rate(c)
return (0 if _pattern_match(c, prefer) else 1,
_price_tier(c),
float(c["cost"]) if c.get("cost") is not None else float("inf"),
prior_key(c),
standing_key(c),
load_ratio(c),
-(r if r is not None else -1.0),
c["worker"])
return key, rate, load_ratio
def _select(eligible, assessments):
"""(pool, basis): the workers to rank by price, and what put them there.
basis is "capable", "weak" (nobody capable; judged evidence at an easier difficulty),
"strongest" (nobody capable; the strongest known by evidence), "nothing" (nobody has any
evidence) or "all-bad" (every usable worker has a thick bad record)."""
live = [c for c in eligible if not assessments[c["worker"]]["bad"]]
if not live:
return list(eligible), "all-bad"
capable = [c for c in live if assessments[c["worker"]]["capable"]]
if capable:
return capable, "capable"
weak = [c for c in live if assessments[c["worker"]]["weak"]]
if weak:
return weak, "weak"
top = max(strength(assessments[c["worker"]]) for c in live)
pool = [c for c in live if strength(assessments[c["worker"]]) == top]
return pool, ("nothing" if top[0] <= 1 else "strongest")
def choose(candidates, records, availability, kind, difficulty, review_of=None, now=0.0, exclude=(),
avoid=None, prefer=None, floors=None):
"""Pick one candidate, or none. Returns {"choice", "passed_over", "stats", "author_maker", ...}.
`passed_over` is [(worker, plain reason)] covering every candidate not chosen. `avoid` and
`prefer` are the user's own [{"pattern", "why"}] constraints; `floors` the standing floors."""
now = float(now or 0)
eligible, passed, stats, author_maker = _prepare(candidates, records, availability, now, exclude, avoid, review_of)
assessments, best = _assess_all(eligible, stats, kind, difficulty, floors)
key, rate, load_ratio = _make_key(stats, kind, difficulty, prefer)
pool, basis = _select(eligible, assessments) if eligible else ([], "none")
detail = {}
ranked = sorted(pool, key=key)
def price_of(c):
return (_price_tier(c), float(c["cost"]) if c.get("cost") is not None else float("inf"))
pool.sort(key=key)
choice = pool[0] if pool else None
if basis == "all-bad":
ranked = sorted(pool, key=lambda c: (-(assessments[c["worker"]].get("measure") or 0.0), key(c)))
choice = ranked[0] if ranked else None
explored = None
if (choice is not None and difficulty == 1 and not _pattern_match(choice, prefer)
if (choice is not None and difficulty == 1 and basis == "capable" and not _pattern_match(choice, prefer)
and _cell(stats, choice["worker"], kind, difficulty)["n"] >= MIN_ATTEMPTS):
total = sum(_cell(stats, c["worker"], kind, difficulty)["n"] for c in candidates)
if total >= EXPLORE_EVERY - 1 and total % EXPLORE_EVERY == EXPLORE_EVERY - 1:
thinner = [c for c in pool
thinner = [c for c in ranked
if c is not choice
and _cell(stats, c["worker"], kind, difficulty)["n"] < MIN_ATTEMPTS
and price_of(c) <= price_of(choice)]
if thinner:
thinner.sort(key=key)
explored, choice = choice, thinner[0]
pool = [choice] + [c for c in pool if c is not choice]
ranked = [choice] + [c for c in ranked if c is not choice]
in_pool = {c["worker"] for c in ranked}
if choice is not None:
for c in pool[1:]:
cheaper_than = price_of(choice)
for c in eligible:
if c is choice:
continue
a = assessments[c["worker"]]
w = c["worker"]
if w not in in_pool:
reason, extra = _why_not(a, difficulty, basis, cheaper=price_of(c) < cheaper_than)
passed.append((w, reason))
if extra:
detail[w] = extra
continue
if explored is not None and c is explored:
reason = ("the usual choice, passed over this once so a cheaper thin-record worker "
"gathers evidence on low-stakes work (about one task in %d)" % EXPLORE_EVERY)
@@ -276,45 +470,163 @@ def choose(candidates, records, availability, kind, difficulty, review_of=None,
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 came first in worker-id order")
passed.append((c["worker"], reason))
passed.append((w, reason))
capable_n = sum(1 for c in eligible if assessments[c["worker"]]["capable"])
return {"choice": choice, "passed_over": passed, "stats": stats, "author_maker": author_maker,
"explored": explored["worker"] if explored else None,
"load_ratios": {c["worker"]: load_ratio(c) for c in candidates}}
"load_ratios": {c["worker"]: load_ratio(c) for c in candidates},
"assessments": assessments, "basis": basis, "capable_count": capable_n,
"best_standing": best, "passed_detail": detail, "floors": floors,
"kind": kind, "difficulty": difficulty}
def _why_not(a, difficulty, basis, cheaper):
"""(plain reason, short per-worker detail) for a worker kept out of the pool by what is known
about its capability. The reason text is the same for every worker it applies to, so reasons group."""
lead = "cheaper than the choice but " if cheaper else ""
if a["bad"]:
where = "" if a.get("at") == difficulty else " (at an easier difficulty, which a harder one cannot beat)"
return ("%saccepted rate below the bar over %d attempts%s" % ("cheaper but " if cheaper else "", a["n"], where),
"%d of %d accepted" % (a["good"], a["n"]))
if basis == "capable":
if a["contradicted"]:
return (lead + "not capable enough: its own thin record for this kind repeats rejections, which "
"cancels its benchmark standing", None)
if a["tier"] == "standing":
return (lead + "not capable enough for difficulty %d: benchmark standing under the %g needed "
"(%g%% of the best usable standing, %g)" % (difficulty, a["needed"], a["floor"], a["best"]),
"standing %g" % a["standing"])
if a["weak"]:
return (lead + "not capable enough for difficulty %d: its only judged proof is at an easier "
"difficulty, and a worker with better evidence is usable" % difficulty, None)
return (lead + "not capable enough for difficulty %d: nothing is recorded about it that proves it; "
"unknown workers are tried on difficulty 1 only" % difficulty, None)
if basis == "weak":
return (lead + "less evidence: no worker is capable by the evidence, so the one with judged proof at an "
"easier difficulty was taken", None)
return (lead + "weaker known evidence than the strongest known usable worker",
("standing %g" % a["standing"]) if a["standing"] is not None else None)
# ---------------------------------------------------------------- the retry ladder
def retry_choice(candidates, records, availability, kind, difficulty, rejected, rejections,
now=0.0, exclude=(), avoid=None, prefer=None, floors=None, review_of=None):
"""Who gets a task again after `rejected` (a worker id) was rejected `rejections` times in this chain.
The first retry goes back to the same worker while it is still usable. After that: the cheapest
capable worker whose evidence is strictly better than the rejected one's, or, when there is none,
the strongest known usable worker other than it (and only the rejected one itself when nobody
else is usable). Returns {"choice", "step", "assessments", "basis", ...}; step is "same", "better",
"strongest" or "only", and choice is None when nobody is usable. Pure; the caller supplies facts."""
now = float(now or 0)
eligible, passed, stats, author_maker = _prepare(candidates, records, availability, now, exclude, avoid, review_of)
assessments, best = _assess_all(eligible, stats, kind, difficulty, floors)
key, _rate, _load = _make_key(stats, kind, difficulty, prefer)
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}
mine = next((c for c in eligible if c["worker"] == rejected), None)
if int(rejections or 0) <= 1 and mine is not None:
out.update(choice=mine, step="same")
return out
others = [c for c in eligible if c["worker"] != rejected and not assessments[c["worker"]]["bad"]]
if not others:
if mine is not None:
out.update(choice=mine, step="only")
return out
gone = next((c for c in candidates if c["worker"] == rejected), None)
floor = (strength(assessments[rejected]) if mine is not None else
strength(assess(stats, rejected, kind, difficulty, _standing_of(gone) if gone else None, best, floors)))
better = [c for c in others if assessments[c["worker"]]["capable"] and strength(assessments[c["worker"]]) > floor]
if better:
out.update(choice=sorted(better, key=key)[0], step="better")
return out
top = max(strength(assessments[c["worker"]]) for c in others)
out.update(choice=sorted([c for c in others if strength(assessments[c["worker"]]) == top], key=key)[0],
step="strongest")
return out
# ---------------------------------------------------------------- the explanation
MAX_EXPLAIN_LINES = 20
EXPLAIN_TAIL_LINES = 5 # worker, mechanism, exclusion note, cold-start notice, request for facts
def _pct(x):
return "%d%%" % round(100.0 * x)
def evidence_line(a, kind, difficulty, choice, basis):
"""One line saying which evidence decided that the chosen worker is capable, with the numbers."""
if a is None:
return "evidence: none recorded"
if a["bad"]:
return ("evidence: none favourable; every usable worker has a poor record, so this one has the best "
"accepted rate (%d of %d for %s)" % (a["good"], a["n"], kind))
tier = a["tier"]
if tier == "a":
return ("evidence (a), judged record: %d of %d accepted for %s at difficulty %d (%s, bar %s)"
% (a["good"], a["n"], kind, difficulty, _pct(a["measure"]), _pct(MIN_ACCEPTED_RATE)))
if tier == "b-higher":
return ("evidence (b), judged record at a harder difficulty: %d of %d accepted for %s at difficulty %d "
"(%s), which proves difficulty %d" % (a["good"], a["n"], kind, a["at"], _pct(a["measure"]), difficulty))
if tier == "b-all":
return ("evidence (b), judged record across all kinds at difficulty %d: %d of %d accepted (%s)"
% (a["at"], a["good"], a["n"], _pct(a["measure"])))
if tier == "standing":
src = choice.get("standing_source") or "no source stated"
if a["capable"]:
if a["floor"]:
need = "above the %g needed (%g%% of the best usable standing, %g)" % (a["needed"], a["floor"], a["best"])
else:
need = "no floor at difficulty %d" % difficulty
return ("evidence (c), benchmark standing: %g (%s, %s), %s; no judged record for this decides it"
% (a["standing"], src, choice.get("standing_date") or "no date stated", need))
return ("evidence (c), benchmark standing only: %g (%s, %s), the strongest known; it is under the %g "
"needed for difficulty %d" % (a["standing"], src, choice.get("standing_date") or "no date stated",
a["needed"], difficulty))
if tier == "unknown":
return "evidence (d): nothing is known about this worker yet; it is an exploration on low-stakes work"
if a.get("weak"):
return ("evidence (b, weak): %d of %d accepted for %s at the easier difficulty %d; no worker has better evidence"
% (a["weak_good"], a["weak_n"], kind, a["weak_at"]))
return "evidence: nothing is recorded about any usable worker for %s at difficulty %d" % (kind, difficulty)
def explain_choice(result, kind, difficulty):
"""Plain lines for `--explain`, from a choose() result."""
choice = result["choice"]
lines = []
basis = result.get("basis")
if choice is None:
lines.append("no usable worker for kind %s at difficulty %s" % (kind, difficulty))
else:
cell = _cell(result["stats"], choice["worker"], kind, difficulty)
a = (result.get("assessments") or {}).get(choice["worker"])
if choice.get("plan") == "flat":
price = "a flat-rate plan with allowance left, so one more task costs nothing extra"
elif choice.get("cost") is not None:
price = "the cheapest known per-use price among the workers that are good enough"
price = "the cheapest known per-use price among the workers that are capable enough"
elif choice.get("plan") == "per-use":
price = "billed per use; no cheaper flat-rate worker is usable"
else:
price = "price unknown, treated as most expensive until learned; nothing priced cheaper is usable"
if cell["n"] >= MIN_ATTEMPTS:
record = "%d judged attempts for this kind and difficulty, %d accepted" % (cell["n"], cell["good"])
elif cell["n"]:
record = "a thin record (%d of %d attempts for this kind and difficulty)" % (cell["n"], MIN_ATTEMPTS)
price = "price unknown, treated as most expensive until learned; nothing priced cheaper is capable"
if basis in (None, "capable"):
head = "chose %s: %s" % (choice["worker"], price)
if result.get("capable_count"):
head += "; %d usable worker(s) capable enough" % result["capable_count"]
else:
record = "no judged attempts yet for this kind and difficulty"
lines.append("chose %s: %s; %s; load so far is %s recorded use(s) against the allowance it has left, "
"the lowest in its price tier, so work spreads instead of draining one plan"
% (choice["worker"], price, record, result["stats"].get(choice["worker"], {}).get("uses", 0)))
if isinstance(choice.get("prior_score"), (int, float)) and cell["n"] < MIN_ATTEMPTS:
lines.append("its benchmark prior is %g (%s, %s); with a thin record, price and prior decide the order"
% (float(choice["prior_score"]), choice.get("prior_source") or "no source stated",
choice.get("prior_date") or "no date stated"))
head = "chose %s: none is proven capable for %s at difficulty %s" % (choice["worker"], kind, difficulty)
head += ("; taken for the strongest known evidence (%s)" % price if basis == "strongest" else
"; %s" % ("every usable worker has a poor record" if basis == "all-bad" else
"nothing is recorded about any usable worker, so this is a trial" if basis == "nothing" else
"taken for the judged proof at an easier difficulty (%s)" % price))
lines.append(head)
if a is not None:
lines.append(evidence_line(a, kind, difficulty, choice, basis))
if result.get("explored"):
lines.append("this is an exploration pick: %s was the usual choice, passed over once so a cheaper "
"thin-record worker gathers evidence" % result["explored"])
@@ -325,6 +637,7 @@ def explain_choice(result, kind, difficulty):
else:
lines.append("no worker from a different maker than the author (%s) is available, "
"so the review stays with the same maker" % result["author_maker"])
detail = result.get("passed_detail") or {}
groups, order = {}, []
for worker, reason in result["passed_over"]:
if reason not in groups:
@@ -336,7 +649,7 @@ def explain_choice(result, kind, difficulty):
# smallest groups share one closing line that still names each reason and its count.
def group_line(reason):
names = groups[reason]
shown = ", ".join(names[:3])
shown = ", ".join(("%s [%s]" % (n, detail[n])) if n in detail else n for n in names[:3])
more = " and %d more" % (len(names) - 3) if len(names) > 3 else ""
return "passed over %d worker(s) (%s%s): %s" % (len(names), shown, more, reason)
+28 -6
View File
@@ -501,12 +501,34 @@ def load_prices():
return read_json(prices_path())
def standing_of(entry):
"""The benchmark standing in a stored fact, or None. Facts recorded before standing had its own
name carry it as "score": read the same way, with their source and date."""
if not isinstance(entry, dict):
return None
for field in ("standing", "score"):
v = entry.get(field)
if isinstance(v, (int, float)) and not isinstance(v, bool):
return float(v)
return None
def load_strength_prior():
d = read_json(strength_path())
models = d.get("models")
return models if isinstance(models, dict) else {}
def route_cfg():
cfg = store.config().get("route")
return cfg if isinstance(cfg, dict) else {}
def route_floors():
"""{difficulty: percent of the best usable standing needed} from `route.standing_floor`."""
return routing.standing_floors(route_cfg().get("standing_floor"))
def _price_for(prices, tool, model, worker):
models = prices.get("models") if isinstance(prices.get("models"), dict) else {}
tools = prices.get("tools") if isinstance(prices.get("tools"), dict) else {}
@@ -561,15 +583,15 @@ def build_candidates(disc=None, records=None):
cost = price.get("cost_per_million_tokens", price.get("cost"))
prior_entry = next((prior[k] for k in (worker, model)
if k and isinstance(prior.get(k), dict)), {})
score = prior_entry.get("score")
standing = standing_of(prior_entry)
c = {"worker": worker, "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": float(cost) if isinstance(cost, (int, float)) else None,
"allowance_pct_left": allowance, "usable": usable, "reason": reason,
"price_source": price.get("source"), "price_date": price.get("date"),
"prior_score": float(score) if isinstance(score, (int, float)) else None,
"prior_source": prior_entry.get("source"), "prior_date": prior_entry.get("date"),
"standing": standing,
"standing_source": prior_entry.get("source"), "standing_date": prior_entry.get("date"),
"aliases": [worker, model, ("%s/%s" % (tool, model)) if tool and model else None,
tool if model is None else None]}
c["aliases"] = [a for a in c["aliases"] if a]
@@ -825,7 +847,7 @@ def routable_candidates(candidates, records):
keep = []
for c in candidates:
judged = sum(cell["n"] for cell in stats.get(c["worker"], {}).get("by_cell", {}).values())
if judged or c.get("price_source") or c.get("prior_score") is not None:
if judged or c.get("price_source") or c.get("standing") is not None:
keep.append(c)
if not keep:
return list(candidates), True, 0
@@ -1104,7 +1126,7 @@ def run_delegation(candidates, kind, difficulty, prompt, cwd, explicit=None, rev
prefs = effective_prefs(kind, difficulty, cwd)
result = routing.choose(candidates, read_records(), read_availability(), kind, difficulty,
review_of=review_of, now=time.time(), exclude=tried,
avoid=prefs["avoid"], prefer=prefs["prefer"])
avoid=prefs["avoid"], prefer=prefs["prefer"], floors=route_floors())
cand = result["choice"]
if cand is None:
notes.append("sisi: no usable worker remains for kind %s at difficulty %s" % (kind, difficulty))
@@ -1434,7 +1456,7 @@ def cmd_route(args=()):
candidates, limited = apply_limits(candidates, prefs)
result = routing.choose(candidates, records, read_availability(), kind, difficulty,
review_of=_opt(args, "--review-of"), now=time.time(),
avoid=prefs["avoid"], prefer=prefs["prefer"])
avoid=prefs["avoid"], prefer=prefs["prefer"], floors=route_floors())
result["passed_over"] = list(result["passed_over"]) + limited
by_worker = {c["worker"]: c for c in everyone}
down = _down_now(read_availability(), time.time())
+282
View File
@@ -0,0 +1,282 @@
"""Choosing the cheapest worker that is capable enough for a kind and difficulty, from the best evidence
about each worker: judged record (exact, a harder difficulty, all kinds), then benchmark standing against other
workers' standing only, then nothing known (difficulty 1 only). Requirement ids: R-7.2-1, R-7.2-2, R-7.2-3,
R-7.3-3. Property tests are seeded and scale with SISI_TEST_ITERS."""
import random, unittest
from support import *
from sisi import routing
KIND = "research"
def cand(name, cost=None, standing=None, plan="per-use", allowance=None, maker=None, usable=True):
w = "t/%s" % name
return {"worker": w, "tool": "t", "model": name, "maker": maker or name.split("-")[0], "plan": plan,
"cost": cost, "allowance_pct_left": allowance, "usable": usable, "reason": None,
"standing": standing, "standing_source": "fixture benchmark", "standing_date": "2000-01-01",
"aliases": [w, name]}
_n = [0]
def attempts(worker, kind, difficulty, good, bad, kind_name="attempt"):
rows = []
for i in range(good + bad):
_n[0] += 1
rows.append({"kind": kind_name, "id": "x%d" % _n[0], "type": kind, "difficulty": difficulty,
"worker": worker, "outcome": "accepted" if i < good else "rejected", "check": "tests"})
return rows
def pick(cands, records, difficulty, kind=KIND, **kw):
return routing.choose(cands, records, {}, kind, difficulty, now=1000.0, **kw)
def chosen(cands, records, difficulty, **kw):
r = pick(cands, records, difficulty, **kw)
return r["choice"]["worker"] if r["choice"] else None
class SufficientCapabilityTests(unittest.TestCase):
def fleet(self):
# the shape that went wrong: the cheapest worker has the weakest standing
return [cand("weak-1", cost=0.2, standing=40.0), cand("mid-1", cost=4.0, standing=64.0),
cand("top-1", cost=8.0, standing=66.0)]
def test_a_hard_task_goes_to_a_worker_near_the_top_not_the_cheapest(self):
"""R-7.2-2: difficulty 3 needs at least 85 percent of the best standing; the cheapest of those wins."""
self.assertEqual(chosen(self.fleet(), [], 3), "t/mid-1")
self.assertEqual(chosen(self.fleet(), [], 1), "t/weak-1") # no floor at difficulty 1
self.assertEqual(chosen(self.fleet(), [], 2), "t/weak-1") # 40 is 60.6 percent of 66, above the 60 percent floor
def test_the_floor_is_configurable(self):
got = chosen(self.fleet(), [], 2, floors={"2": 80})
self.assertEqual(got, "t/mid-1")
self.assertEqual(chosen(self.fleet(), [], 3, floors={3: 100}), "t/top-1")
def test_a_flat_plan_with_low_standing_does_not_take_a_hard_task(self):
cands = [cand("flat-1", standing=30.0, plan="flat", allowance=80), cand("pay-1", cost=5.0, standing=64.0)]
self.assertEqual(chosen(cands, [], 3), "t/pay-1")
self.assertEqual(chosen(cands, [], 2), "t/pay-1") # 30 is under 60 percent of 64
self.assertEqual(chosen(cands, [], 1), "t/flat-1") # flat first where nothing is needed
def test_a_judged_record_proves_capability_whatever_the_standing(self):
"""The record outranks the benchmark: 9 of 10 at this kind and difficulty beats a low standing."""
cands = self.fleet()
recs = attempts("t/weak-1", KIND, 3, 9, 1)
r = pick(cands, recs, 3)
self.assertEqual(r["choice"]["worker"], "t/weak-1")
self.assertEqual(r["assessments"]["t/weak-1"]["tier"], "a")
def test_a_harder_difficulty_of_the_same_kind_proves_an_easier_one(self):
cands = [cand("a-1", cost=1.0), cand("b-1", cost=2.0)]
recs = attempts("t/b-1", KIND, 3, 10, 0)
r = pick(cands, recs, 2)
self.assertEqual(r["choice"]["worker"], "t/b-1")
self.assertEqual(r["assessments"]["t/b-1"]["tier"], "b-higher")
self.assertFalse(r["assessments"]["t/a-1"]["capable"])
def test_an_easier_difficulty_is_weak_evidence_used_only_as_a_last_resort(self):
cands = [cand("a-1", cost=1.0), cand("b-1", cost=2.0)]
recs = attempts("t/b-1", KIND, 1, 10, 0)
r = pick(cands, recs, 3)
self.assertEqual(r["choice"]["worker"], "t/b-1")
self.assertEqual(r["basis"], "weak")
# with a capable worker on hand, the weak evidence does not count
cands2 = cands + [cand("c-1", cost=9.0, standing=70.0)]
r2 = pick(cands2, recs, 3)
self.assertEqual(r2["choice"]["worker"], "t/c-1")
self.assertEqual(r2["basis"], "capable")
def test_the_same_difficulty_across_all_kinds_counts_when_the_kind_has_no_record(self):
cands = [cand("a-1", cost=1.0), cand("b-1", cost=2.0)]
recs = attempts("t/b-1", "other-kind", 2, 6, 0) + attempts("t/b-1", "third-kind", 2, 5, 1)
r = pick(cands, recs, 2)
self.assertEqual(r["choice"]["worker"], "t/b-1")
self.assertEqual(r["assessments"]["t/b-1"]["tier"], "b-all")
def test_unknown_workers_are_an_exploration_at_difficulty_one_only(self):
cands = [cand("a-1", cost=1.0), cand("b-1", cost=2.0, standing=50.0)]
r1 = pick(cands, [], 1)
self.assertEqual(r1["choice"]["worker"], "t/a-1")
self.assertEqual(r1["assessments"]["t/a-1"]["tier"], "unknown")
r2 = pick(cands, [], 2)
self.assertEqual(r2["choice"]["worker"], "t/b-1")
self.assertFalse(r2["assessments"]["t/a-1"]["capable"])
def test_all_workers_unknown_still_gives_an_answer_and_says_nothing_is_proven(self):
cands = [cand("a-1", cost=1.0), cand("b-1", cost=2.0)]
for d in (2, 3):
r = pick(cands, [], d)
self.assertEqual(r["choice"]["worker"], "t/a-1")
self.assertEqual(r["basis"], "nothing")
def test_no_capable_worker_falls_back_to_the_strongest_known(self):
"""When the best-standing worker is itself out (a poor record), nobody clears the floor: the strongest known
usable worker is taken and the result says that nothing is proven."""
cands = [cand("great-1", cost=1.0, standing=99.0), cand("ok-1", cost=3.0, standing=70.0),
cand("low-1", cost=0.5, standing=50.0)]
recs = attempts("t/great-1", KIND, 3, 3, 7)
r = pick(cands, recs, 3)
self.assertEqual(r["choice"]["worker"], "t/ok-1")
self.assertEqual(r["basis"], "strongest")
def test_a_great_benchmark_never_rescues_a_thick_bad_record(self):
cands = [cand("great-1", cost=1.0, standing=99.0), cand("ok-1", cost=30.0, standing=70.0)]
recs = attempts("t/great-1", KIND, 3, 3, 7)
self.assertEqual(chosen(cands, recs, 3), "t/ok-1")
# a bad record at difficulty 3 says nothing about difficulty 1: there the cheaper great-1 is fine
self.assertEqual(chosen(cands, recs, 1), "t/great-1")
def test_a_bad_record_at_an_easier_difficulty_also_blocks_the_benchmark(self):
cands = [cand("great-1", cost=1.0, standing=99.0), cand("ok-1", cost=30.0, standing=98.0)]
recs = attempts("t/great-1", KIND, 2, 2, 8)
self.assertEqual(chosen(cands, recs, 3), "t/ok-1")
self.assertEqual(chosen(cands, recs, 2), "t/ok-1")
def test_a_thin_record_of_repeated_rejections_cancels_the_prior(self):
cands = [cand("cheap-1", cost=0.2, standing=40.0), cand("mid-1", cost=4.0, standing=64.0)]
recs = attempts("t/cheap-1", KIND, 2, 0, 2)
r = pick(cands, recs, 2)
self.assertEqual(r["choice"]["worker"], "t/mid-1")
self.assertTrue(r["assessments"]["t/cheap-1"]["contradicted"])
def test_every_usable_worker_poor_still_names_the_best_rate(self):
cands = [cand("a-1", cost=1.0), cand("b-1", cost=2.0)]
recs = attempts("t/a-1", KIND, 2, 1, 9) + attempts("t/b-1", KIND, 2, 4, 6)
r = pick(cands, recs, 2)
self.assertEqual(r["choice"]["worker"], "t/b-1")
self.assertEqual(r["basis"], "all-bad")
def test_equal_evidence_and_price_is_stable_and_explained(self):
cands = [cand("b-1", cost=2.0, standing=60.0), cand("a-1", cost=2.0, standing=60.0)]
for _ in range(3):
r = pick(list(reversed(cands)), [], 3)
self.assertEqual(r["choice"]["worker"], "t/a-1")
text = " ".join(reason for _w, reason in r["passed_over"])
self.assertIn("equal on price and load", text)
def test_a_single_usable_worker_is_recommended_whatever_it_knows(self):
for d in (1, 2, 3):
self.assertEqual(chosen([cand("only-1")], [], d), "t/only-1")
self.assertEqual(chosen([cand("only-1", standing=5.0)], [], d), "t/only-1")
self.assertEqual(pick([cand("only-1")], [], 3)["basis"], "nothing")
def test_the_existing_constraints_still_hold(self):
cands = [cand("a-1", cost=1.0, standing=60.0), cand("b-1", cost=2.0, standing=60.0),
cand("c-contributor-1", cost=0.1, standing=60.0), cand("d-1", cost=0.5, standing=60.0, usable=False)]
r = pick(cands, [], 2, review_of="t/a-1")
self.assertEqual(r["choice"]["worker"], "t/b-1") # another maker reviews
reasons = dict(r["passed_over"])
self.assertIn("trains on prompts", reasons["t/c-contributor-1"])
self.assertIn("t/d-1", reasons)
avoided = pick(cands, [], 2, avoid=[{"pattern": "a-1", "why": "mine"}])
self.assertEqual(avoided["choice"]["worker"], "t/b-1")
preferred = pick(cands, [], 2, prefer=[{"pattern": "b-1"}])
self.assertEqual(preferred["choice"]["worker"], "t/b-1")
down = routing.choose(cands, [], {"t": {"retry_at": 5000.0, "reason": "limit"}}, KIND, 2, now=1000.0)
self.assertIsNone(down["choice"])
def test_the_two_scales_are_never_compared(self):
"""R-7.2-2: V (standing 60, the best) is cheaper than W (standing 50, but 10 of 10 accepted here). At
difficulty 3 both are capable (V on 60 against its own best, W on its record) and the cheapest, V, wins. A
comparison of W's accepted rate (100) with a standing would make 100 the 'best' and V (60) incapable."""
cands = [cand("v-1", cost=1.0, standing=60.0), cand("w-1", cost=5.0, standing=50.0)]
recs = attempts("t/w-1", KIND, 3, 10, 0)
r = pick(cands, recs, 3)
self.assertEqual(r["choice"]["worker"], "t/v-1")
self.assertEqual(r["best_standing"], 60.0)
def test_a_standing_scaled_by_any_factor_changes_nothing(self):
rng = random.Random(7)
for _ in range(60 * ITERS):
cands, recs = gen_world(rng)
for d in (1, 2, 3):
base = pick(cands, recs, d)
for k in (0.01, 0.37, 3.0, 40.0):
scaled = [dict(c, standing=(c["standing"] * k if c["standing"] is not None else None)) for c in cands]
got = pick(scaled, recs, d)
self.assertEqual((got["choice"] or {}).get("worker"), (base["choice"] or {}).get("worker"), (d, k))
self.assertEqual(got["basis"], base["basis"])
def gen_world(rng, kinds=("research", "edit")):
"""Generated workers and a judged ledger: prices, plans, standings (or none), cells of every size."""
cands, recs = [], []
for i in range(rng.randint(1, 6)):
flat = rng.random() < 0.2
c = cand("w%d-%d" % (i, rng.randint(0, 9)), cost=None if flat else rng.choice([None, 0.2, 1.0, 4.0, 8.0, 30.0]),
standing=rng.choice([None, None, rng.uniform(10, 100)]), plan="flat" if flat else rng.choice(["per-use", None]),
allowance=rng.choice([None, 40, 90]) if flat else None)
cands.append(c)
for kind in kinds:
for d in (1, 2, 3):
n = rng.choice([0, 0, 2, 3, 8, 8, 12, 30])
good = rng.randint(0, n)
recs += attempts(c["worker"], kind, d, good, n - good)
rng.shuffle(recs)
return cands, recs
class CapabilityPropertyTests(unittest.TestCase):
def test_raising_the_difficulty_never_gives_weaker_evidence(self):
"""R-7.2-2, R-7.2-3: for the same data, a worker capable at difficulty d+1 is capable at d, its evidence at d is
at least as strong, and the worker chosen for a harder task on evidence is capable on the easier one."""
rng = random.Random(20261123)
for _ in range(300 * ITERS):
cands, recs = gen_world(rng)
runs = {d: pick(cands, recs, d) for d in (1, 2, 3)}
for d in (1, 2):
lo, hi = runs[d]["assessments"], runs[d + 1]["assessments"]
for w in lo:
self.assertLessEqual(hi[w]["capable"], lo[w]["capable"], (d, w, lo[w], hi[w]))
self.assertGreaterEqual(lo[w]["level"], hi[w]["level"], (d, w, lo[w], hi[w]))
got = runs[d + 1]["choice"]
if got is not None and runs[d + 1]["basis"] == "capable":
self.assertTrue(lo[got["worker"]]["capable"], (d, got["worker"]))
def test_a_capable_worker_that_is_as_good_and_cheaper_is_never_passed_over(self):
"""R-7.2-2: the choice is the cheapest of the capable workers (a prefer pattern aside, none here)."""
rng = random.Random(4242)
for _ in range(300 * ITERS):
cands, recs = gen_world(rng)
for d in (1, 2, 3):
r = pick(cands, recs, d)
if r["choice"] is None or r["basis"] != "capable":
continue
x = r["choice"]
price = lambda c: (routing._price_tier(c), c["cost"] if c.get("cost") is not None else float("inf"))
for c in cands:
a = r["assessments"].get(c["worker"])
if a and a["capable"] and c["worker"] != x["worker"]:
self.assertGreaterEqual(price(c), price(x), (d, c["worker"], x["worker"]))
def test_a_thick_bad_record_is_never_chosen_over_a_usable_worker_without_one(self):
"""R-7.2-3, R-7.3-3."""
rng = random.Random(99)
seen = 0
for _ in range(400 * ITERS):
cands, recs = gen_world(rng)
for d in (1, 2, 3):
r = pick(cands, recs, d)
if r["choice"] is None:
continue
cell = routing._cell(r["stats"], r["choice"]["worker"], KIND, d)
if cell["n"] >= routing.MIN_ATTEMPTS and cell["good"] / cell["n"] < routing.MIN_ACCEPTED_RATE:
seen += 1
self.assertTrue(all(a["bad"] for a in r["assessments"].values()), (d, r["choice"]["worker"]))
self.assertGreater(seen, 0, "the generator never produced the case it is meant to test")
def test_the_choice_does_not_depend_on_candidate_order(self):
rng = random.Random(5)
for _ in range(120 * ITERS):
cands, recs = gen_world(rng)
d = rng.choice([1, 2, 3])
a = chosen(cands, recs, d)
b = chosen(list(reversed(cands)), recs, d)
self.assertEqual(a, b)
if __name__ == "__main__":
unittest.main()
+2 -1
View File
@@ -4,7 +4,8 @@ import ast, collections, glob, os, re, unittest
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Seams that are documented and exercised by real-behaviour tests (docs/evaluation.md); keep them.
SEAMS = {"validate_check", "capture_case", "compare_for_candidate"}
# retry_choice is the pure ladder the `sisi route --retry-of` command calls; it lands with that command.
SEAMS = {"validate_check", "capture_case", "compare_for_candidate", "retry_choice"}
def _files():
+2 -2
View File
@@ -366,8 +366,8 @@ class ExplorationTests(unittest.TestCase):
]
# Same price: alpha (proven, stronger prior) is the usual pick. Every tenth judged
# attempt for the kind and difficulty, the thin-record beta gets the task instead.
cands[0]["prior_score"] = 90.0
cands[1]["prior_score"] = 10.0
cands[0]["standing"] = 90.0
cands[1]["standing"] = 10.0
records = [{"kind": "attempt", "id": "e%d" % i, "type": "read", "difficulty": 1,
"worker": "tool/alpha-1", "outcome": "accepted", "check": "tests"}
for i in range(9)]