sahiljagtap's picture
Drums launch benchmarks reproduction + paired Drums/Prime/E2B re-run (scrubbed)
4ef198a
Raw History Blame Contribute Delete
3.65 kB
"""appcompat.py OUT CYCLES TASK...: the app-compat pipeline (runbooks/app-compat/20261029T2020Z §3) through the installed
drumsd: per task and cycle, a parent with the OSWorld setup; capture + 8 children (fork(8)); every child must come up
valid (every gate, no_app_crash included) and score the same as the parent; no child may see a sibling's canary file;
then one child is reset and must be valid with the same score and without its canary. Records one row per child."""
import json
import os
import sys
import time
import drums
OUT, CYCLES = sys.argv[1], int(sys.argv[2])
os.makedirs(OUT, exist_ok=True)
log = open(os.path.join(OUT, "appcompat.jsonl"), "a")
def rec(**kw):
kw["t"] = round(time.time(), 3)
log.write(json.dumps(kw, default=str) + "\n")
log.flush()
print(json.dumps(kw, default=str)[:400], flush=True)
def sh(env, cmd):
return env.step({"type": "execute", "command": cmd, "shell": True}, check=False).result
with drums.connect() as c:
for tid in sys.argv[3:]:
for cyc in range(1, CYCLES + 1):
t0 = time.monotonic()
row = {"task": tid, "cycle": cyc}
try:
with c.create(task=tid) as p:
p.wait_valid()
pr = p.verify(strict=False)
row["parent"] = {"env": p.id, "score": pr.score, "valid": pr.valid, "reasons": pr.invalid_reasons}
tf = time.monotonic()
with p.fork(8, keep_state=False) as kids:
row["fork_s"] = round(time.monotonic() - tf, 3)
kids_rows = []
for k in kids:
sh(k, f"echo {k.id} > /tmp/drums-canary-{k.id}")
for k in kids:
k.wait_valid() if False else k.valid(timeout=30)
seen = (sh(k, "ls /tmp | grep drums-canary || true").get("output") or "").split()
r = k.verify(strict=False)
kr = {"env": k.id, "score": r.score, "valid": r.valid, "verdict": r.verdict, "bad_gates": r.bad_gates,
"reasons": r.invalid_reasons, "checker_error": r.checker_error,
"foreign_canary": [s for s in seen if s != f"drums-canary-{k.id}"]}
kids_rows.append(kr)
rec(task=tid, cycle=cyc, child=kr)
k = kids[0]
k.reset()
k.valid(timeout=30)
r = k.verify(strict=False)
canary = (sh(k, f"test -e /tmp/drums-canary-{k.id} && echo present || echo gone").get("output") or "").strip()
row["reset"] = {"env": k.id, "score": r.score, "valid": r.valid, "reasons": r.invalid_reasons, "canary": canary}
row["children"] = kids_rows
ok_children = [x for x in row["children"] if x["valid"] and x["score"] == row["parent"]["score"] and not x["foreign_canary"]]
row["children_ok"] = len(ok_children)
row["pass"] = (row["parent"]["valid"] and len(ok_children) == 8 and row["reset"]["valid"]
and row["reset"]["score"] == row["parent"]["score"] and row["reset"]["canary"] == "gone")
except Exception as e: # noqa: BLE001
row.update(error=f"{type(e).__name__}: {str(e)[:600]}", **{"pass": False})
row["seconds"] = round(time.monotonic() - t0, 3)
rec(**{k: v for k, v in row.items() if k != "children"}, summary=True)