From ab479b36ecbde100726512711d5196cbb4c4cdfb Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Sat, 31 Oct 2026 21:21:44 +0200 Subject: [PATCH 1/6] feat(efficacy): show a run's scoring in progress.py, one bar per arm Below the run's bars, progress.py now draws the scoring once it starts: the trials scored per arm, their security readings, the trial being scored and the scorer's pace. It reads the scoring area's listing and the scorer's marker, and opens no score. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- docs/architecture/05-building-block-view.md | 2 +- tests/efficacy/progress.py | 131 +++++++++++++++++++- 2 files changed, 126 insertions(+), 7 deletions(-) diff --git a/docs/architecture/05-building-block-view.md b/docs/architecture/05-building-block-view.md index 7c27d48..65d4393 100644 --- a/docs/architecture/05-building-block-view.md +++ b/docs/architecture/05-building-block-view.md @@ -18,7 +18,7 @@ dependency with its keyword. | `generate_arm.py` | Makes one arm's file once: fixed text, one non-interactive generation from `agents.md`, under a line budget where the arm has one, or the emitter. Scans prompt and output for leaks, and refuses a file over its budget | `brief.txt`, the templates source | `arms//CLAUDE.md`, `generation.json` | | `harness.py` | Prepares each workspace, runs the agent in isolation, catches reach, freezes the result, keeps the run record current | The specs, the arm files, the change prompt | The run root | | `reuse.py` | Copies an earlier round's trials and readings into a new root, with their tool lock | An earlier root | The run root, the scoring area | -| `progress.py` | Watches a run: one bar per arm, its voided tries, its cost and the trial running, redrawn every 30 s. Read-only | The run records | The console | +| `progress.py` | Watches a run: one bar per arm, its voided tries, its cost and the trial running; then its scoring: one bar per arm, the security readings and the trial being scored. Redrawn every 30 s. Read-only | The run records, the scoring area | The console | | `score.py` | Installs each frozen trial cleanly, runs the hidden suite, the static tools and the adherence checklist, counts scope and cost | The run root, the hidden suite, `scoring-requirements.txt`, `toolconfig/` | `scores/`, `scores-change/` | | `probes.py` | The structural and web-quality probes, run inside the trial's own interpreter | A trial's tree | Its findings, to `score.py` | | `security.py` | Seeds each app, signs in its administrator, runs the 11 security and 3 data-protection probes | The scored trees | `security-scores/` | diff --git a/tests/efficacy/progress.py b/tests/efficacy/progress.py index e48cf77..f8173b4 100644 --- a/tests/efficacy/progress.py +++ b/tests/efficacy/progress.py @@ -1,8 +1,10 @@ -"""Show a run's progress, one bar per arm, read from its run records. +"""Show a run's progress, one bar per arm, read from its run records, and +its scoring's, read from the scoring area. -Read-only: it opens the run root's `run-*.json` and nothing else, so it can -watch a live run from a console of its own without touching a trial. It -redraws every `--every` seconds until stopped, or once with `--once`. +Read-only: it opens the run root's `run-*.json` and lists the scoring area, +so it can watch a live run or a live scoring from a console of its own +without touching a trial. It redraws every `--every` seconds until stopped, +or once with `--once`. """ import argparse @@ -19,8 +21,9 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import lib # noqa: E402 -from harness import (ROUND5_K, SCORABLE, VOIDING, arm_name, # noqa: E402 - now, result_of) +from harness import (ROUND5_K, SCORABLE, VOIDING, LiveRunError, # noqa: E402 + TrialError, arm_name, claim_path, now, read_claim, + result_of, running_as, scoring_area, split_name) from report import ROUND5_RUN # noqa: E402 WIDTH = 30 @@ -127,6 +130,87 @@ def render(root, arms=ROUND5_RUN, k=ROUND5_K, moment=None): summary += " %.1f h in, about %.0f h left" % ( elapsed.total_seconds() / 3600, left.total_seconds() / 3600) lines.append(summary) + return lines + scoring_lines(root, arms, k) + + +def names_in(directory): + """The trial names a directory holds a `.json` for, each with when + it was written.""" + try: + entries = os.listdir(directory) + except OSError: + return {} + return {entry[:-len(".json")]: + os.path.getmtime(os.path.join(directory, entry)) + for entry in entries if entry.endswith(".json")} + + +def arm_of(name): + """A trial name's arm, or None where the name is not a trial's.""" + try: + return split_name(name)[0] + except TrialError: + return None + + +def live_scorer(claim): + """Whether the scorer a marker names is still running.""" + try: + return running_as(claim["pid"], "score.py") + except LiveRunError: + return False + + +def scoring_lines(root, arms, k, alive=live_scorer): + """The scoring's lines: one bar per arm of trials scored, with their + security readings, and the trial being scored; none before scoring + starts.""" + area = scoring_area(root) + if not os.path.isdir(area): + return [] + scores = names_in(os.path.join(area, "scores")) + readings = names_in(os.path.join(area, "security-scores")) + lines = ["", "Scored"] + total = len(arms) * k + done = 0 + for name in arms: + scored = sum(1 for trial in scores if arm_of(trial) == name) + read = sum(1 for trial in readings if arm_of(trial) == name) + done += scored + line = "%-10s %s %2d/%d" % (name, bar(scored, k), scored, k) + if read: + line += " %d read for security" % read + lines.append(line) + summary = "%-10s %s %2d/%d" % ("all", bar(done, total), done, total) + + # The scorer marks the area while it runs. The trial it is on is the one + # whose working directory is there without a score yet; the pace is this + # scorer's own, from the scores it wrote since it started. + claim = read_claim(claim_path(area, "score.py")) + if claim and alive(claim): + work = os.path.join(area, "scoring") + try: + pending = [entry for entry in os.listdir(work) + if entry not in scores] + except OSError: + pending = [] + if pending: + current = max(pending, key=lambda entry: os.path.getmtime( + os.path.join(work, entry))) + summary += " scoring %s" % current + try: + begun = datetime.datetime.fromisoformat(claim["started"]) + except (KeyError, TypeError, ValueError): + begun = None + if begun is not None: + fresh = sum(1 for written in scores.values() + if written >= begun.timestamp()) + elapsed = time.time() - begun.timestamp() + summary += " %.1f h in" % (elapsed / 3600) + if fresh: + left = elapsed / fresh * (total - done) + summary += ", about %.1f h left" % (left / 3600) + lines.extend(["", summary]) return lines @@ -194,7 +278,28 @@ def drawn(root): return ["raised %r" % error] lines, old = drawn(scratch), drawn(legacy) + + # A scoring under way: two arms scored, one read for security, a trial + # in the scorer's working directory, and the scorer's marker. + area = scoring_area(scratch) + for folder, names in (("scores", ["none-1", "inline-1", "inline-2"]), + ("security-scores", ["none-1"])): + os.makedirs(os.path.join(area, folder)) + for name in names: + io.open(os.path.join(area, folder, "%s.json" % name), "w").close() + for name in ("inline-2", "hybrid-1"): + os.makedirs(os.path.join(area, "scoring", name)) + started_at = datetime.datetime.now() - datetime.timedelta(hours=1) + with io.open(claim_path(area, "score.py"), "w", encoding="utf-8") as handle: + json.dump({"pid": 4242, "tool": "score.py", + "started": started_at.isoformat(timespec="seconds")}, handle) + live = scoring_lines(scratch, ROUND5_RUN, ROUND5_K, + alive=lambda claim: True) + stale = scoring_lines(scratch, ROUND5_RUN, ROUND5_K, + alive=lambda claim: False) + shutil.rmtree(area, ignore_errors=True) shutil.rmtree(scratch, ignore_errors=True) + scored = {line.split()[0]: line for line in live[2:] if line.strip()} by_arm = {line.split()[0]: line for line in lines[2:] if line.strip()} old_by_arm = {line.split()[0]: line for line in old[2:] if line.strip()} checks = [ @@ -219,6 +324,20 @@ def drawn(root): ("a root without offsets draws its counts and reads no time", " 2/75 " in old_by_arm.get("all", "") and not any("min" in line or "h left" in line for line in old)), + ("before scoring starts, no scoring lines are drawn", + "Scored" not in lines and "Scored" not in old), + ("each arm's scored trials count toward its bar", + " 1/15" in scored.get("none", "") and " 2/15" in scored.get("inline", "") + and " 0/15" in scored.get("skills", "")), + ("an arm's security readings are counted beside it", + "1 read for security" in scored.get("none", "") + and "read for security" not in scored.get("inline", "")), + ("the trial being scored is named, not one already scored", + "scoring hybrid-1" in scored.get("all", "")), + ("the scoring's line counts every arm and estimates what is left", + " 3/75" in scored.get("all", "") and "h left" in scored.get("all", "")), + ("a scorer that has ended names no trial and no pace", + not any("scoring " in line or " h in" in line for line in stale)), ] for label, ok in checks: print(" %-52s %s" % (label, "ok" if ok else "FAILED")) From 42c25645227b5daf7ebff8ca285d2d00ab2f8495 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Sat, 31 Oct 2026 21:56:05 +0200 Subject: [PATCH 2/6] fix(efficacy): name the trial in hand by its directory's date, not a missing score The scorer's tools folder was a candidate for the trial being scored, and a rescore kept its old score, so the trial in hand was hidden. The trial in hand is now the newest trial directory changed since its result was written; the security pass is named the same way. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- tests/efficacy/progress.py | 99 ++++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 26 deletions(-) diff --git a/tests/efficacy/progress.py b/tests/efficacy/progress.py index f8173b4..cc00dfb 100644 --- a/tests/efficacy/progress.py +++ b/tests/efficacy/progress.py @@ -161,6 +161,27 @@ def live_scorer(claim): return False +def in_progress(work, written): + """The trial a tool is working on in `work`, or None. + + A tool rebuilds a trial's directory there before it writes the trial's + result, so the trial in hand is the newest directory changed since its + result was last written; one never written counts as changed. A rescore + keeps the old result until the new one is ready, so the old result's + presence alone does not say the trial is done. Directories that are not + a trial's, such as the scorer's tools, are never the trial in hand. + """ + try: + entries = [entry for entry in os.listdir(work) if arm_of(entry)] + except OSError: + return None + changed = [(os.path.getmtime(os.path.join(work, entry)), entry) + for entry in entries] + changed = [(when, entry) for when, entry in changed + if when > written.get(entry, 0)] + return max(changed)[1] if changed else None + + def scoring_lines(root, arms, k, alive=live_scorer): """The scoring's lines: one bar per arm of trials scored, with their security readings, and the trial being scored; none before scoring @@ -183,21 +204,17 @@ def scoring_lines(root, arms, k, alive=live_scorer): lines.append(line) summary = "%-10s %s %2d/%d" % ("all", bar(done, total), done, total) - # The scorer marks the area while it runs. The trial it is on is the one - # whose working directory is there without a score yet; the pace is this - # scorer's own, from the scores it wrote since it started. + # The scorer marks the area while it runs, scores each trial and then + # reads the scored ones for security; the pace is this scorer's own, from + # the scores it wrote since it started. claim = read_claim(claim_path(area, "score.py")) if claim and alive(claim): - work = os.path.join(area, "scoring") - try: - pending = [entry for entry in os.listdir(work) - if entry not in scores] - except OSError: - pending = [] - if pending: - current = max(pending, key=lambda entry: os.path.getmtime( - os.path.join(work, entry))) - summary += " scoring %s" % current + scoring = in_progress(os.path.join(area, "scoring"), scores) + reading = in_progress(os.path.join(area, "security"), readings) + if scoring: + summary += " scoring %s" % scoring + elif reading: + summary += " reading %s for security" % reading try: begun = datetime.datetime.fromisoformat(claim["started"]) except (KeyError, TypeError, ValueError): @@ -279,24 +296,47 @@ def drawn(root): lines, old = drawn(scratch), drawn(legacy) - # A scoring under way: two arms scored, one read for security, a trial - # in the scorer's working directory, and the scorer's marker. + # A scoring under way: two arms scored, one read for security, the + # scorer's tools, a scored trial's directory, the trial in hand, and the + # scorer's marker. Each file and directory is dated, newest last. area = scoring_area(scratch) - for folder, names in (("scores", ["none-1", "inline-1", "inline-2"]), - ("security-scores", ["none-1"])): - os.makedirs(os.path.join(area, folder)) - for name in names: - io.open(os.path.join(area, folder, "%s.json" % name), "w").close() - for name in ("inline-2", "hybrid-1"): - os.makedirs(os.path.join(area, "scoring", name)) + clock = time.time() - 3600 + + def dated(path, minutes, folder=False): + if folder: + os.makedirs(path, exist_ok=True) + else: + os.makedirs(os.path.dirname(path), exist_ok=True) + io.open(path, "w").close() + os.utime(path, (clock + minutes * 60,) * 2) + + for name, minutes in (("none-1", 5), ("inline-1", 10), ("inline-2", 30)): + dated(os.path.join(area, "scores", "%s.json" % name), minutes) + dated(os.path.join(area, "security-scores", "none-1.json"), 6) + dated(os.path.join(area, "scoring", "inline-2"), 20, folder=True) + dated(os.path.join(area, "scoring", "hybrid-1"), 40, folder=True) + dated(os.path.join(area, "scoring", "tools"), 50, folder=True) started_at = datetime.datetime.now() - datetime.timedelta(hours=1) with io.open(claim_path(area, "score.py"), "w", encoding="utf-8") as handle: json.dump({"pid": 4242, "tool": "score.py", "started": started_at.isoformat(timespec="seconds")}, handle) - live = scoring_lines(scratch, ROUND5_RUN, ROUND5_K, - alive=lambda claim: True) - stale = scoring_lines(scratch, ROUND5_RUN, ROUND5_K, - alive=lambda claim: False) + + def scoring_now(alive=True): + return scoring_lines(scratch, ROUND5_RUN, ROUND5_K, + alive=lambda claim: alive) + + live, stale = scoring_now(), scoring_now(alive=False) + + # A rescore of none-1 rebuilds its directory while its old score stays. + dated(os.path.join(area, "scoring", "none-1"), 45, folder=True) + rescoring = scoring_now() + + # Every trial in the scorer's directory scored; inline-1 in the security + # reader's directory with no reading yet. + for name, minutes in (("hybrid-1", 55), ("none-1", 56)): + dated(os.path.join(area, "scores", "%s.json" % name), minutes) + dated(os.path.join(area, "security", "inline-1"), 57, folder=True) + securing = scoring_now() shutil.rmtree(area, ignore_errors=True) shutil.rmtree(scratch, ignore_errors=True) scored = {line.split()[0]: line for line in live[2:] if line.strip()} @@ -334,6 +374,13 @@ def drawn(root): and "read for security" not in scored.get("inline", "")), ("the trial being scored is named, not one already scored", "scoring hybrid-1" in scored.get("all", "")), + ("the scorer's tools are never named as the trial in hand", + not any("tools" in line for line in live + rescoring + securing)), + ("a trial being rescored is named while its old score stays", + any("scoring none-1" in line for line in rescoring)), + ("once every trial is scored, the one read for security is named", + any("reading inline-1 for security" in line for line in securing) + and not any("scoring " in line for line in securing)), ("the scoring's line counts every arm and estimates what is left", " 3/75" in scored.get("all", "") and "h left" in scored.get("all", "")), ("a scorer that has ended names no trial and no pace", From d0c3cae37b0ad6dc6f3f2241cce7d2cfc7825455 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Sat, 31 Oct 2026 22:01:55 +0200 Subject: [PATCH 3/6] fix(efficacy): pick the scorer's phase by its latest change, and no time left for a rescore A refused trial leaves its directory without a score, which kept it named as the trial in hand through the security readings. The newer of the scoring and security directories now names the work in hand. A rescore or a run of named trials keeps scores it has not replaced, so no time left is estimated for it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- tests/efficacy/progress.py | 39 +++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/tests/efficacy/progress.py b/tests/efficacy/progress.py index cc00dfb..d692f99 100644 --- a/tests/efficacy/progress.py +++ b/tests/efficacy/progress.py @@ -162,7 +162,8 @@ def live_scorer(claim): def in_progress(work, written): - """The trial a tool is working on in `work`, or None. + """The trial a tool is working on in `work`, as (when it changed, its + name), or None. A tool rebuilds a trial's directory there before it writes the trial's result, so the trial in hand is the newest directory changed since its @@ -179,7 +180,7 @@ def in_progress(work, written): for entry in entries] changed = [(when, entry) for when, entry in changed if when > written.get(entry, 0)] - return max(changed)[1] if changed else None + return max(changed) if changed else None def scoring_lines(root, arms, k, alive=live_scorer): @@ -205,26 +206,33 @@ def scoring_lines(root, arms, k, alive=live_scorer): summary = "%-10s %s %2d/%d" % ("all", bar(done, total), done, total) # The scorer marks the area while it runs, scores each trial and then - # reads the scored ones for security; the pace is this scorer's own, from - # the scores it wrote since it started. + # reads the scored ones for security. Whichever of the two changed last is + # the one in hand, so a refused trial's directory, left without a result, + # does not hide the readings that follow it. claim = read_claim(claim_path(area, "score.py")) if claim and alive(claim): scoring = in_progress(os.path.join(area, "scoring"), scores) reading = in_progress(os.path.join(area, "security"), readings) - if scoring: - summary += " scoring %s" % scoring + if scoring and (not reading or scoring > reading): + summary += " scoring %s" % scoring[1] elif reading: - summary += " reading %s for security" % reading + summary += " reading %s for security" % reading[1] try: begun = datetime.datetime.fromisoformat(claim["started"]) except (KeyError, TypeError, ValueError): begun = None + + # The pace is this scorer's own, from the scores it wrote since it + # started. What is left is known only for a plain run, which scores + # every trial without a score; a rescore keeps the scores it has not + # yet replaced, and a run of named trials holds only those. + plain = not {"--rescore", "--trial"} & set(claim.get("argv") or []) if begun is not None: fresh = sum(1 for written in scores.values() if written >= begun.timestamp()) elapsed = time.time() - begun.timestamp() summary += " %.1f h in" % (elapsed / 3600) - if fresh: + if fresh and plain: left = elapsed / fresh * (total - done) summary += ", about %.1f h left" % (left / 3600) lines.extend(["", summary]) @@ -333,10 +341,20 @@ def scoring_now(alive=True): # Every trial in the scorer's directory scored; inline-1 in the security # reader's directory with no reading yet. + # A refused trial, skills-1, leaves its directory without a score. for name, minutes in (("hybrid-1", 55), ("none-1", 56)): dated(os.path.join(area, "scores", "%s.json" % name), minutes) + dated(os.path.join(area, "scoring", "skills-1"), 56.5, folder=True) dated(os.path.join(area, "security", "inline-1"), 57, folder=True) securing = scoring_now() + + # A rescore keeps the scores it has not replaced, so what is left of it + # cannot be told from the area. + with io.open(claim_path(area, "score.py"), "w", encoding="utf-8") as handle: + json.dump({"pid": 4242, "tool": "score.py", + "argv": ["tests/efficacy/score.py", "--rescore"], + "started": started_at.isoformat(timespec="seconds")}, handle) + rescore_pace = scoring_now() shutil.rmtree(area, ignore_errors=True) shutil.rmtree(scratch, ignore_errors=True) scored = {line.split()[0]: line for line in live[2:] if line.strip()} @@ -378,9 +396,12 @@ def scoring_now(alive=True): not any("tools" in line for line in live + rescoring + securing)), ("a trial being rescored is named while its old score stays", any("scoring none-1" in line for line in rescoring)), - ("once every trial is scored, the one read for security is named", + ("a refused trial's directory does not hide the security reading", any("reading inline-1 for security" in line for line in securing) and not any("scoring " in line for line in securing)), + ("a rescore shows its time in and no time left", + any(" h in" in line for line in rescore_pace) + and not any("h left" in line for line in rescore_pace)), ("the scoring's line counts every arm and estimates what is left", " 3/75" in scored.get("all", "") and "h left" in scored.get("all", "")), ("a scorer that has ended names no trial and no pace", From 3a6050782f12065fa388da9941707fc4d3907281 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Sat, 31 Oct 2026 22:18:14 +0200 Subject: [PATCH 4/6] fix(efficacy): read the scorer's command line with its own parser A run of named trials spelled --trial=none-1, or one given --run, was taken for a plain run and promised time left for all 75 trials. The command line is now read with score.py's parser, so every spelling and filter is seen. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- tests/efficacy/progress.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/efficacy/progress.py b/tests/efficacy/progress.py index d692f99..cb09be4 100644 --- a/tests/efficacy/progress.py +++ b/tests/efficacy/progress.py @@ -8,6 +8,7 @@ """ import argparse +import contextlib import datetime import glob import io @@ -183,6 +184,21 @@ def in_progress(work, written): return max(changed) if changed else None +def plain_scoring(argv): + """Whether a scorer's command line scores every build trial still + without a score, read with the scorer's own parser.""" + + # Imported here: the scorer's module is only needed once one runs. + import score + try: + with contextlib.redirect_stderr(io.StringIO()): + options = score.parse_args(list(argv or [])[1:]) + except SystemExit: + return False + return (options.task == "build" and not options.rescore + and not options.trial and not options.run) + + def scoring_lines(root, arms, k, alive=live_scorer): """The scoring's lines: one bar per arm of trials scored, with their security readings, and the trial being scored; none before scoring @@ -225,8 +241,9 @@ def scoring_lines(root, arms, k, alive=live_scorer): # The pace is this scorer's own, from the scores it wrote since it # started. What is left is known only for a plain run, which scores # every trial without a score; a rescore keeps the scores it has not - # yet replaced, and a run of named trials holds only those. - plain = not {"--rescore", "--trial"} & set(claim.get("argv") or []) + # yet replaced, and a run of named trials or of one record holds only + # those. + plain = plain_scoring(claim.get("argv")) if begun is not None: fresh = sum(1 for written in scores.values() if written >= begun.timestamp()) @@ -402,6 +419,13 @@ def scoring_now(alive=True): ("a rescore shows its time in and no time left", any(" h in" in line for line in rescore_pace) and not any("h left" in line for line in rescore_pace)), + ("only a plain scoring run, in any spelling, estimates what is left", + plain_scoring(["score.py", "--root", "r"]) + and not any(plain_scoring(["score.py", "--root", "r"] + extra) + for extra in (["--rescore"], ["--trial=none-1"], + ["--trial", "none-1"], ["--run=run-1.json"], + ["--run", "run-1.json"], + ["--task", "change"], ["--bogus"]))), ("the scoring's line counts every arm and estimates what is left", " 3/75" in scored.get("all", "") and "h left" in scored.get("all", "")), ("a scorer that has ended names no trial and no pace", From 10da0c545a3e88a6cc83a0f5c16b607a771df84b Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Sat, 31 Oct 2026 22:20:52 +0200 Subject: [PATCH 5/6] fix(efficacy): estimate the scoring alone, and none once every trial is scored The estimate counted build scores only, so it read 0.0 h through the security pass that follows them. It now says it covers the scoring, and is not shown once every trial is scored. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- tests/efficacy/progress.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/efficacy/progress.py b/tests/efficacy/progress.py index cb09be4..5c1844e 100644 --- a/tests/efficacy/progress.py +++ b/tests/efficacy/progress.py @@ -242,16 +242,18 @@ def scoring_lines(root, arms, k, alive=live_scorer): # started. What is left is known only for a plain run, which scores # every trial without a score; a rescore keeps the scores it has not # yet replaced, and a run of named trials or of one record holds only - # those. + # those. The estimate covers the scoring alone: the security readings + # that follow it run at a pace of their own, so once every trial is + # scored no estimate is shown. plain = plain_scoring(claim.get("argv")) if begun is not None: fresh = sum(1 for written in scores.values() if written >= begun.timestamp()) elapsed = time.time() - begun.timestamp() summary += " %.1f h in" % (elapsed / 3600) - if fresh and plain: + if fresh and plain and done < total: left = elapsed / fresh * (total - done) - summary += ", about %.1f h left" % (left / 3600) + summary += ", about %.1f h of scoring left" % (left / 3600) lines.extend(["", summary]) return lines @@ -365,6 +367,10 @@ def scoring_now(alive=True): dated(os.path.join(area, "security", "inline-1"), 57, folder=True) securing = scoring_now() + # A plain run with every trial scored, as one of one arm: only the + # security readings are left, and they have no estimate. + all_scored = scoring_lines(scratch, ("none",), 1, alive=lambda claim: True) + # A rescore keeps the scores it has not replaced, so what is left of it # cannot be told from the area. with io.open(claim_path(area, "score.py"), "w", encoding="utf-8") as handle: @@ -415,10 +421,13 @@ def scoring_now(alive=True): any("scoring none-1" in line for line in rescoring)), ("a refused trial's directory does not hide the security reading", any("reading inline-1 for security" in line for line in securing) - and not any("scoring " in line for line in securing)), + and not any(" scoring " in line for line in securing)), ("a rescore shows its time in and no time left", any(" h in" in line for line in rescore_pace) and not any("h left" in line for line in rescore_pace)), + ("once every trial is scored, the security pass shows no time left", + any(" h in" in line for line in all_scored) + and not any("left" in line for line in all_scored)), ("only a plain scoring run, in any spelling, estimates what is left", plain_scoring(["score.py", "--root", "r"]) and not any(plain_scoring(["score.py", "--root", "r"] + extra) @@ -427,7 +436,7 @@ def scoring_now(alive=True): ["--run", "run-1.json"], ["--task", "change"], ["--bogus"]))), ("the scoring's line counts every arm and estimates what is left", - " 3/75" in scored.get("all", "") and "h left" in scored.get("all", "")), + " 3/75" in scored.get("all", "") and "h of scoring left" in scored.get("all", "")), ("a scorer that has ended names no trial and no pace", not any("scoring " in line or " h in" in line for line in stale)), ] From c52758bd67306c504c2d4cd91d50d8c76a010e37 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Sat, 31 Oct 2026 22:23:50 +0200 Subject: [PATCH 6/6] fix(efficacy): count each trial once, and estimate only while a trial is scored A rescore of a round 1 trial leaves its letter's score beside its word's, which counted twice. A plain run that refused a trial leaves the bar short, which kept the estimate through the security readings. Each trial now counts once however it is spelled, and the estimate shows only while a trial is being scored. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- tests/efficacy/progress.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/efficacy/progress.py b/tests/efficacy/progress.py index 5c1844e..9851a07 100644 --- a/tests/efficacy/progress.py +++ b/tests/efficacy/progress.py @@ -154,6 +154,20 @@ def arm_of(name): return None +def blocks_of(names, arm): + """The blocks of `arm` that `names` hold, each once however it is + spelled: round 1's `A1` and its word `none-1` are one trial.""" + found = set() + for name in names: + try: + other, block = split_name(name) + except TrialError: + continue + if other == arm: + found.add(block) + return found + + def live_scorer(claim): """Whether the scorer a marker names is still running.""" try: @@ -212,8 +226,8 @@ def scoring_lines(root, arms, k, alive=live_scorer): total = len(arms) * k done = 0 for name in arms: - scored = sum(1 for trial in scores if arm_of(trial) == name) - read = sum(1 for trial in readings if arm_of(trial) == name) + scored = len(blocks_of(scores, name)) + read = len(blocks_of(readings, name)) done += scored line = "%-10s %s %2d/%d" % (name, bar(scored, k), scored, k) if read: @@ -229,9 +243,12 @@ def scoring_lines(root, arms, k, alive=live_scorer): if claim and alive(claim): scoring = in_progress(os.path.join(area, "scoring"), scores) reading = in_progress(os.path.join(area, "security"), readings) + phase = None if scoring and (not reading or scoring > reading): + phase = "scoring" summary += " scoring %s" % scoring[1] elif reading: + phase = "security" summary += " reading %s for security" % reading[1] try: begun = datetime.datetime.fromisoformat(claim["started"]) @@ -242,16 +259,17 @@ def scoring_lines(root, arms, k, alive=live_scorer): # started. What is left is known only for a plain run, which scores # every trial without a score; a rescore keeps the scores it has not # yet replaced, and a run of named trials or of one record holds only - # those. The estimate covers the scoring alone: the security readings - # that follow it run at a pace of their own, so once every trial is - # scored no estimate is shown. + # those. The estimate covers the scoring alone, so it is shown only + # while a trial is being scored: the security readings that follow + # run at a pace of their own, and a refused trial leaves the bar short + # with no scoring left to do. plain = plain_scoring(claim.get("argv")) if begun is not None: fresh = sum(1 for written in scores.values() if written >= begun.timestamp()) elapsed = time.time() - begun.timestamp() summary += " %.1f h in" % (elapsed / 3600) - if fresh and plain and done < total: + if fresh and plain and phase == "scoring" and done < total: left = elapsed / fresh * (total - done) summary += ", about %.1f h of scoring left" % (left / 3600) lines.extend(["", summary]) @@ -340,6 +358,9 @@ def dated(path, minutes, folder=False): for name, minutes in (("none-1", 5), ("inline-1", 10), ("inline-2", 30)): dated(os.path.join(area, "scores", "%s.json" % name), minutes) dated(os.path.join(area, "security-scores", "none-1.json"), 6) + + # Round 1's spelling of none-1, left beside the word a rescore wrote. + dated(os.path.join(area, "scores", "A1.json"), 4) dated(os.path.join(area, "scoring", "inline-2"), 20, folder=True) dated(os.path.join(area, "scoring", "hybrid-1"), 40, folder=True) dated(os.path.join(area, "scoring", "tools"), 50, folder=True) @@ -422,6 +443,10 @@ def scoring_now(alive=True): ("a refused trial's directory does not hide the security reading", any("reading inline-1 for security" in line for line in securing) and not any(" scoring " in line for line in securing)), + ("the security pass shows no scoring estimate, bar short or not", + not any("left" in line for line in securing)), + ("a trial scored under two spellings counts once", + " 1/15" in scored.get("none", "")), ("a rescore shows its time in and no time left", any(" h in" in line for line in rescore_pace) and not any("h left" in line for line in rescore_pace)),