volt: tool_map grades the tree it lives in, not the one it was written in

DEFAULT_REPO was the absolute /root/troupe-standup, so a copy's
`--selftest` -- the invocation selftest_sweep.py uses, no --repo, cwd =
the tree under sweep -- graded the home checkout and reported the copy
clean. Derived from __file__ instead: the default is the checkout the
tool lives in. Measured on a clone at c3058d5 with drifted docs: before,
repo-less --selftest 20/20 rc 0 vs --repo . 19/20 rc 1; after, 19/20
rc 1 both ways.

Also in this commit:
- verify.run_leg: one elapsed-ms clock (_elapsed_ms) and one except arm
  for TimeoutExpired/OSError, instead of three copies of the arithmetic;
- write_probe c13: roster read from FLAG_PROBES rather than a hardcoded
  three, and selftest_sweep.py --write-baseline added to the table;
- docs/TOOLS.md: the selftest_sweep row grows the flags it now prints.
This commit is contained in:
volt committed 2026-10-22 17:08:40 +00:00
1 parent 2a1ef2feaf
commit b859ad6464
4 files changed
+70 -36

No files matched your search

+34 -23
View File
@@ -361,6 +361,16 @@ def leg_argv(key, repo, queue, index, checkin_day=None):
raise KeyError(key)
def _elapsed_ms(started):
"""Milliseconds elapsed since `started`; the integer clock every row carries.
Extracted so run_leg() does not recompute `int((time.time() - started) * 1000)`
at each of its exit paths -- the DRY collapse that previously ran the same
expression three times (timeout, OSError, normal verdict).
"""
return int((time.time() - started) * 1000)
def run_leg(leg, repo, queue, index, timeout, checkin_day=None):
"""One leg -> one row. rc 0/1/2 are graded; anything else is ungradable."""
tool = os.path.join(repo, "tools", leg["tool"])
@@ -384,30 +394,31 @@ def run_leg(leg, repo, queue, index, timeout, checkin_day=None):
proc = subprocess.run(leg_argv(leg["key"], repo, queue, index, day),
cwd=repo, capture_output=True, text=True,
timeout=timeout)
except subprocess.TimeoutExpired:
row.update(verdict=UNGRADABLE, detail="TIMEOUT after %ss" % timeout)
row["ms"] = int((time.time() - started) * 1000)
return row
except OSError as exc:
row.update(verdict=UNGRADABLE, detail="could not run: %s" % exc)
row["ms"] = int((time.time() - started) * 1000)
return row
out = (proc.stdout or "") + (proc.stderr or "")
row["rc"] = proc.returncode
row["detail"] = pick_detail(out, summary=(proc.returncode == 0))
if proc.returncode == 0:
row["verdict"] = PASS
elif proc.returncode == 1:
row["verdict"] = FAULT
elif proc.returncode == 2:
row["verdict"] = UNGRADABLE
except (subprocess.TimeoutExpired, OSError) as exc:
# Both transport failures collapse to the same ungradable shape; only the
# detail differs -- timeout names the deadline, OSError names the error.
if isinstance(exc, subprocess.TimeoutExpired):
detail = "TIMEOUT after %ss" % timeout
else:
detail = "could not run: %s" % exc
row.update(verdict=UNGRADABLE, detail=detail)
else:
# rc 3 is retired in this repo (one meaning, two codes); any other code
# is a tool that left the contract, and the run cannot grade through it.
row["verdict"] = UNGRADABLE
row["detail"] = "unexpected rc %d: %s" % (proc.returncode, row["detail"])
row["ms"] = int((time.time() - started) * 1000)
out = (proc.stdout or "") + (proc.stderr or "")
row["rc"] = proc.returncode
row["detail"] = pick_detail(out, summary=(proc.returncode == 0))
if proc.returncode == 0:
row["verdict"] = PASS
elif proc.returncode == 1:
row["verdict"] = FAULT
elif proc.returncode == 2:
row["verdict"] = UNGRADABLE
else:
# rc 3 is retired in this repo (one meaning, two codes); any other
# code is a tool that left the contract, and the run cannot grade
# through it.
row["verdict"] = UNGRADABLE
row["detail"] = "unexpected rc %d: %s" % (proc.returncode, row["detail"])
row["ms"] = _elapsed_ms(started)
return row