From a81a3f5fe75914e18038948eeaaba48e269763ab Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 29 Oct 2026 07:45:32 +0200 Subject: [PATCH 1/2] feat(efficacy): register round 5's spec by content, and refuse any other Each trial recorded the spec's SHA-256, but nothing compared it. The harness now refuses a round-5 trial whose spec differs from the registered content, checked before every trial so an edit mid-run builds nothing. The report refuses a round-5 report holding a trial that built from other content, or a scorable trial that records no spec. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- docs/architecture/08-crosscutting-concepts.md | 5 + .../architecture/09-architecture-decisions.md | 1 + docs/rounds/README.md | 2 +- docs/rounds/round-5.md | 8 +- tests/efficacy/harness.py | 98 ++++++++++++++++++- tests/efficacy/report.py | 79 ++++++++++++++- 6 files changed, 186 insertions(+), 7 deletions(-) diff --git a/docs/architecture/08-crosscutting-concepts.md b/docs/architecture/08-crosscutting-concepts.md index 4bd23c8..5be3ea7 100644 --- a/docs/architecture/08-crosscutting-concepts.md +++ b/docs/architecture/08-crosscutting-concepts.md @@ -20,6 +20,11 @@ whose registration under `docs/rounds/`: - landed on `main` after the round's first trial started, read on `main`'s first-parent line so a merge counts at the merge - differs from `main`'s copy, or has changes not yet committed +- holds a trial that built from a spec other than the one it registers, by + content, or a trial with something to score that records no spec + +The harness checks the spec too, before every trial, so an edit made while a +run is under way refuses the trials after it rather than building them. Trials record their start with its UTC offset, so the order holds on any machine; a start with no offset is refused rather than guessed. A diff --git a/docs/architecture/09-architecture-decisions.md b/docs/architecture/09-architecture-decisions.md index 560267d..359a813 100644 --- a/docs/architecture/09-architecture-decisions.md +++ b/docs/architecture/09-architecture-decisions.md @@ -63,6 +63,7 @@ that mentions the design means the document these chapters replaced. | 2026-10-27 | Round 5 runs block A alone, at K = 15 with no escalation, each block starting one arm later; adherence is held within 8 pp, and H2 reads the mean over pairs of trials. Blocks B and C wait for a later round | The report's rules, run on round 3's per-trial noise, decide almost nothing at K = 3: H1 is supported in 29 % of rounds when true, and a chance "worse" turns up in 36 %. At K = 15 those are 73 % and 12 %. On round 4's noise, B and C would contradict block A by chance at any affordable K | — | | 2026-10-28 | A template change runs the baseline and the candidate head to head in the candidate's round, with one contrast, `candidate − baseline`, and no `none` arm; round 3 stays a reference without a verdict | A contrast pairing trials from different rounds gets no verdict, so round 3 as the baseline could decide nothing. Two arms answer "is the trim free" at the least cost | — | | 2026-10-28 | From round 5, size reads app code's lines and files against a band of 20 %, smallest change 40 %; test lines are reported without a verdict; docs and configuration leave size; committed generated files count as artifacts nobody asked for | A better solution is often a little bigger, with tests and layering. Round 4's source lines missed templates, and its file count was mostly docs, templates and committed bytecode | — | +| 2026-10-29 | A round registers its spec by content, and the harness and the report each refuse a trial built from other content | Each trial recorded the spec's hash but nothing compared it, so an edit during a two-day run would have mixed two specs in one round unseen | — | ¹ This agrees with Anthropic's guidance on context engineering, which asks for the smallest set of high-signal tokens: [Effective context engineering for AI diff --git a/docs/rounds/README.md b/docs/rounds/README.md index 93c5a9f..62beb50 100644 --- a/docs/rounds/README.md +++ b/docs/rounds/README.md @@ -8,7 +8,7 @@ trial of that round has run. The rules every round shares are in | Round | Registered | Asks | | ----- | ---------- | ---- | | [Round 4](round-4.md) | Before its first trial, after round 3 | Does a file supply what a thin spec leaves out, and help a weaker model more | -| [Round 5](round-5.md) | 2026-10-26, amended 2026-10-27 and 2026-10-28 | Which way of delivering the rules gives the best and most consistent code | +| [Round 5](round-5.md) | 2026-10-26, amended 2026-10-27, 2026-10-28 and 2026-10-29 | Which way of delivering the rules gives the best and most consistent code | ## Reports diff --git a/docs/rounds/round-5.md b/docs/rounds/round-5.md index 2b3f029..c51de90 100644 --- a/docs/rounds/round-5.md +++ b/docs/rounds/round-5.md @@ -4,7 +4,8 @@ Registered in the design on 2026-10-26, before any round-5 trial ran, and amended twice on 2026-10-27, still before any trial: once to change the judge, and once to size the round from the noise of rounds 3 and 4 (#38). Moved here unchanged but for its links, and amended on 2026-10-28, still before any trial, -to read code size as app code and test code (#39). +to read code size as app code and test code (#39). Amended on 2026-10-29, still +before any trial, to register the specification's content as well as its name. ## 13. Round 5: how the rules are delivered @@ -24,6 +25,11 @@ fifteen times: | --- | --- | --- | --- | | A, main | `SPEC.md` | `claude-sonnet-5`, effort `high` | 5 arms × K = 15 | +`SPEC.md` is registered at sha256 +`48ee93ff968ef4a3175408c349afd6ce7223d0f3bd25b49ad4521f0fc307e55e`. The harness +refuses a trial whose spec has other content, and the report refuses a round +with a trial that built from one. + Blocks B (`SPEC-thin.md`) and C (`claude-haiku-4-5-20251001`) are deferred to a later round, sized from block A's measured noise. On the noise round 4 measured in those settings, they read a chance "worse" in 57 to 69 % of rounds at K = 3, diff --git a/tests/efficacy/harness.py b/tests/efficacy/harness.py index bb2dea2..8cd0689 100644 --- a/tests/efficacy/harness.py +++ b/tests/efficacy/harness.py @@ -96,6 +96,12 @@ # Round 5's templates and roots, as registered: one commit and one # chain for every arm, so the arms differ only in how they deliver it. ROUND5_REF = "9086e0ff" + +# Round 5's specification, as registered: one file at one content for every +# trial. A spec edited while a two-day run is under way would otherwise mix two +# specifications in one round without a trace in its verdicts. +ROUND5_SPEC = ("normal", + "48ee93ff968ef4a3175408c349afd6ce7223d0f3bd25b49ad4521f0fc307e55e") ROUND5_ROOTS = ["backend-api", "backend-auth", "backend-database", "frontend-ux", "base-security", "base-data-governance"] @@ -1345,12 +1351,41 @@ def prepare_change_workspace(arm, trial, root, build): return workspace, git(workspace, "rev-parse", "HEAD") +def spec_digest(path): + with io.open(path, "rb") as handle: + return hashlib.sha256(handle.read()).hexdigest() + + +def spec_problem(arms, spec_name, digest): + """Why a run of these arms may not build from this spec, or None. + + A run holding a round-5 arm builds from the spec round 5 registers, at + the content it registers; any other run is not checked here. + """ + if not set(arms) & set(ROUND5_ARMS): + return None + name, registered = ROUND5_SPEC + if spec_name != name: + return ("round 5 registers the %s spec, and this run names %s" + % (name, spec_name)) + if digest != registered: + return ("the %s spec is not the content round 5 registers: sha256 %s, " + "registered %s" % (name, digest, registered)) + return None + + def run_trial(arm, trial, root, home, options): """Run one build trial and return its record.""" - spec = SPECS[getattr(options, "spec", "normal")] + spec_name = getattr(options, "spec", "normal") + spec = SPECS[spec_name] + + # Read again for every trial, so an edit made after the run started + # refuses the trials after it rather than building them from a new spec. + digest = spec_digest(spec) + problem = spec_problem(getattr(options, "arm_list", ()), spec_name, digest) + if problem: + raise TrialError(problem) workspace, vendored = prepare_workspace(arm, trial, root, spec) - with io.open(spec, "rb") as handle: - digest = hashlib.sha256(handle.read()).hexdigest() record = {"arm": arm, "label": ARMS[arm]["label"], "trial": trial, "task": "build", "vendored": vendored, "spec": {"file": os.path.basename(spec), "sha256": digest}} @@ -2953,6 +2988,54 @@ def round5_checks(): return checks +def spec_checks(): + """A round-5 run builds from the registered spec, and from nothing else.""" + import argparse as _argparse + + round5 = ["none", "inline", "hybrid", "reference", "skills"] + name, registered = ROUND5_SPEC + checks = [ + ("round 5's registered digest is SPEC.md's content", + spec_digest(SPECS[name]) == registered), + ("a round-5 run on the registered spec passes", + spec_problem(round5, name, registered) is None), + ("a round-5 run on other content is refused", + spec_problem(round5, name, "0" * 64) is not None), + ("a round-5 run on the thin spec is refused", + spec_problem(round5, "thin", spec_digest(SPECS["thin"])) is not None), + ("a run without a round-5 arm is not checked", + spec_problem(["none", "hybrid"], "thin", "0" * 64) is None), + ] + + # The spec edited after the run started: the next trial is refused before + # its workspace is laid out, so nothing is built from the new content. + scratch = tempfile.mkdtemp(prefix="efficacy-spec-") + original = SPECS[name] + try: + edited = os.path.join(scratch, "SPEC.md") + with io.open(original, "rb") as source, io.open(edited, "wb") as out: + out.write(source.read() + b"\nOne more line.\n") + SPECS[name] = edited + # The options name no model, so a trial that got past the check stops + # on that before any CLI is called. + options = _argparse.Namespace(spec=name, arm_list=round5) + root = os.path.join(scratch, "root") + os.makedirs(root) + try: + run_trial("none", 2, root, scratch, options) + refused = False + except TrialError: + refused = True + except Exception: + refused = False + checks.append(("a spec edited mid-run refuses the next trial unbuilt", + refused and os.listdir(root) == [])) + finally: + SPECS[name] = original + shutil.rmtree(scratch, ignore_errors=True) + return checks + + def self_test(): """Prove the naming, isolation, outcome, resume, change and vendoring rules before a trial.""" @@ -2962,7 +3045,7 @@ def self_test(): + process_checks() + claim_checks() + leftover_checks() + reach_checks() + outside_checks() + vendor_checks() + denial_checks() + kill_checks() - + recover_checks() + round5_checks()) + + recover_checks() + round5_checks() + spec_checks()) for label, ok in checks: print(" %-52s %s" % (label, "ok" if ok else "FAILED")) passed = sum(1 for _, ok in checks if ok) @@ -3072,6 +3155,13 @@ def main(argv): except TrialError as error: print("refused: %s" % error) return 2 + options.arm_list = arms + if options.task == "build": + problem = spec_problem(arms, options.spec, + spec_digest(SPECS[options.spec])) + if problem: + print("refused: %s" % problem) + return 2 # A trial an earlier harness died under holds its slot until voided, so # the run that re-runs it `--from` that trial finds the slot free. diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index bd77b5d..d178106 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -35,7 +35,8 @@ import lib # noqa: E402 from generate_arm import GENERATED, record_path # noqa: E402 from harness import (ARMS, ARMS_DIR, K_CEILING, K_PRIMARY, # noqa: E402 - ROUND5_ARMS, ROUND5_K, SCORABLE, TEMPLATES_ENV, VOIDING, + ROUND5_ARMS, ROUND5_K, ROUND5_SPEC, SCORABLE, + TEMPLATES_ENV, VOIDING, TrialError, canonical, git, k_ceiling, order, reach, read_transcripts, scoring_area, split_name, templates_root, trial_name) @@ -1095,6 +1096,29 @@ def started(record): return moment.timestamp() +def spec_problem(root): + """Why the round's build trials did not all build from the spec round 5 + registers, or None when every one did.""" + registered = ROUND5_SPEC[1] + for record in run_records(root): + if record.get("task", "build") != "build": + continue + spec = record.get("spec") + + # A refused or unfinished trial built nothing, so it has no spec to + # show; a trial with something to score has to. + if spec is None: + if record.get("outcome") in SCORABLE: + return ("trial %s records no spec, so it cannot be shown to " + "have built from the registered one" % trial_of(record)) + continue + if spec.get("sha256") != registered: + return ("trial %s built from %s at sha256 %s, and round 5 " + "registers sha256 %s" % (trial_of(record), spec.get("file"), + spec.get("sha256"), registered)) + return None + + def registration_problem(root, registration, repository=REPOSITORY): """Why the round's registration does not predate its first trial, or None when it landed on the main branch before that trial and is @@ -2787,6 +2811,51 @@ def trial(app, files): return checks +def spec_checks(): + """A round is refused when a trial with something to score built from + another spec than the registered one, or records none.""" + scratch = tempfile.mkdtemp(prefix="efficacy-report-spec-") + registered = ROUND5_SPEC[1] + + def problem_for(*trials): + for old in glob.glob(os.path.join(scratch, "run-*.json")): + os.remove(old) + with io.open(os.path.join(scratch, "run-1.json"), "w", + encoding="utf-8") as handle: + json.dump({"trials": list(trials)}, handle) + return spec_problem(scratch) + + def build(arm, trial, digest="registered", outcome="completed"): + record = {"arm": arm, "trial": trial, "task": "build", + "outcome": outcome} + if digest is not None: + record["spec"] = {"file": "SPEC.md", + "sha256": registered if digest == "registered" + else digest} + return record + + try: + checks = [ + ("every trial on the registered spec passes", + problem_for(build("none", 1), build("skills", 1)) is None), + ("a trial on another spec is refused", + problem_for(build("none", 1), build("skills", 1, "0" * 64)) + is not None), + ("a scorable trial recording no spec is refused", + problem_for(build("none", 1, None)) is not None), + ("a refused trial, which built nothing, is not read", + problem_for(build("none", 1), + build("skills", 1, None, "refused")) is None), + ("a change task, which gets no spec, is not read", + problem_for(build("none", 1), + {"arm": "none", "trial": 1, "task": "change", + "outcome": "completed"}) is None), + ] + finally: + shutil.rmtree(scratch, ignore_errors=True) + return checks + + def registration_checks(): """A round is refused when its registration landed on the main branch after its first trial, has not landed, is changed and not committed, or @@ -3647,6 +3716,7 @@ def self_test(seed): checks.extend((label, ok, ok) for label, ok in lost_checks()) checks.extend((label, ok, ok) for label, ok in rescan_checks()) checks.extend((label, ok, ok) for label, ok in registration_checks()) + checks.extend((label, ok, ok) for label, ok in spec_checks()) for label, ok, got in checks: print(" %-52s %s" % (label, "ok" if ok else "FAILED, got %r" % (got,))) @@ -3712,6 +3782,13 @@ def main(argv): print("refused: %s" % problem) return 2 + # Two specifications in one round would read as one arm's effect, so + # a round whose trials did not all get the registered one is refused. + problem = spec_problem(options.root) + if problem: + print("refused: %s" % problem) + return 2 + # A trial that read past its workspace measures what it read, not its # arm; the harness voids one its own scan catches, and this re-scan, under # the current rule, leaves out any it missed. From 635a2ad4d9fec74719e222961f019af4cc15f6b0 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 29 Oct 2026 07:53:36 +0200 Subject: [PATCH 2/2] fix(efficacy): check and record the spec copy the agent reads The source was hashed before it was copied, so an edit between the two gave a trial changed content under the registered hash. The workspace's copy is now what is checked and recorded, and a refused workspace is removed so the trial's slot stays free. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX --- tests/efficacy/harness.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/efficacy/harness.py b/tests/efficacy/harness.py index 8cd0689..b2aca89 100644 --- a/tests/efficacy/harness.py +++ b/tests/efficacy/harness.py @@ -1381,11 +1381,20 @@ def run_trial(arm, trial, root, home, options): # Read again for every trial, so an edit made after the run started # refuses the trials after it rather than building them from a new spec. - digest = spec_digest(spec) - problem = spec_problem(getattr(options, "arm_list", ()), spec_name, digest) + arms = getattr(options, "arm_list", ()) + problem = spec_problem(arms, spec_name, spec_digest(spec)) if problem: raise TrialError(problem) workspace, vendored = prepare_workspace(arm, trial, root, spec) + + # The copy is what the agent reads, and the source can change between the + # check above and the copy, so the copy is what is checked and recorded. + # A refused workspace is removed, so the trial's slot stays free. + digest = spec_digest(os.path.join(workspace, "SPEC.md")) + problem = spec_problem(arms, spec_name, digest) + if problem: + remove_tree(workspace) + raise TrialError(problem) record = {"arm": arm, "label": ARMS[arm]["label"], "trial": trial, "task": "build", "vendored": vendored, "spec": {"file": os.path.basename(spec), "sha256": digest}} @@ -3030,6 +3039,30 @@ def spec_checks(): refused = False checks.append(("a spec edited mid-run refuses the next trial unbuilt", refused and os.listdir(root) == [])) + + # The source edited between its check and its copy: the planted copy + # step writes the edit into the workspace after the source passed. + SPECS[name] = original + prepare = globals()["prepare_workspace"] + + def edited_in_flight(*args, **kwargs): + workspace, vendored = prepare(*args, **kwargs) + with io.open(os.path.join(workspace, "SPEC.md"), "ab") as copy: + copy.write(b"\nOne more line.\n") + return workspace, vendored + + globals()["prepare_workspace"] = edited_in_flight + try: + run_trial("none", 3, root, scratch, options) + refused = False + except TrialError: + refused = True + except Exception: + refused = False + finally: + globals()["prepare_workspace"] = prepare + checks.append(("a spec changed as it is copied refuses the trial and " + "frees its slot", refused and os.listdir(root) == [])) finally: SPECS[name] = original shutil.rmtree(scratch, ignore_errors=True)