Build the evaluation harness: benchmark cases, isolated replay, comparison, shadow evaluation and independent judging
This commit is contained in:
1 parent
57ec5e8f58
commit
9b3ea74ffc
5 files changed
+1383
-1
No files matched your search
+10
@@ -91,6 +91,10 @@ A shared rulebook and enforced definitions of done for every AI coding CLI.
|
||||
sisi delegate judge ID --outcome accepted|rejected --check none|diffstat|tests|read|review [--minutes 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
|
||||
sisi delegate amend ID | recent [-n N] [--project P] mark a judged delegation that later proved wrong; list recent judgements to find an id
|
||||
sisi eval list|add|run|compare|shadow|judge|status|import
|
||||
the evaluation harness: benchmark cases from real work, isolated
|
||||
replay, policy comparison and independent judging (see docs/evaluation.md);
|
||||
`sisi eval` alone prints status; run without --tasks replays check cases only
|
||||
sisi version | --version print the product version (the VERSION file in the product folder)
|
||||
sisi help this text
|
||||
|
||||
@@ -460,6 +464,12 @@ def main(argv):
|
||||
if cmd == "delegate":
|
||||
from . import workers
|
||||
return workers.cmd_delegate(args)
|
||||
if cmd == "eval":
|
||||
from . import evaluate
|
||||
return evaluate.cmd_eval(args)
|
||||
if cmd in ("tasks", "checks"):
|
||||
from . import evaluate
|
||||
return evaluate.cmd_folded(cmd, args)
|
||||
rc = _learn_cli(cmd, args)
|
||||
if rc is not None:
|
||||
return rc
|
||||
|
||||
+1309
File diff suppressed because it is too large.
Load diff
@@ -91,6 +91,15 @@ def estimate_start(root, t0):
|
||||
return out if rc == 0 and out else None
|
||||
|
||||
|
||||
def fix_commit_of(commits):
|
||||
"""The fix commit of a harvested task: the last following commit recorded for the
|
||||
session (commits are [{"sha": ...}] in chronological record order). None when there
|
||||
were no following commits, so such a task can seed a task case but not a check case."""
|
||||
shas = [(c.get("sha") if isinstance(c, dict) else c) for c in (commits or [])]
|
||||
shas = [s for s in shas if s]
|
||||
return shas[-1] if shas else None
|
||||
|
||||
|
||||
def commit_exists(root, sha):
|
||||
rc, _ = _git(root, "cat-file", "-e", str(sha) + "^{commit}")
|
||||
return rc == 0
|
||||
|
||||
@@ -246,6 +246,60 @@ def get_task(con, tid):
|
||||
return dict(rows[0]) if len(rows) == 1 else None
|
||||
|
||||
|
||||
def to_benchmark_case(row, commits=None):
|
||||
"""One harvested task as an evaluation-harness benchmark case (see sisi/evaluate.py),
|
||||
or None when it is not replayable: only human tasks graded A or B with a test command,
|
||||
a repository and a start commit qualify. The fix commit is the last following commit
|
||||
ground truth recorded. The dev/holdout split is the same deterministic id hash as the
|
||||
task itself, so importing never moves a case between splits. The product ships no such
|
||||
case: they are built only from the user's own harvested sessions, into the user store."""
|
||||
try:
|
||||
t = dict(row)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
if t.get("kind") not in (None, "human"):
|
||||
return None
|
||||
if t.get("grade") not in ("A", "B"):
|
||||
return None
|
||||
test_cmd = t.get("test_cmd")
|
||||
repo, start = t.get("repo_root") or t.get("repo"), t.get("start_commit")
|
||||
if not test_cmd or not repo or not start or not (t.get("request") or "").strip():
|
||||
return None
|
||||
from . import groundtruth
|
||||
if commits is None:
|
||||
try:
|
||||
commits = json.loads(t.get("commits") or "[]")
|
||||
except (TypeError, ValueError):
|
||||
commits = []
|
||||
fix = groundtruth.fix_commit_of(commits)
|
||||
return {"id": str(t.get("id")), "kind": "task",
|
||||
"source": {"unit": str(t.get("session_id") or ""), "learning": ""},
|
||||
"project": {"repo": str(repo), "start_commit": str(start), "fix_commit": str(fix or "")},
|
||||
"request": t.get("request"),
|
||||
"checks": [{"id": "tests", "cmd": str(test_cmd), "expect": {"exit": 0}}],
|
||||
"tags": ["harvested"],
|
||||
"split": t.get("split") if t.get("split") in ("dev", "holdout") else split_of(t.get("id")),
|
||||
"added": time.strftime("%Y-%m-%d", time.gmtime())}
|
||||
|
||||
|
||||
def benchmark_cases(con):
|
||||
"""All replayable harvested tasks as benchmark cases, ordered by task id."""
|
||||
rows = con.execute(
|
||||
"SELECT t.*, g.commits FROM tasks t LEFT JOIN groundtruth g ON g.session_id=t.session_id "
|
||||
"WHERE t.kind='human' ORDER BY t.id")
|
||||
out = []
|
||||
for r in rows:
|
||||
t = dict(r)
|
||||
try:
|
||||
commits = json.loads(t.pop("commits") or "[]")
|
||||
except (TypeError, ValueError):
|
||||
commits = []
|
||||
case = to_benchmark_case(t, commits)
|
||||
if case:
|
||||
out.append(case)
|
||||
return out
|
||||
|
||||
|
||||
def counts(con):
|
||||
"""{kind: {grade: {split: n}}} for the scoreboard."""
|
||||
out = {}
|
||||
|
||||
@@ -148,7 +148,7 @@ class TaskReplayTests(EvalCase):
|
||||
c = fixture_case(self, "task-case.json")
|
||||
saved = os.environ.pop("SISI_EVAL_WORKER_CMD", None)
|
||||
try:
|
||||
r = self.ev.run_case(c, store_dir=self.store, worker_runner=lambda **kw: None)
|
||||
r = self.ev.run_case(c, store_dir=self.store, worker_runner=lambda *a, **kw: None)
|
||||
finally:
|
||||
if saved:
|
||||
os.environ["SISI_EVAL_WORKER_CMD"] = saved
|
||||
|
||||
Reference in new issue
Block a user