Items 7-9: per-provider plans, exact provider scoping of constraints and marks, the owner's vouch (relayed counts to 2), allowance probes (key fetched at probe time, never stored, no redirects, owner approval) and provider failure phrases. done / next: owner setup on a copy of the store, real runs, report
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a12dccf16
commit
a03102aba9
7 files changed
+1310
-45
No files matched your search
+44
-10
@@ -115,14 +115,19 @@ def _floor_pct(floors, difficulty):
|
||||
|
||||
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."""
|
||||
worker, model or tool name, case aside; a pattern ending in `/` is a provider and matches only
|
||||
the workers whose id starts with it (`a-b/` never reaches `a-b-c/x` or a model named `a-b`)."""
|
||||
hay = " ".join(str(x or "").lower() for x in (c.get("worker"), c.get("model"), c.get("tool")))
|
||||
worker = str(c.get("worker") or "").lower()
|
||||
for entry in patterns or []:
|
||||
if isinstance(entry, dict):
|
||||
pat, why = str(entry.get("pattern") or ""), str(entry.get("why") or "")
|
||||
else:
|
||||
pat, why = str(entry), ""
|
||||
if pat and pat.lower() in hay:
|
||||
if pat.endswith("/"): # `provider/` names one provider exactly: the start of the worker id, never a part of another name
|
||||
if worker.startswith(pat.lower()):
|
||||
return pat, why
|
||||
elif pat and pat.lower() in hay:
|
||||
return pat, why
|
||||
return None
|
||||
|
||||
@@ -144,12 +149,22 @@ def _availability_keys(c):
|
||||
return keys
|
||||
|
||||
|
||||
def provider_of(worker):
|
||||
"""The part of a worker id before the first slash, lower case, or None."""
|
||||
w = str(worker or "")
|
||||
return w.split("/", 1)[0].lower() if "/" in w else None
|
||||
|
||||
|
||||
def _down_entry(c, availability, now):
|
||||
keys = _availability_keys(c)
|
||||
prov = provider_of(c.get("worker"))
|
||||
for k, e in (availability or {}).items():
|
||||
if not isinstance(e, dict):
|
||||
if not isinstance(e, dict) or not float(e.get("retry_at") or 0) > now:
|
||||
continue
|
||||
if str(k).lower() in keys and float(e.get("retry_at") or 0) > now:
|
||||
if e.get("scope") == "provider": # a mark made for one provider reaches that provider's workers only
|
||||
if str(k).lower() == prov:
|
||||
return e
|
||||
elif str(k).lower() in keys:
|
||||
return e
|
||||
return None
|
||||
|
||||
@@ -191,7 +206,7 @@ def _cell(stats, worker, kind, difficulty):
|
||||
|
||||
# ---------------------------------------------------------------- capability evidence
|
||||
|
||||
_TIER_RANK = {"a": 0, "b-higher": 1, "b-all": 2} # smaller is closer to the request
|
||||
_TIER_RANK = {"a": 0, "b-higher": 1, "vouch": 1.5, "b-all": 2} # smaller is closer to the request
|
||||
_NO_CELL = {"n": 0, "good": 0}
|
||||
|
||||
|
||||
@@ -231,7 +246,7 @@ def _by_difficulty(stats, worker, kind):
|
||||
return own, pooled
|
||||
|
||||
|
||||
def assess(stats, worker, kind, difficulty, standing=None, best_standing=None, floors=None):
|
||||
def assess(stats, worker, kind, difficulty, standing=None, best_standing=None, floors=None, vouch=0):
|
||||
"""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
|
||||
@@ -241,7 +256,9 @@ def assess(stats, worker, kind, difficulty, standing=None, best_standing=None, f
|
||||
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."""
|
||||
Standing is compared only with the best standing; a rate only with the bar.
|
||||
`vouch` is the difficulty up to which the owner vouched for the worker: a judged proof outranks it, a thick bad
|
||||
record or a thin one with repeated rejections cancels it, and it outranks a benchmark (tier "vouch")."""
|
||||
d = difficulty
|
||||
own, pooled = _by_difficulty(stats, worker, kind)
|
||||
out = {"tier": "none", "capable": False, "bad": False, "weak": False, "contradicted": False,
|
||||
@@ -275,6 +292,9 @@ def assess(stats, worker, kind, difficulty, standing=None, best_standing=None, f
|
||||
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 vouch and isinstance(d, int) and d <= vouch and not out["contradicted"]:
|
||||
out.update(tier="vouch", capable=True, level=3, at=vouch, measure=0.0)
|
||||
return out
|
||||
if standing is not None:
|
||||
pct = _floor_pct(floors, d)
|
||||
needed = (best_standing or 0.0) * pct / 100.0
|
||||
@@ -314,6 +334,13 @@ def _standing_of(c):
|
||||
# ---------------------------------------------------------------- the pool, then the choice
|
||||
|
||||
|
||||
def vouch_level(c):
|
||||
"""The difficulty up to which the owner's word makes this candidate capable (0 for none)."""
|
||||
v = c.get("vouch")
|
||||
lvl = v.get("level") if isinstance(v, dict) else 0
|
||||
return lvl if isinstance(lvl, int) and not isinstance(lvl, bool) and lvl > 0 else 0
|
||||
|
||||
|
||||
def _prepare(candidates, records, availability, now, exclude, avoid, review_of, difficulty=None):
|
||||
"""The workers that may be recommended at all: (eligible, passed, stats, author_maker). An unproven
|
||||
worker (flagged by workers.build_candidates: new, with fewer than MIN_ATTEMPTS judged attempts) is
|
||||
@@ -331,7 +358,7 @@ def _prepare(candidates, records, availability, now, exclude, avoid, review_of,
|
||||
if "contributor" in str(c.get("model") or w).lower():
|
||||
passed.append((w, "its id contains 'contributor', a tier that trains on prompts"))
|
||||
continue
|
||||
if c.get("unproven") and isinstance(difficulty, int) and difficulty > 1:
|
||||
if c.get("unproven") and isinstance(difficulty, int) and difficulty > max(1, vouch_level(c)):
|
||||
passed.append((w, "unproven: a new worker with no judged record is offered routine work (difficulty 1) only"))
|
||||
continue
|
||||
down = _down_entry(c, availability, now)
|
||||
@@ -379,7 +406,7 @@ 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)
|
||||
return ({c["worker"]: assess(stats, c["worker"], kind, difficulty, _standing_of(c), best, floors, vouch_level(c))
|
||||
for c in eligible}, best)
|
||||
|
||||
|
||||
@@ -419,7 +446,7 @@ def _prefer_judged(capable, assessments, difficulty):
|
||||
those capable by the judged record across all kinds; failing that, everyone capable."""
|
||||
if difficulty is None or difficulty < 2:
|
||||
return list(capable), False
|
||||
for tiers in (("a", "b-higher"), ("b-all",)):
|
||||
for tiers in (("a", "b-higher", "vouch"), ("b-all",)):
|
||||
own = [c for c in capable if assessments[c["worker"]]["tier"] in tiers]
|
||||
if own:
|
||||
return own, True
|
||||
@@ -556,6 +583,8 @@ def _why_not(a, difficulty, basis, cheaper):
|
||||
if a["tier"] == "b-all":
|
||||
return (lead + "its only judged proof is across other kinds, and a worker with a judged record "
|
||||
"for this kind is usable", None)
|
||||
if a["tier"] == "vouch":
|
||||
return (lead + "capable by the owner's word, and a worker with a judged record for this kind is usable", None)
|
||||
return (lead + "capable only by benchmark standing or as an exploration; above difficulty 1 a worker "
|
||||
"with a judged record is preferred to a benchmark",
|
||||
("standing %g" % a["standing"]) if a["standing"] is not None else None)
|
||||
@@ -665,6 +694,11 @@ def evidence_line(a, kind, difficulty, choice, basis):
|
||||
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 == "vouch":
|
||||
v = choice.get("vouch") or {}
|
||||
return ("evidence (the owner's word): vouched for up to difficulty %d%s (%s, %s); it ranks with judged proof "
|
||||
"until its own record is thick" % (a["at"], " (relayed by an agent: counted up to difficulty 2 only)"
|
||||
if v.get("relayed") else "", _short(v.get("why")), v.get("date") or "no date stated"))
|
||||
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"):
|
||||
|
||||
Reference in new issue
Block a user