O6: telemetry report and eval task set (#14)
This commit was merged in pull request #14.
This commit is contained in:
1 parent
bea07e82bb
commit
b2d72f2dc9
31 files changed
+809
-3
No files matched your search
@@ -268,6 +268,54 @@ assert len((tmp / "g-audit.log").read_text().splitlines()) == 4
|
||||
# warning for unrestricted profiles
|
||||
assert "no `allow` list" in run("warn", "p", body="WRITE").stderr
|
||||
|
||||
# --- telemetry, report, eval, bench (O6) ---
|
||||
tel = tmp / "state/telemetry.jsonl"
|
||||
recs = [json.loads(l) for l in tel.read_text().splitlines() if l.strip()]
|
||||
assert len(recs) >= 30, len(recs)
|
||||
ok_rec = next(r for r in recs if r["task"] == "ok")
|
||||
assert (ok_rec["status"], ok_rec["profile"], ok_rec["hx_version"], ok_rec["input_tokens"], ok_rec["attempts"]) == ("done", "p", "hx 9.9.9", 100, 1), ok_rec
|
||||
assert next(r for r in recs if r["task"] == "nowrite")["status"] == "needs-human"
|
||||
assert next(r for r in recs if r["task"] == "nowrite")["attempts"] == 3
|
||||
assert any(r["status"] == "requeued" for r in recs)
|
||||
rep = subprocess.run([orch, "report"], env=env, capture_output=True, text=True).stdout
|
||||
assert "hx 9.9.9" in rep and "profile" in rep and rep.splitlines()[-1].startswith("retries"), rep
|
||||
allrow = next(l for l in rep.splitlines() if l.startswith("all"))
|
||||
assert allrow.split()[1] == str(len([r for r in recs])), (allrow, len(recs))
|
||||
# a half-written line (crash) is skipped and does not hide the next record
|
||||
with open(tel, "a") as f:
|
||||
f.write('{"ts": 1, "run": "cut')
|
||||
run("after-cut", "p", body="WRITE")
|
||||
rep2 = subprocess.run([orch, "report"], env=env, capture_output=True, text=True)
|
||||
assert "skipped 1 unreadable" in rep2.stderr and rep2.returncode == 0, rep2
|
||||
assert len(subprocess.run([orch, "report"], env=env, capture_output=True, text=True).stdout.splitlines()) == len(rep.splitlines()) # same table shape
|
||||
|
||||
# bench: the shipped eval cases, with a fake hx that solves every case but one
|
||||
ev = root / "eval"
|
||||
chk = subprocess.run([orch, "bench", str(ev), "--check"], env=env, capture_output=True, text=True)
|
||||
assert chk.returncode == 0 and chk.stdout.count("untouched=fail solved=pass") == 4, chk
|
||||
profile("bb", f'env = ["SOLVE_DIR", "SOLVE_SKIP", "FAKE_VERSION"]\ngate = "false"\nmax_retries = 0\n')
|
||||
a_out, b_out = tmp / "a.jsonl", tmp / "b.jsonl"
|
||||
benv = {**env, "SOLVE_DIR": str(ev)}
|
||||
pa = subprocess.run([orch, "bench", str(ev), "--profile", "bb", "--out", str(a_out), "--repeat", "2"], env={**benv, "FAKE_VERSION": "1.0"}, capture_output=True, text=True)
|
||||
assert pa.returncode == 0, pa # every case solved; the profile gate ("false") is replaced by the case's gate.sh
|
||||
pb = subprocess.run([orch, "bench", str(ev), "--profile", "bb", "--out", str(b_out)], env={**benv, "SOLVE_SKIP": "rename-symbol", "FAKE_VERSION": "2.0"}, capture_output=True, text=True)
|
||||
assert pb.returncode == 1, pb # one case unsolved -> bench exit 1
|
||||
ra, rb = report_load = [[json.loads(l) for l in f.read_text().splitlines() if l.strip()] for f in (a_out, b_out)]
|
||||
assert len(ra) == 8 and {r["hx_version"] for r in ra} == {"hx 1.0"} and {r["task"] for r in ra} == {"add-function", "fix-off-by-one", "fix-typo-readme", "rename-symbol"}
|
||||
assert [r["status"] for r in rb if r["task"] == "rename-symbol"] == ["needs-human"] and len(rb) == 4
|
||||
ev_out = subprocess.run([orch, "eval", str(a_out), str(b_out)], env=env, capture_output=True, text=True)
|
||||
assert ev_out.returncode == 1 and "REGRESSION" in ev_out.stdout and "-25 pp" in ev_out.stdout, ev_out
|
||||
line = next(l for l in ev_out.stdout.splitlines() if l.startswith("rename-symbol"))
|
||||
assert line.split()[1:3] == ["2/2", "0/1"], line
|
||||
ev_ok = subprocess.run([orch, "eval", str(b_out), str(a_out)], env=env, capture_output=True, text=True)
|
||||
assert ev_ok.returncode == 0 and "REGRESSION" not in ev_ok.stdout and "+25 pp" in ev_ok.stdout, ev_ok # B better than A: no failure
|
||||
# a broken case set is caught by --check
|
||||
broken = tmp / "broken"
|
||||
shutil.copytree(ev, broken)
|
||||
(broken / "add-function/solution/text.py").write_text("def slugify(s):\n return s\n")
|
||||
bad = subprocess.run([orch, "bench", str(broken), "--check"], env=env, capture_output=True, text=True)
|
||||
assert bad.returncode == 1 and "broken case" in bad.stdout, bad
|
||||
|
||||
# kill orch mid-run: status must say interrupted and hx must be dead after the next orch call
|
||||
pidfile = tmp / "hx.pid"
|
||||
p = subprocess.Popen([orch, "run", str(task("killed", "HANG")), "--repo", str(repo), "--profile", "p"],
|
||||
|
||||
Reference in new issue
Block a user