From 6d249e42bc75d1a30d997d9fcc2a69a7d1a7e519 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 10:29:11 +0200 Subject: [PATCH 01/21] feat(efficacy): the report reads round 5e A round-5e run reads under round 5d's rules against its own registration: H7 to H9 as registered, each map arm against `none`, the arm it answers and the reused arms, the skill against the file paired. Two sections join the round's answer. The use of the map, read from each trial's transcript: every template read from the vendored copy or loaded as a skill, the turn it happened at, how many came before the trial's first write, and the note beside H7 where `lazyref` read everything up front. The round-6 screen of 13d.9: each candidate against `none`, out on a deciding row worse, the rest ranked by rows better and then by cost, the top four named. FR-12-13 to FR-12-15 state the rules, each with its self-test; the registration's 13e.5 moves the report's reading to done. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/architecture/08-crosscutting-concepts.md | 9 + docs/coverage.md | 3 + docs/requirements.md | 3 + docs/rounds/round-5e.md | 21 +- tests/efficacy/report.py | 480 +++++++++++++++++- 5 files changed, 495 insertions(+), 21 deletions(-) diff --git a/docs/architecture/08-crosscutting-concepts.md b/docs/architecture/08-crosscutting-concepts.md index b68fb3b..b67461e 100644 --- a/docs/architecture/08-crosscutting-concepts.md +++ b/docs/architecture/08-crosscutting-concepts.md @@ -554,6 +554,15 @@ Round 5's: | `reference − hybrid` | H3: does naming the templates alone deliver less? | | `skills − inline` | The same rules, with and without the split into skills | +Round 5e's, read under round 5d's rules: + +| Contrast | Asks | +| -------- | ---- | +| `lazyref − reference` | H7: does a template read when the work touches its topics deliver what one read up front does? | +| `lazyskills − lazyref` | H8: does a skill load deliver what a file read does, at the same moments? | +| `lazyskills − skills` | H9: do whole templates as skills, at a named moment, deliver what task skills do? | +| each map arm − `none`, `hand`, `short`, and the other reused arm | Secondary, no verdict; the `none` reading feeds round 6's screen | + **Rules** | # | Rule | In practice | Requirement | diff --git a/docs/coverage.md b/docs/coverage.md index e691fac..add0243 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -170,6 +170,9 @@ when: | FR-12-09 | Self-test | `report.py` "withdrawal blanks every value of the row"
`report.py` "its verdict vector row reads withdrawn"
`report.py` "the withdrawal section names it and why"
`report.py` "a run graded by another revision withdraws nothing"
`report.py` "a metric not withdrawn keeps its verdict" | | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | +| FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none" | +| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs" | ## 13 Records and archive diff --git a/docs/requirements.md b/docs/requirements.md index 4f63cfb..921faed 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -178,6 +178,9 @@ | FR-12-10 | The benchmark shall fix a fault found in its instruments, validate the fix, re-score in full every round that reads the faulty scores, and replace each report with a dated note keeping the verdicts it replaces. | Scorer, Report, Owner | | FR-12-11 | Removed: merged into FR-12-10. | - | | FR-12-12 | From round 6 the benchmark shall draw one radar per file arm against `none` on the eight ISO/IEC 25010:2023 characteristics, each axis the share of its targets met, with a marker only past the axis's margin, a broken build counted against Reliability alone, the cost shown above and one table of sub-scores per axis in the appendix. | Report | +| FR-12-13 | The benchmark shall read round 5e's H7 to H9 under round 5d's rules, each a map arm against the arm it answers, unpaired where the arms ran in different rounds. | Report | +| FR-12-14 | The benchmark shall count, per trial of an arm whose file points at the templates, each template read from the vendored copy or loaded as a skill, the turn it happened at, and how many came before the trial's first write to a file of its own. | Report | +| FR-12-15 | The benchmark shall screen round 6's candidates against `none` as round 5d registers: out on a deciding row worse, the rest ranked by rows better and then by mean cost, the top four kept. | Report | ### 13 Records and archive diff --git a/docs/rounds/round-5e.md b/docs/rounds/round-5e.md index f0b766a..e77ec75 100644 --- a/docs/rounds/round-5e.md +++ b/docs/rounds/round-5e.md @@ -4,6 +4,10 @@ Registered on 2026-11-05, while round 5d ran and before any round-5e trial ran. Round 5d keeps its registration as it was when its first trial ran; this one is a registration of its own. +Amended on 2026-11-05, before any round-5e trial ran: the report's reading of +the round moved from "still needed" to done in 13e.5, and the reuse of the +earlier rounds' arms is what remains. + ## 13e. Round 5e: the templates on demand, against rounds 5c and 5d ### 13e.1 What it takes from rounds 5c and 5d @@ -158,14 +162,17 @@ Done with this registration: them, and builds both from round 5's spec at its registered content - the report names both arms in plain words -The report still gains, with a self-test for each: +Done after it, before any round-5e trial, each with a self-test: + +- the report reads a round-5e run under round 5d's rules and against this + registration, with the contrasts of H7 and H9, unpaired, and H8, paired +- the use-of-the-map rows of 13e.4, read from the transcripts, with the note + beside H7 +- the round-6 screen of 13d.9, with round 5e's arms among the candidates -- round 5c's `reference` and `skills` and round 5d's `hand` and `short` read - with their scores, judgings, security readings and tool lock, as 13d.5 reads - round 5c's `none` -- the contrasts of H7 and H9, unpaired, and H8, paired -- the use-of-the-map rows of 13e.4, read from the transcripts -- the round-6 screen of 13d.9 with round 5e's arms among the candidates +Still needed: round 5c's `reference` and `skills` and round 5d's `hand` and +`short` brought into round 5e's root by `reuse.py`, scored and read as they +were, with their tool lock. ### 13e.6 When it runs diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index b806b7a..5b2493b 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -37,10 +37,11 @@ import lib # noqa: E402 from generate_arm import GENERATED, record_path # noqa: E402 from harness import (ARMS, ARMS_DIR, PROMPT, ROUND5_ARMS, # noqa: E402 - ROUND5_K, ROUND5_SPEC, ROUND5D_ARMS, SCORABLE, - TEMPLATES_ENV, VOIDING, TrialError, canonical, git, - reach, read_transcripts, scoring_area, split_name, - templates_root, trial_name) + ROUND5_K, ROUND5_SPEC, ROUND5D_ARMS, ROUND5E_ARMS, + SCORABLE, TEMPLATES_ENV, VENDORED, VOIDING, TrialError, + canonical, git, reach, read_transcripts, scoring_area, + split_name, templates_root, transcript_files, + trial_name) from harness import name_of as trial_of # noqa: E402 HERE = os.path.dirname(os.path.abspath(__file__)) @@ -54,6 +55,7 @@ # turn and runs again as round 5c, which changes only where a workspace sits. ROUND5_REGISTRATION = "docs/rounds/round-5c.md" ROUND5D_REGISTRATION = "docs/rounds/round-5d.md" +ROUND5E_REGISTRATION = "docs/rounds/round-5e.md" # A registration counts once it is on this branch, not on a branch of its own. REGISTRATION_BRANCH = "main" @@ -95,7 +97,17 @@ # Round 5d: each templates arm against a person's file, and the # 40-line file against the same generation without its budget. ("inline", "hand"), ("hybrid", "hand"), ("reference", "hand"), - ("skills", "hand"), ("short", "inline")) + ("skills", "hand"), ("short", "inline"), + + # Round 5e: each map arm against none, against the arm it + # answers (H7, H9), against the other reused arms, and the skill + # against the file (H8). + ("lazyref", "none"), ("lazyskills", "none"), + ("lazyref", "reference"), ("lazyskills", "skills"), + ("lazyskills", "lazyref"), + ("lazyref", "skills"), ("lazyskills", "reference"), + ("lazyref", "hand"), ("lazyskills", "hand"), + ("lazyref", "short"), ("lazyskills", "short")) # Declared before the run. "up" improves upward, "down" # improves downward, "neutral" is reported without a verdict. @@ -651,7 +663,7 @@ def is_round5(trials): """Whether the run holds a round-5 arm, so that round's registration, its K and its margins, governs it.""" return (any(arm_of(name) in ROUND5_ARMS for name in trials) - or is_round5d(trials)) + or is_round5d(trials) or is_round5e(trials)) def is_round5d(trials): @@ -660,15 +672,34 @@ def is_round5d(trials): return any(arm_of(name) in ROUND5D_ARMS for name in trials) +def is_round5e(trials): + """Whether the run holds a round-5e arm, so that round's registration + governs it, under round 5d's verdict rules.""" + return any(arm_of(name) in ROUND5E_ARMS for name in trials) + + +def later_rules_of(trials): + """Whether round 5d's verdict rules govern the run: they do from round + 5d on, so round 5e reads under them too.""" + return is_round5d(trials) or is_round5e(trials) + + # The arms round 5 registers. A block is complete only when every one of # them has its trial, so a run that lost a trial or an arm is part-run. ROUND5_RUN = ("none", "inline", "hybrid", "reference", "skills") +def round_arms(trials): + """The arms the run's round registers as fresh trials.""" + if is_round5e(trials): + return ROUND5E_ARMS + return ROUND5D_ARMS if is_round5d(trials) else ROUND5_RUN + + def owed_blocks(trials): """The blocks of round 5's K that still miss a registered arm's trial, in order.""" - run = ROUND5D_ARMS if is_round5d(trials) else ROUND5_RUN + run = round_arms(trials) return [block for block in range(1, ROUND5_K + 1) if any(trial_name(arm, block) not in trials for arm in run)] @@ -690,7 +721,7 @@ def blocks_named(blocks): def margins_of(trials): """The margins a run's contrasts are held against.""" - return ROUND5D_MARGINS if is_round5d(trials) else ROUND5_MARGINS + return ROUND5D_MARGINS if later_rules_of(trials) else ROUND5_MARGINS def active_contrasts(trials): @@ -733,7 +764,8 @@ def crossed_labels(trials): def collect(trials, metrics=METRICS, later_rules=None): """Metric values by metric, arm and trial index, read by round 5d's rules for a round-5d run or where `later_rules` asks for them.""" - working_only = is_round5d(trials) if later_rules is None else later_rules + working_only = (later_rules_of(trials) if later_rules is None + else later_rules) table = {} for key, label, direction, accessor in metrics: if key in SUPERSEDED_IN_ROUND5 or (working_only @@ -1069,7 +1101,7 @@ def round_contrasts(trials, table, seed): """`table`'s contrasts read the way the round registered: its margins, its crossings, and round 5d's rules for a round-5d run.""" return contrasts(table, seed, crossed_labels(trials), margins_of(trials), - is_round5d(trials)) + later_rules_of(trials)) def withdrawals(trials, path=WITHDRAWN): @@ -1148,7 +1180,7 @@ def cross_check(trials, other, seed, later_rules=None): """How far the other vendor's judge agrees with the rounds' judge on the trials it read, per judge row, and the contrasts it reads itself, by round 5d's rules for a round-5d run or where `later_rules` asks.""" - strict = is_round5d(trials) if later_rules is None else later_rules + strict = later_rules_of(trials) if later_rules is None else later_rules rows = {} for key in JUDGE_ROWS: dimension = key[len("judge_"):] @@ -1374,6 +1406,14 @@ def python_problem(trials): for minor, name in sorted(found.items()))) +def registration_of(trials): + """The registration a run is read against: the latest round whose arm + it holds.""" + if is_round5e(trials): + return ROUND5E_REGISTRATION + return ROUND5D_REGISTRATION if is_round5d(trials) else ROUND5_REGISTRATION + + 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 @@ -1695,13 +1735,17 @@ def write_report(root, trials, table, results, seed, out_dir, blocks=k)) lines.append("") - if is_round5(trials) and not is_round5d(trials): + if is_round5(trials) and not later_rules_of(trials): lines.extend(round5_section(trials, table, results)) lines.append("") if is_round5d(trials): lines.extend(round5d_section(trials, table, results, seed, margins_of(trials))) lines.append("") + if is_round5e(trials): + lines.extend(round5e_section(root, trials, table, results, seed, + margins_of(trials))) + lines.append("") lines.append("## Raw numbers, per trial") lines.append("") @@ -2010,6 +2054,14 @@ def vector_lines(results, active): "skills-hand": "Does the skills approach do as well as a person's file?", "short-hand": "Does a 40-line file from the templates do as well as a " "person's file of the same length?", + "lazyref-reference": "Does a template read when the work touches its " + "topics do as well as the same template read " + "before the work starts?", + "lazyskills-lazyref": "Does loading a template as a skill do as well as " + "reading it as a file, at the same moments?", + "lazyskills-skills": "Do templates loaded whole as skills, at a named " + "moment, do as well as task skills offered by " + "description?", } PLAIN_ANSWERS = {"supported": "yes", "refuted": "no", "inconclusive": "not settled: the runs could not tell " @@ -2565,6 +2617,15 @@ def shown(value): "held"), ) +# Round 5e's hypotheses, as registered: each asks for no loss, under round +# 5d's rules. H7 and H9 cross rounds and read unpaired; H8 is paired. +ROUND5E_HYPOTHESES = ( + ("H7, on demand against up front", "lazyref-reference", "held"), + ("H8, a skill against a file", "lazyskills-lazyref", "held"), + ("H9, one skill per template against one skill per task", + "lazyskills-skills", "held"), +) + # Each leave-two-out reading takes fewer resamples than the report's # intervals, so an unpaired contrast's 435 readings stay cheap. LEAVE_TWO_OUT_RESAMPLES = 2000 @@ -2735,6 +2796,397 @@ def round5d_section(trials, table, results, seed, margins, return lines +# The tools whose call writes a file of the trial's own. A read of the map's +# templates before the first of them came before any work. +WRITES = ("Write", "Edit", "MultiEdit", "NotebookEdit") + + +def mapped_templates(arm): + """What an arm's file points the agent at: the skills it carries, by + name, or the templates it vendors, by path; empty for an arm with + neither.""" + entry = ARMS.get(arm) or {} + if entry.get("skills"): + folder = os.path.join(ARMS_DIR, entry["skills"]) + return sorted(os.listdir(folder)) if os.path.isdir(folder) else [] + if entry.get("vendor"): + record = generation_records().get(arm) or {} + return list(record.get("resolved_files") or []) + return [] + + +def map_use(files, arm, templates=None): + """How one trial used what its file points at, from its transcripts: + each template read from the vendored copy or loaded as a skill, as + (turn, template) in order, and the turn of the trial's first write to a + file of its own, or None.""" + entry = ARMS.get(arm) or {} + known = set(mapped_templates(arm) if templates is None else templates) + marker = VENDORED["into"] + "/" + uses = [] + first_write = None + turn = 0 + last_message = object() + for file in files: + with io.open(file, encoding="utf-8", errors="replace") as handle: + for line in handle: + try: + record = json.loads(line) + except ValueError: + continue + if not isinstance(record, dict) \ + or record.get("type") != "assistant": + continue + message = record.get("message") or {} + + # One turn of the model may be written as several lines that + # share a message id, so a new id is what counts a turn. + if message.get("id") != last_message: + last_message = message.get("id") + turn += 1 + content = message.get("content") + for block in content if isinstance(content, list) else []: + if not isinstance(block, dict) \ + or block.get("type") != "tool_use": + continue + given = block.get("input") + given = given if isinstance(given, dict) else {} + name = block.get("name") + if name in WRITES: + if first_write is None: + first_write = turn + elif name == "Read" and entry.get("vendor"): + path = str(given.get("file_path") or "") + path = path.replace("\\", "/") + if marker in path: + uses.append((turn, path.split(marker, 1)[1])) + elif name == "Skill" and entry.get("skills"): + skill = str(given.get("skill") or "").strip() + if skill in known: + uses.append((turn, skill)) + return {"uses": uses, "first_write": first_write} + + +def map_uses(root, trials): + """Every trial's map use, by name, for the arms whose file points at + the templates and whose transcripts the root still holds.""" + home = os.path.join(root, "home") + uses = {} + for record in run_records(root): + if record.get("outcome") not in SCORABLE: + continue + name = name_of(record) + if name not in trials: + continue + arm = arm_of(name) + templates = mapped_templates(arm) + if not templates: + continue + files = transcript_files(home, record.get("workspace") or "", + started(record)) + if files: + uses[name] = map_use(files, arm, templates) + return uses + + +def mean_of(values): + """The mean of the values, or None of none.""" + return statistics.fmean(values) if values else None + + +def median_of(values): + """The median of the values, or None of none.""" + return float(statistics.median(values)) if values else None + + +def map_use_rows(trials, uses): + """Per arm: trials read, templates in its map, how many each trial read + or loaded, how many before its first write, the turn of the first, and + how many trials read every template before writing anything.""" + rows = [] + for arm in ARMS: + names = [name for name in ordered(trials) + if arm_of(name) == arm and name in uses] + if not names: + continue + total = len(mapped_templates(arm)) + counts, before, firsts = [], [], [] + for name in names: + use = uses[name] + counts.append(len({template for _, template in use["uses"]})) + before.append(len({ + template for turn, template in use["uses"] + if use["first_write"] is None or turn < use["first_write"]})) + if use["uses"]: + firsts.append(use["uses"][0][0]) + rows.append({"arm": arm, "trials": len(names), "total": total, + "read": mean_of(counts), "before": mean_of(before), + "first": median_of(firsts), + "up_front": sum(1 for count in before + if total and count >= total)}) + return rows + + +def map_use_lines(trials, uses): + """The use-of-the-map table and the note beside H7.""" + rows = map_use_rows(trials, uses) + lines = ["### Use of the map", "", + "From each trial's transcript: the templates it read from the " + "vendored copy or loaded as skills, counted once each, the " + "turn the first happened at, and how many came before the " + "trial's first write to a file of its own.", "", + "| Arm | Trials | Templates in the map | Read or loaded, mean " + "| Before the first write, mean | First at turn, median " + "| Read all before writing |", + "| --- | --- | --- | --- | --- | --- | --- |"] + + def shown(value, places=1): + return "—" if value is None else ("%%.%df" % places) % value + for row in rows: + lines.append("| %s | %d | %d | %s | %s | %s | %d of %d |" % ( + row["arm"], row["trials"], row["total"], shown(row["read"]), + shown(row["before"]), shown(row["first"], 0), row["up_front"], + row["trials"])) + for row in rows: + if row["arm"] != "lazyref": + continue + lines.append("") + if row["up_front"]: + lines.append("Beside H7: `lazyref` read every template before " + "its first write in %d of %d trials. Those trials " + "measured reading up front, not on demand." + % (row["up_front"], row["trials"])) + else: + lines.append("Beside H7: no `lazyref` trial read every template " + "before its first write, so H7 reads on-demand " + "reading.") + return lines + + +# Round 5d's screen for round 6: the candidates, read against the bare arm, +# and how many of them go on. +SCREEN_CANDIDATES = ("inline", "hybrid", "reference", "skills", "hand", + "short") + ROUND5E_ARMS +SCREEN_KEEPS = 4 +SCREEN_ROWS = ROUND5D_ROWS + ("reliability",) + + +def round6_screen(table, results): + """Each candidate against the bare arm: out where a deciding row reads + worse, the rest ranked by rows better and then by mean cost, the top + four going on to round 6. Candidates the run holds no contrast for are + left out.""" + rows = [] + for arm in SCREEN_CANDIDATES: + label = "%s-%s" % (arm, BARE) + if not any(label in results.get(key, {}) for key in SCREEN_ROWS): + continue + readings = {key: row_reading(results.get(key, {}).get(label)) + for key in SCREEN_ROWS} + rows.append({"arm": arm, + "worse": [key for key in SCREEN_ROWS + if readings[key] == "worse"], + "better": sum(1 for reading in readings.values() + if reading == "better"), + "cost": arm_mean(table, "cost_usd", arm), + "rank": None, "round6": False}) + kept = [row for row in rows if not row["worse"]] + kept.sort(key=lambda row: (-row["better"], row["cost"] + if row["cost"] is not None else float("inf"))) + for rank, row in enumerate(kept, 1): + row["rank"] = rank + row["round6"] = rank <= SCREEN_KEEPS + return rows + + +def screen_lines(table, results): + """The screen as a table, and the arms round 6 runs.""" + rows = round6_screen(table, results) + lines = ["### Round 6's arms, by the screen of 13d.9", "", + "Each candidate is read against `%s` by the rules of 13d.7. An " + "arm worse on a deciding row is out; the rest rank by how many " + "rows read better, then by mean cost. The screen decides which " + "arms run again, not which arm is better." % BARE, "", + "| Arm | Rows better | Rows worse | Mean cost | Screen |", + "| --- | --- | --- | --- | --- |"] + for row in rows: + if row["worse"]: + screen = "out: %s worse" % ", ".join( + SHORT.get(key, key) for key in row["worse"]) + else: + screen = "rank %d%s" % (row["rank"], + ", round 6" if row["round6"] else "") + lines.append("| %s | %d | %d | %s | %s |" % ( + row["arm"], row["better"], len(row["worse"]), + "—" if row["cost"] is None else "$%.2f" % row["cost"], screen)) + chosen = [row["arm"] for row in sorted( + (row for row in rows if row["round6"]), key=lambda row: row["rank"])] + lines.extend(["", "Round 6 runs `%s`%s." % ( + BARE, " and " + spoken(["`%s`" % arm for arm in chosen]) + if chosen else " alone")]) + return lines + + +def round5e_section(root, trials, table, results, seed, margins): + """Round 5e's answer: round 5d's reading of H7 to H9, how each trial + used its map, and the screen for round 6.""" + lines = round5d_section(trials, table, results, seed, margins, + ROUND5E_HYPOTHESES, + "## Round 5e: the templates on demand") + lines.append("") + lines.extend(map_use_lines(trials, map_uses(root, trials))) + lines.append("") + lines.extend(screen_lines(table, results)) + return lines + + +def round5e_checks(): + """Round 5e's rules: its arms are read under round 5d's rules and its + own registration, its contrasts are declared, H7 to H9 read as + registered, the map's use is counted from the transcript, and the + screen ranks round 6's candidates as 13d.9 says.""" + checks = [] + fresh = {"lazyref-1": {}, "lazyskills-1": {}} + earlier = {"hand-1": {}, "short-1": {}} + got = (is_round5e(fresh), is_round5d(fresh), later_rules_of(fresh), + round_arms(fresh) == ROUND5E_ARMS, + margins_of(fresh) is ROUND5D_MARGINS, + registration_of(fresh), registration_of(earlier), + owed_blocks(fresh) == list(range(2, ROUND5_K + 1))) + checks.append(("round 5e reads under round 5d's rules, against its own " + "registration, owing its own arms' blocks", + got == (True, False, True, True, True, + ROUND5E_REGISTRATION, ROUND5D_REGISTRATION, True), + got)) + + present = {"%s-1" % arm: {} for arm in + ("none", "reference", "skills", "hand", "short") + ROUND5E_ARMS} + active = active_contrasts(present) + wanted = [tuple(label.split("-")) for _, label, _ in ROUND5E_HYPOTHESES] + against = [(arm, other) for arm in ROUND5E_ARMS + for other in ("none", "reference", "skills", "hand", "short")] + got = (all(pair in active for pair in wanted + against), + all(label in PLAIN_QUESTIONS for _, label, _ in ROUND5E_HYPOTHESES)) + checks.append(("round 5e's contrasts are declared: each map arm against " + "none and every reused arm, and the skill against the " + "file", got == (True, True), got)) + + def results_for(label, **overrides): + readings = {key: "held" for key in SCREEN_ROWS} + readings.update(overrides) + return {key: {label: {"verdict": reading}} + for key, reading in readings.items()} + label = "lazyref-reference" + got = [round5d_hypothesis(results_for(label), label, "held")[0], + round5d_hypothesis(results_for(label, task_success="better"), + label, "held")[0], + round5d_hypothesis(results_for(label, judge_security="worse"), + label, "held")[0], + round5d_hypothesis(results_for(label, reliability="worse"), + label, "held")[0], + round5d_hypothesis(results_for(label, task_success="open"), + label, "held")[0]] + checks.append(("H7 to H9 are supported when every row is held or better, " + "refuted by any worse row, reliability's included", + got == ["supported", "supported", "refuted", "refuted", + "inconclusive"], got)) + + scratch = os.path.join(tempfile.gettempdir(), + "efficacy-report-map-use-self-test") + shutil.rmtree(scratch, ignore_errors=True) + os.makedirs(scratch) + + def call(name, **given): + return {"type": "tool_use", "id": "t", "name": name, "input": given} + + def line(kind, message_id, *blocks): + return json.dumps({"type": kind, + "message": {"id": message_id, + "content": list(blocks)}}) + "\n" + into = VENDORED["into"] + planted = os.path.join(scratch, "planted.jsonl") + with io.open(planted, "w", encoding="utf-8", newline="\n") as handle: + handle.write(line("user", "u1", {"type": "text", "text": "go"})) + handle.write(line("assistant", "a1", call( + "Read", file_path="C:\\pen\\%s\\templates\\core\\quality.md" + % into.replace("/", "\\")))) + handle.write(line("assistant", "a1", {"type": "text", "text": "ok"})) + handle.write(line("assistant", "a2", call( + "Read", file_path="/pen/%s/templates/core/quality.md" % into))) + handle.write(line("assistant", "a3", call("Write", file_path="x.py"))) + handle.write(line("assistant", "a4", call( + "Read", file_path="/pen/%s/templates/backend/http.md" % into))) + handle.write(line("assistant", "a5", call("Read", + file_path="/pen/x.py"))) + reading = map_use([planted], "lazyref", + ["templates/core/quality.md", + "templates/backend/http.md"]) + skills = os.path.join(scratch, "skills.jsonl") + with io.open(skills, "w", encoding="utf-8", newline="\n") as handle: + handle.write(line("assistant", "s1", call("Skill", + skill="base-quality"))) + handle.write(line("assistant", "s2", call("Skill", skill="run"))) + handle.write(line("assistant", "s3", call("Edit", file_path="x.py"), + call("Skill", skill="backend-api"))) + loading = map_use([skills], "lazyskills", ["base-quality", "backend-api"]) + rows = map_use_rows({"lazyref-1": {}, "lazyskills-1": {}}, + {"lazyref-1": reading, "lazyskills-1": loading}) + summary = [(row["arm"], row["read"], row["before"], row["first"], + row["up_front"]) for row in rows] + shutil.rmtree(scratch, ignore_errors=True) + got = (reading, loading, summary) + checks.append(("the map's use counts each template read or skill loaded, " + "with its turn, and those before the first write", + reading == {"uses": [(1, "templates/core/quality.md"), + (2, "templates/core/quality.md"), + (4, "templates/backend/http.md")], + "first_write": 3} + and loading == {"uses": [(1, "base-quality"), + (3, "backend-api")], + "first_write": 3} + and summary == [("lazyref", 2.0, 1.0, 1.0, 0), + ("lazyskills", 2.0, 1.0, 1.0, 0)], + got)) + got = (mapped_templates("none"), len(mapped_templates("lazyskills")), + len(mapped_templates("lazyref"))) + checks.append(("an arm's map is its skills or its vendored chain, and the " + "bare arm has none", got == ([], 13, 13), got)) + + # Two arms better on two rows, the cheaper first; one out on task + # success; three held, by cost; the fifth in rank stays out of round 6. + costs = {"inline": 10.0, "hybrid": 8.0, "reference": 6.0, "skills": 5.0, + "hand": 9.0, "short": 20.0} + table = {"cost_usd": {"values": {arm: {1: cost, 2: cost} + for arm, cost in costs.items()}}} + results = {key: {} for key in SCREEN_ROWS} + for arm in costs: + for key in SCREEN_ROWS: + results[key]["%s-none" % arm] = {"verdict": "held"} + for key in ("task_success", "judge_security"): + results[key]["inline-none"]["verdict"] = "better" + results[key]["hybrid-none"]["verdict"] = "better" + results["task_success"]["reference-none"]["verdict"] = "worse" + screen = {row["arm"]: (row["rank"], row["round6"], row["worse"]) + for row in round6_screen(table, results)} + checks.append(("the screen drops an arm worse than none on a deciding " + "row, ranks the rest by rows better and then by cost, " + "and keeps four", + screen == {"hybrid": (1, True, []), + "inline": (2, True, []), + "skills": (3, True, []), + "hand": (4, True, []), + "short": (5, False, []), + "reference": (None, False, ["task_success"])}, + screen)) + text = "\n".join(screen_lines(table, results)) + checks.append(("the screen names the arms round 6 runs", + "Round 6 runs `none` and `hybrid`, `inline`, `skills` and " + "`hand`." in text + and "out: %s worse" % SHORT["task_success"] in text, + text.splitlines()[-1])) + return checks + + def round5d_checks(seed): """Round 5d's rules: a working build, quality on working builds, a verdict only past the margin, economy's margins, reliability's interval @@ -6179,6 +6631,7 @@ def self_test(seed): checks.extend(exclusion_checks()) checks.extend(round5_checks()) checks.extend(round5d_checks(seed)) + checks.extend(round5e_checks()) checks.extend(iso_checks(seed)) checks.extend(band_checks(seed)) checks.extend(failed_build_checks()) @@ -6249,8 +6702,7 @@ def main(argv): if is_round5(trials): try: problem = registration_problem( - options.root, ROUND5D_REGISTRATION if is_round5d(trials) - else ROUND5_REGISTRATION) + options.root, registration_of(trials)) except TrialError as error: problem = str(error) if problem: From 6fafc93aa136d455b8d9add9cf1da4f326be2607 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 10:44:50 +0200 Subject: [PATCH 02/21] fix(efficacy): round 5e's reading after review round 1 A contrast crosses rounds where its arms ran in different roots, reused or not, and a trial copied on keeps the root it ran in as its origin. The screen names no arm for round 6 while a registered candidate is missing, and the registration reuses all five of round 5c's arms so none is. The plain report asks the latest round's questions. A shell command that redirects, copies, moves or creates is the trial's first write; a template off the arm's map is not counted; a trial that never wrote says nothing about reading up front. Every trial's reads are listed with their turns, in the record and in the aggregate. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 8 +- docs/rounds/round-5e.md | 39 +++-- tests/efficacy/report.py | 317 +++++++++++++++++++++++++++++++-------- tests/efficacy/reuse.py | 17 ++- 4 files changed, 294 insertions(+), 87 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index add0243..fac711d 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -161,7 +161,7 @@ when: | ID | Kind | Checked by | | -- | ---- | ---------- | | FR-12-01 | Self-test | `report.py` "a contrast crossing rounds carries no verdict and counts nowhere"
`report.py` "a comparison across rounds reads as not given, not too few runs" | -| FR-12-02 | Self-test | `report.py` "a contrast across rounds is unpaired, with a verdict"
`report.py` "a round-5d run reads H4 against a reused `none`, unpaired"
`report.py` "an unpaired contrast leaves out two trials, not blocks" | +| FR-12-02 | Self-test | `report.py` "a contrast across rounds is unpaired, with a verdict"
`report.py` "a round-5d run reads H4 against a reused `none`, unpaired"
`report.py` "an unpaired contrast leaves out two trials, not blocks"
`report.py` "a contrast crosses rounds where its arms ran in different roots, reused or not"
`reuse.py` "a trial copied on keeps the root it ran in as its origin" | | FR-12-03 | Self-test | `report.py` "it prints every declared contrast its arms ran"
`report.py` "a three-arm run prints only its own contrasts" | | FR-12-04 | Self-test | `report.py` "round 5 reports the files it supersedes without a verdict" | | FR-12-05 | Self-test | `report.py` "the report links its appendix, and the appendix the record"
`report.py` "the appendix holds what produced the results, the radar's axes and the verdict vector, and nothing else" | @@ -170,9 +170,9 @@ when: | FR-12-09 | Self-test | `report.py` "withdrawal blanks every value of the row"
`report.py` "its verdict vector row reads withdrawn"
`report.py` "the withdrawal section names it and why"
`report.py` "a run graded by another revision withdraws nothing"
`report.py` "a metric not withdrawn keeps its verdict" | | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | -| FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none" | -| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs" | +| FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use" | +| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/docs/rounds/round-5e.md b/docs/rounds/round-5e.md index e77ec75..5468778 100644 --- a/docs/rounds/round-5e.md +++ b/docs/rounds/round-5e.md @@ -5,8 +5,9 @@ Round 5d keeps its registration as it was when its first trial ran; this one is a registration of its own. Amended on 2026-11-05, before any round-5e trial ran: the report's reading of -the round moved from "still needed" to done in 13e.5, and the reuse of the -earlier rounds' arms is what remains. +the round moved from "still needed" to done in 13e.5; all five of round 5c's +arms are reused, so the screen of 13d.9 reads every candidate; and the reuse of +the earlier rounds' arms is what remains. ## 13e. Round 5e: the templates on demand, against rounds 5c and 5d @@ -30,7 +31,7 @@ Three things differ: the arms, the order, and what is reused. | --- | --- | --- | | `lazyref` | 15, fresh | `arms/lazyref/CLAUDE.md`, made for 5e | | `lazyskills` | 15, fresh | `arms/lazyskills/`, root and 13 skills, made for 5e | -| `none`, `reference`, `skills` | 15 each, reused | Round 5c's, re-scored in 5d's root | +| round 5c's five arms | 15 each, reused | Round 5c's, re-scored in 5d's root | | `hand`, `short` | 15 each, reused | Round 5d's, scored and read | Both fresh arms live under `tests/efficacy/arms/`. They are fixed text, made by @@ -82,8 +83,11 @@ own: 30 trials in the rotated order. - The run starts `lazyref-1`, `lazyskills-1`, and each block starts one arm later. - The two arms share every block, so `lazyskills` minus `lazyref` is paired. -- No fresh `none`, `reference` or `skills` runs beside them, so drift against - rounds 5c and 5d goes unchecked, as in round 5d. The CLI is pinned. +- No fresh trial of a reused arm runs beside them, so drift against rounds 5c + and 5d goes unchecked, as in round 5d. The CLI is pinned. +- A contrast pairs only trials that ran in one round; a reused trial keeps + the root it ran in as its origin however many times it is copied on, so a + contrast of two reused arms from different rounds is unpaired too. ### 13e.4 Hypotheses @@ -138,16 +142,19 @@ round-6 screen of 13d.9, which round 5e's arms join as candidates. - every metric of [ch. 8.6](../architecture/08-crosscutting-concepts.md) for each fresh arm against round 5c's `none`, `reference` and `skills` and round - 5d's `hand` and `short`; + 5d's `hand` and `short`; `inline` and `hybrid` are reused for the screen + alone; - cost, turns, tokens and wall time, and the words each arm puts in context on every turn; -- **use of the map**, per trial, from the transcript: how many templates the - agent read (`lazyref`, a read of a file under the vendored path) or loaded - (`lazyskills`, a skill call naming one of the arm's skills), which ones, the - turn each happened at, and how many happened before the trial's first write - to a file of its own. Round 5c's `reference` read 13 of 13 in turns 1 and 2; - a map arm that does the same has not measured on-demand reading, and the - report says so beside H7. +- **use of the map**, per trial, from the transcript: how many templates of the + map the agent read (`lazyref`, a read of a file of the chain under the + vendored path) or loaded (`lazyskills`, a skill call naming one of the arm's + skills), which ones, the turn each happened at, and how many happened before + the trial's first write to a file of its own, a write tool's call or a shell + command that redirects, copies, moves or creates. A trial that never wrote + says nothing about reading up front. Round 5c's `reference` read 13 of 13 in + turns 1 and 2; a map arm that does the same has not measured on-demand + reading, and the report says so beside H7. ### 13e.5 Before the first trial @@ -170,9 +177,9 @@ Done after it, before any round-5e trial, each with a self-test: beside H7 - the round-6 screen of 13d.9, with round 5e's arms among the candidates -Still needed: round 5c's `reference` and `skills` and round 5d's `hand` and -`short` brought into round 5e's root by `reuse.py`, scored and read as they -were, with their tool lock. +Still needed: round 5c's five arms and round 5d's `hand` and `short` brought +into round 5e's root by `reuse.py` from round 5d's root, scored and read as +they were, with their tool lock. ### 13e.6 When it runs diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 5b2493b..fd47389 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -747,18 +747,30 @@ def reused_arms(trials): return [(arm, counts[arm]) for arm in ARMS if arm in counts] -def crossing(active, reused): - """The contrasts pairing a reused arm with one run in this round.""" - earlier = {arm for arm, _ in reused} +def arm_origins(trials): + """Where each arm's trials ran: the root they were reused from, or None + for an arm run in this round. A reused trial that names no root is + told apart from a fresh one by the name its origin carries.""" + origins = {} + for name in ordered(trials): + source = (trials[name].get("scores") or {}).get("reused_from") or {} + origins.setdefault(arm_of(name), source.get("root") + or source.get("name") or None) + return origins + + +def crossing(active, origins): + """The contrasts whose arms ran in different rounds: one reused and one + run here, or both reused from different roots.""" return [pair for pair in active - if len(set(pair) & earlier) == 1] + if origins.get(pair[0]) != origins.get(pair[1])] def crossed_labels(trials): - """Every contrast label pairing a reused arm with one run in this round.""" + """Every contrast label whose arms ran in different rounds.""" return {"%s-%s" % pair for pair in crossing(active_contrasts(trials), - reused_arms(trials))} + arm_origins(trials))} def collect(trials, metrics=METRICS, later_rules=None): @@ -1614,7 +1626,7 @@ def unrecorded_voids(root, sequence, recorded): def write_report(root, trials, table, results, seed, out_dir, - withdrawn=None, cross=None, iso=None): + withdrawn=None, cross=None, iso=None, uses=None): """The dated round report, written to `out_dir`. The directory has no default so a shakedown of the writer renders into @@ -1744,7 +1756,7 @@ def write_report(root, trials, table, results, seed, out_dir, lines.append("") if is_round5e(trials): lines.extend(round5e_section(root, trials, table, results, seed, - margins_of(trials))) + margins_of(trials), uses)) lines.append("") lines.append("## Raw numbers, per trial") @@ -2260,9 +2272,13 @@ def plain_report_lines(root, trials, table, results, radar, appendix, k, context_lines(arm), iso)) lines.append("") present = {arm_of(name) for name in trials} - if is_round5d(trials): + if later_rules_of(trials): + # The latest round's questions are the run's: a round-5e root + # holds round 5d's arms too, reused, and answers its own. + hypotheses = (ROUND5E_HYPOTHESES if is_round5e(trials) + else ROUND5D_HYPOTHESES) lines.extend(["## The questions this round asked", ""]) - for _, label, wanted in ROUND5D_HYPOTHESES: + for _, label, wanted in hypotheses: if not set(label.split("-")) <= present: continue state, _ = round5d_hypothesis(results, label, wanted) @@ -2796,9 +2812,15 @@ def round5d_section(trials, table, results, seed, margins, return lines -# The tools whose call writes a file of the trial's own. A read of the map's -# templates before the first of them came before any work. +# The tools whose call writes a file of the trial's own, and the shell tools +# whose command may: one is a write where its text redirects, copies, moves +# or creates. A read of the map's templates before the first of them came +# before any work. WRITES = ("Write", "Edit", "MultiEdit", "NotebookEdit") +SHELLS = ("Bash", "PowerShell") +SHELL_WRITE = re.compile( + r"(>|\btee\b|\btouch\b|\bmkdir\b|\bcp\b|\bmv\b|\binstall\b" + r"|New-Item|Set-Content|Add-Content|Out-File|Copy-Item|Move-Item)") def mapped_templates(arm): @@ -2852,14 +2874,20 @@ def map_use(files, arm, templates=None): given = block.get("input") given = given if isinstance(given, dict) else {} name = block.get("name") - if name in WRITES: + writes = name in WRITES or ( + name in SHELLS + and SHELL_WRITE.search(str(given.get("command") + or "")) is not None) + if writes: if first_write is None: first_write = turn elif name == "Read" and entry.get("vendor"): path = str(given.get("file_path") or "") path = path.replace("\\", "/") if marker in path: - uses.append((turn, path.split(marker, 1)[1])) + template = path.split(marker, 1)[1] + if not known or template in known: + uses.append((turn, template)) elif name == "Skill" and entry.get("skills"): skill = str(given.get("skill") or "").strip() if skill in known: @@ -2914,19 +2942,42 @@ def map_use_rows(trials, uses): for name in names: use = uses[name] counts.append(len({template for _, template in use["uses"]})) - before.append(len({ - template for turn, template in use["uses"] - if use["first_write"] is None or turn < use["first_write"]})) + + # A trial that never wrote has no "before", and says nothing + # about reading up front. + if use["first_write"] is not None: + before.append(len({template for turn, template in use["uses"] + if turn < use["first_write"]})) if use["uses"]: firsts.append(use["uses"][0][0]) rows.append({"arm": arm, "trials": len(names), "total": total, "read": mean_of(counts), "before": mean_of(before), - "first": median_of(firsts), + "wrote": len(before), "first": median_of(firsts), "up_front": sum(1 for count in before if total and count >= total)}) return rows +def map_use_detail(trials, uses): + """Every trial's map use, one row each: the turn of its first write and + each template with the turn it was read or loaded at.""" + lines = ["#### Per trial", "", + "| Trial | First write at turn | Templates, by turn |", + "| --- | --- | --- |"] + for name in ordered(trials): + if name not in uses: + continue + use = uses[name] + reads = ", ".join("%d: %s" % (turn, template[len("templates/"):] + if template.startswith("templates/") + else template) + for turn, template in use["uses"]) or "none" + lines.append("| %s | %s | %s |" % ( + name, "—" if use["first_write"] is None else use["first_write"], + reads)) + return lines + + def map_use_lines(trials, uses): """The use-of-the-map table and the note beside H7.""" rows = map_use_rows(trials, uses) @@ -2946,20 +2997,22 @@ def shown(value, places=1): lines.append("| %s | %d | %d | %s | %s | %s | %d of %d |" % ( row["arm"], row["trials"], row["total"], shown(row["read"]), shown(row["before"]), shown(row["first"], 0), row["up_front"], - row["trials"])) + row["wrote"])) for row in rows: if row["arm"] != "lazyref": continue lines.append("") if row["up_front"]: - lines.append("Beside H7: `lazyref` read every template before " - "its first write in %d of %d trials. Those trials " - "measured reading up front, not on demand." - % (row["up_front"], row["trials"])) + lines.append("Beside H7: `lazyref` read every template of its map " + "before its first write in %d of the %d trials that " + "wrote. Those trials measured reading up front, not " + "on demand." % (row["up_front"], row["wrote"])) else: lines.append("Beside H7: no `lazyref` trial read every template " - "before its first write, so H7 reads on-demand " - "reading.") + "of its map before its first write, so H7 reads " + "on-demand reading.") + lines.append("") + lines.extend(map_use_detail(trials, uses)) return lines @@ -2974,12 +3027,15 @@ def shown(value, places=1): def round6_screen(table, results): """Each candidate against the bare arm: out where a deciding row reads worse, the rest ranked by rows better and then by mean cost, the top - four going on to round 6. Candidates the run holds no contrast for are - left out.""" + four going on to round 6 once every candidate is read. A candidate the + run holds no contrast for is named as missing, and nothing goes on + until it is read too.""" rows = [] + missing = [] for arm in SCREEN_CANDIDATES: label = "%s-%s" % (arm, BARE) if not any(label in results.get(key, {}) for key in SCREEN_ROWS): + missing.append(arm) continue readings = {key: row_reading(results.get(key, {}).get(label)) for key in SCREEN_ROWS} @@ -2995,13 +3051,14 @@ def round6_screen(table, results): if row["cost"] is not None else float("inf"))) for rank, row in enumerate(kept, 1): row["rank"] = rank - row["round6"] = rank <= SCREEN_KEEPS - return rows + row["round6"] = rank <= SCREEN_KEEPS and not missing + return rows, missing def screen_lines(table, results): - """The screen as a table, and the arms round 6 runs.""" - rows = round6_screen(table, results) + """The screen as a table, and the arms round 6 runs, or the candidates + still to be read before it names them.""" + rows, missing = round6_screen(table, results) lines = ["### Round 6's arms, by the screen of 13d.9", "", "Each candidate is read against `%s` by the rules of 13d.7. An " "arm worse on a deciding row is out; the rest rank by how many " @@ -3021,20 +3078,27 @@ def screen_lines(table, results): "—" if row["cost"] is None else "$%.2f" % row["cost"], screen)) chosen = [row["arm"] for row in sorted( (row for row in rows if row["round6"]), key=lambda row: row["rank"])] - lines.extend(["", "Round 6 runs `%s`%s." % ( - BARE, " and " + spoken(["`%s`" % arm for arm in chosen]) - if chosen else " alone")]) + if missing: + lines.extend(["", "The screen is partial: %s %s not in this root, so " + "it names no arms for round 6 yet." % ( + spoken(["`%s`" % arm for arm in missing]), + "is" if len(missing) == 1 else "are")]) + else: + lines.extend(["", "Round 6 runs `%s`%s." % ( + BARE, " and " + spoken(["`%s`" % arm for arm in chosen]) + if chosen else " alone")]) return lines -def round5e_section(root, trials, table, results, seed, margins): +def round5e_section(root, trials, table, results, seed, margins, uses=None): """Round 5e's answer: round 5d's reading of H7 to H9, how each trial used its map, and the screen for round 6.""" lines = round5d_section(trials, table, results, seed, margins, ROUND5E_HYPOTHESES, "## Round 5e: the templates on demand") lines.append("") - lines.extend(map_use_lines(trials, map_uses(root, trials))) + lines.extend(map_use_lines( + trials, map_uses(root, trials) if uses is None else uses)) lines.append("") lines.extend(screen_lines(table, results)) return lines @@ -3071,6 +3135,23 @@ def round5e_checks(): "none and every reused arm, and the skill against the " "file", got == (True, True), got)) + # In round 5e's root, `none` and `reference` came from round 5c and + # `hand` from round 5d, all reused: `hand − none` crosses rounds, `none` + # against `reference` does not, and a fresh arm crosses every reused one. + def reused(root): + return {"scores": {"reused_from": {"root": root, "name": "x-1"}}} + mixed = {"none-1": reused("r5c"), "reference-1": reused("r5c"), + "hand-1": reused("r5d"), "lazyref-1": {"scores": {}}} + crossed = crossed_labels(mixed) + got = (sorted(crossed), arm_origins(mixed)["lazyref"]) + checks.append(("a contrast crosses rounds where its arms ran in " + "different roots, reused or not", + "hand-none" in crossed and "lazyref-none" in crossed + and "lazyref-hand" in crossed + and "reference-none" not in crossed + and "lazyref-reference" in crossed and got[1] is None, + got)) + def results_for(label, **overrides): readings = {key: "held" for key in SCREEN_ROWS} readings.update(overrides) @@ -3113,14 +3194,18 @@ def line(kind, message_id, *blocks): handle.write(line("assistant", "a1", {"type": "text", "text": "ok"})) handle.write(line("assistant", "a2", call( "Read", file_path="/pen/%s/templates/core/quality.md" % into))) - handle.write(line("assistant", "a3", call("Write", file_path="x.py"))) + handle.write(line("assistant", "a3", call("Bash", command="ls src"))) handle.write(line("assistant", "a4", call( + "Bash", command="echo x > x.py"))) + handle.write(line("assistant", "a5", call("Write", file_path="y.py"))) + handle.write(line("assistant", "a6", call( "Read", file_path="/pen/%s/templates/backend/http.md" % into))) - handle.write(line("assistant", "a5", call("Read", + handle.write(line("assistant", "a7", call( + "Read", file_path="/pen/%s/templates/core/oop.md" % into))) + handle.write(line("assistant", "a8", call("Read", file_path="/pen/x.py"))) - reading = map_use([planted], "lazyref", - ["templates/core/quality.md", - "templates/backend/http.md"]) + chain = ["templates/core/quality.md", "templates/backend/http.md"] + reading = map_use([planted], "lazyref", chain) skills = os.path.join(scratch, "skills.jsonl") with io.open(skills, "w", encoding="utf-8", newline="\n") as handle: handle.write(line("assistant", "s1", call("Skill", @@ -3129,24 +3214,60 @@ def line(kind, message_id, *blocks): handle.write(line("assistant", "s3", call("Edit", file_path="x.py"), call("Skill", skill="backend-api"))) loading = map_use([skills], "lazyskills", ["base-quality", "backend-api"]) - rows = map_use_rows({"lazyref-1": {}, "lazyskills-1": {}}, - {"lazyref-1": reading, "lazyskills-1": loading}) - summary = [(row["arm"], row["read"], row["before"], row["first"], - row["up_front"]) for row in rows] + silent = os.path.join(scratch, "silent.jsonl") + with io.open(silent, "w", encoding="utf-8", newline="\n") as handle: + for index, name in enumerate(chain, 1): + handle.write(line("assistant", "n%d" % index, call( + "Read", file_path="/pen/%s/%s" % (into, name)))) + never_wrote = map_use([silent], "lazyref", chain) + rows = map_use_rows( + {"lazyref-1": {}, "lazyref-2": {}, "lazyskills-1": {}}, + {"lazyref-1": reading, "lazyref-2": never_wrote, + "lazyskills-1": loading}) + summary = [(row["arm"], row["read"], row["before"], row["wrote"], + row["first"], row["up_front"]) for row in rows] + detail = "\n".join(map_use_detail({"lazyref-1": {}}, + {"lazyref-1": reading})) shutil.rmtree(scratch, ignore_errors=True) - got = (reading, loading, summary) + got = (reading, loading, never_wrote, summary) checks.append(("the map's use counts each template read or skill loaded, " "with its turn, and those before the first write", reading == {"uses": [(1, "templates/core/quality.md"), (2, "templates/core/quality.md"), - (4, "templates/backend/http.md")], - "first_write": 3} + (6, "templates/backend/http.md")], + "first_write": 4} and loading == {"uses": [(1, "base-quality"), (3, "backend-api")], "first_write": 3} - and summary == [("lazyref", 2.0, 1.0, 1.0, 0), - ("lazyskills", 2.0, 1.0, 1.0, 0)], + and never_wrote["first_write"] is None + and summary == [("lazyref", 2.0, 1.0, 1, 1.0, 0), + ("lazyskills", 2.0, 1.0, 1, 1.0, 0)], got)) + checks.append(("a shell command that writes counts as the first write, " + "a template off the map is not counted, and a trial that " + "never wrote says nothing about reading up front", + reading["first_write"] == 4 + and all(template != "templates/core/oop.md" + for _, template in reading["uses"]) + and summary[0][3] == 1 and summary[0][5] == 0, + (reading, summary))) + checks.append(("every trial's reads are listed with their turns", + "| lazyref-1 | 4 | 1: core/quality.md, 2: core/quality.md, " + "6: backend/http.md |" in detail, detail)) + planted_uses = {"lazyref-1": reading} + kept = aggregate(1, {}, {}, {}, {}, None, None, planted_uses)["map_use"] + checks.append(("the aggregate keeps each trial's map use", + kept == {"lazyref-1": { + "first_write": 4, + "uses": [{"turn": 1, + "template": "templates/core/quality.md"}, + {"turn": 2, + "template": "templates/core/quality.md"}, + {"turn": 6, + "template": "templates/backend/http.md"}]}} + and "map_use" not in aggregate(1, {}, {}, {}, {}, None, + None), + kept)) got = (mapped_templates("none"), len(mapped_templates("lazyskills")), len(mapped_templates("lazyref"))) checks.append(("an arm's map is its skills or its vendored chain, and the " @@ -3166,17 +3287,39 @@ def line(kind, message_id, *blocks): results[key]["inline-none"]["verdict"] = "better" results[key]["hybrid-none"]["verdict"] = "better" results["task_success"]["reference-none"]["verdict"] = "worse" + partial_rows, missing = round6_screen(table, results) + partial = {row["arm"]: (row["rank"], row["round6"], row["worse"]) + for row in partial_rows} + checks.append(("the screen ranks what it holds and names no arm for " + "round 6 while a candidate is missing", + missing == list(ROUND5E_ARMS) + and partial["hybrid"] == (1, False, []) + and "names no arms for round 6 yet" in + "\n".join(screen_lines(table, results)) + and "`lazyref` and `lazyskills` are not in this root" + in "\n".join(screen_lines(table, results)), + (partial, missing))) + for arm in ROUND5E_ARMS: + costs[arm] = 30.0 + table["cost_usd"]["values"][arm] = {1: 30.0, 2: 30.0} + for key in SCREEN_ROWS: + results[key]["%s-none" % arm] = {"verdict": "held"} + full_rows, missing = round6_screen(table, results) screen = {row["arm"]: (row["rank"], row["round6"], row["worse"]) - for row in round6_screen(table, results)} + for row in full_rows} checks.append(("the screen drops an arm worse than none on a deciding " "row, ranks the rest by rows better and then by cost, " "and keeps four", - screen == {"hybrid": (1, True, []), - "inline": (2, True, []), - "skills": (3, True, []), - "hand": (4, True, []), - "short": (5, False, []), - "reference": (None, False, ["task_success"])}, + not missing + and screen == {"hybrid": (1, True, []), + "inline": (2, True, []), + "skills": (3, True, []), + "hand": (4, True, []), + "short": (5, False, []), + "lazyref": (6, False, []), + "lazyskills": (7, False, []), + "reference": (None, False, + ["task_success"])}, screen)) text = "\n".join(screen_lines(table, results)) checks.append(("the screen names the arms round 6 runs", @@ -3184,6 +3327,26 @@ def line(kind, message_id, *blocks): "`hand`." in text and "out: %s worse" % SHORT["task_success"] in text, text.splitlines()[-1])) + + # The plain report answers the latest round's questions: with round + # 5e's arms present, H7 to H9, and not round 5d's. + design = {"none": 3, "reference": 3, "skills": 3, "hand": 3, + "lazyref": 3, "lazyskills": 3} + run = {trial_name(arm, index): { + "scores": ({"reused_from": {"root": "r5c", "name": "x"}} + if arm in ("none", "reference", "skills") + else {"reused_from": {"root": "r5d", "name": "x"}} + if arm == "hand" else {}), + "change": None, "security": None, + "judge": {"answer": {"rubric": {"design": {"score": score}}}}} + for arm, score in design.items() for index in range(1, 4)} + plain = " ".join(rendered_plain(run, 20260912).split()) + checks.append(("the plain report asks round 5e's questions, not round " + "5d's", + PLAIN_QUESTIONS["lazyref-reference"] in plain + and PLAIN_QUESTIONS["lazyskills-lazyref"] in plain + and PLAIN_QUESTIONS["hand-none"] not in plain, + plain[plain.find("## The questions"):][:400])) return checks @@ -4783,16 +4946,24 @@ def iso_rules(trials): return not is_round5(trials) -def aggregate(seed, trials, table, results, withdrawn, check, iso): +def aggregate(seed, trials, table, results, withdrawn, check, iso, + uses=None): """What `aggregate.json` keeps beside the report: every row, contrast - and method the documents cite, and the ISO reading where the round - draws that radar, so each of its cells can be checked too.""" + and method the documents cite, the ISO reading where the round draws + that radar, and each trial's use of its map where the round reads it, + so each of its cells can be checked too.""" payload = {"seed": seed, "table": table, "results": results, "blocks": blocks_state(trials), "withdrawn": withdrawn, "cross_check": check} if iso: payload["iso"] = {"table": iso[0], "results": iso[1], "withdrawn": list(iso[2])} + if uses is not None: + payload["map_use"] = { + name: {"first_write": use["first_write"], + "uses": [{"turn": turn, "template": template} + for turn, template in use["uses"]]} + for name, use in sorted(uses.items())} return payload @@ -4909,7 +5080,7 @@ def finding_lines(trials, table, results, active): # footnote. reused = reused_arms(trials) if reused: - crossed = crossing(active, reused) + crossed = crossing(active, arm_origins(trials)) across = ("Compared unpaired with this round's trials, as round 5d " "registered" if is_round5d(trials) else "Pairing them with this round's trials, across days") @@ -5609,6 +5780,22 @@ def rendered(trials, seed, withdrawn): return before, table, text +def rendered_plain(trials, seed): + """The plain report a planted run renders, as text.""" + table = collect(trials) + results = round_contrasts(trials, table, seed) + scratch = os.path.join(tempfile.gettempdir(), + "efficacy-report-plain-render") + shutil.rmtree(scratch, ignore_errors=True) + os.makedirs(scratch) + target = write_report(scratch, trials, table, results, seed, + out_dir=scratch) + with io.open(target, encoding="utf-8") as handle: + text = handle.read() + shutil.rmtree(scratch, ignore_errors=True) + return text + + def section_rows(text, heading, label): """The rows of one report section that start with a metric's label.""" section = text.split(heading)[1].split("\n## ")[0] if heading in text \ @@ -6774,18 +6961,20 @@ def main(argv): disagree(results, check) iso = (iso_reading(trials, options.seed, withdrawn) if iso_rules(trials) else None) + uses = map_uses(options.root, trials) if is_round5e(trials) else None target = write_report(options.root, trials, table, results, options.seed, - out_dir, withdrawn, check, iso) + out_dir, withdrawn, check, iso, uses) with io.open(os.path.join(scoring_area(options.root), "aggregate.json"), "w", encoding="utf-8") as handle: json.dump(aggregate(options.seed, trials, table, results, withdrawn, - check, iso), handle, indent=2, sort_keys=True) + check, iso, uses), handle, indent=2, + sort_keys=True) print("Report: %s" % target) # An earlier round read by round 5d's rules is post-hoc: its own page, # beside the registered report, which it leaves as it was. - if options.posthoc_rules and not is_round5d(trials): + if options.posthoc_rules and not later_rules_of(trials): # The other judge is read by the same rules, so a contrast across # rounds is unpaired on both sides before their signs are compared. later = posthoc_rules_reading( diff --git a/tests/efficacy/reuse.py b/tests/efficacy/reuse.py index 58a4517..7e9a4f2 100644 --- a/tests/efficacy/reuse.py +++ b/tests/efficacy/reuse.py @@ -92,9 +92,12 @@ def reuse_trial(name, record, source, target): tarball = (record.get("frozen") or {}).get("tarball") if not tarball or not os.path.isfile(tarball): raise TrialError("%s has no frozen tarball at %s" % (name, tarball)) - origin = {"root": os.path.abspath(source), - "name": os.path.splitext(os.path.basename(tarball))[0], - "tarball": tarball} + # A trial copied on from a root that itself reused it keeps its first + # origin: the root it ran in is what decides which trials it pairs with. + origin = record.get("reused_from") or { + "root": os.path.abspath(source), + "name": os.path.splitext(os.path.basename(tarball))[0], + "tarball": tarball} copied = dict(record) copied["reused_from"] = origin @@ -320,6 +323,14 @@ def loaded(*parts): except TrialError: checks.append(("an arm the source never ran is refused", True)) + # Copied on from the target, a trial still names the root it ran in. + _, onward = reuse(target, os.path.join(scratch, "onward"), ["inline"]) + carried = {r["arm"] + "-" + str(r["trial"]): r + for r in loaded(onward)["trials"]}["inline-1"] + checks.append(("a trial copied on keeps the root it ran in as its origin", + carried["reused_from"]["root"] == os.path.abspath(source) + and carried["reused_from"]["name"] == "inline-1")) + for label, ok in checks: print(" %-52s %s" % (label, "ok" if ok else "FAILED")) remove_tree(scratch) From d98ccffa5b12ed6a80754219a2f6fee91dec0c6b Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 10:54:57 +0200 Subject: [PATCH 03/21] fix(efficacy): round 5e's reading after review round 2 The screen reads a candidate's presence from the trials, since every declared contrast has a result whether its arms ran or not. A shell command that names a template of the map reads it, and a redirection to the null device or into another stream is no write. Where no trial's first write could be placed, the note beside H7 withholds the reading. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- docs/rounds/round-5e.md | 13 +++-- tests/efficacy/report.py | 106 +++++++++++++++++++++++++++++---------- 3 files changed, 87 insertions(+), 34 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index fac711d..b0e862a 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/docs/rounds/round-5e.md b/docs/rounds/round-5e.md index 5468778..3234c3b 100644 --- a/docs/rounds/round-5e.md +++ b/docs/rounds/round-5e.md @@ -148,13 +148,12 @@ round-6 screen of 13d.9, which round 5e's arms join as candidates. every turn; - **use of the map**, per trial, from the transcript: how many templates of the map the agent read (`lazyref`, a read of a file of the chain under the - vendored path) or loaded (`lazyskills`, a skill call naming one of the arm's - skills), which ones, the turn each happened at, and how many happened before - the trial's first write to a file of its own, a write tool's call or a shell - command that redirects, copies, moves or creates. A trial that never wrote - says nothing about reading up front. Round 5c's `reference` read 13 of 13 in - turns 1 and 2; a map arm that does the same has not measured on-demand - reading, and the report says so beside H7. + vendored path, by the read tool or a shell command) or loaded (`lazyskills`, a + skill call naming one of the arm's skills), which ones, the turn each happened + at, and how many happened before the trial's first write to a file of its own: + a write tool's call, or a shell command that redirects into a file, copies, + moves or creates. A trial that never wrote says nothing about reading up + front, and the note beside H7 says so where no trial wrote. ### 13e.5 Before the first trial diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index fd47389..4216674 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2819,9 +2819,20 @@ def round5d_section(trials, table, results, seed, margins, WRITES = ("Write", "Edit", "MultiEdit", "NotebookEdit") SHELLS = ("Bash", "PowerShell") SHELL_WRITE = re.compile( - r"(>|\btee\b|\btouch\b|\bmkdir\b|\bcp\b|\bmv\b|\binstall\b" + r"(>|\btee\b|\btouch\b|\bmkdir\b|\bcp\b|\bmv\b" r"|New-Item|Set-Content|Add-Content|Out-File|Copy-Item|Move-Item)") +# A redirection that writes no file: to the null device, or of one stream +# into another. Taken out of a command before it is read for a write. +NULL_REDIRECT = re.compile( + r"\d?>{1,2}\s*(&\d|/dev/null|\$null|NUL\b)", re.IGNORECASE) + + +def shell_writes(command): + """Whether a shell command writes a file of the trial's own: it + redirects into a file, or copies, moves or creates one.""" + return SHELL_WRITE.search(NULL_REDIRECT.sub(" ", command)) is not None + def mapped_templates(arm): """What an arm's file points the agent at: the skills it carries, by @@ -2845,6 +2856,12 @@ def map_use(files, arm, templates=None): entry = ARMS.get(arm) or {} known = set(mapped_templates(arm) if templates is None else templates) marker = VENDORED["into"] + "/" + named = re.compile(re.escape(marker) + r"(templates/[\w./-]+\.md)") + + def read_templates(text): + """The templates of the map a path or a command names, in order.""" + return [template for template in named.findall(text) + if not known or template in known] uses = [] first_write = None turn = 0 @@ -2874,20 +2891,22 @@ def map_use(files, arm, templates=None): given = block.get("input") given = given if isinstance(given, dict) else {} name = block.get("name") - writes = name in WRITES or ( - name in SHELLS - and SHELL_WRITE.search(str(given.get("command") - or "")) is not None) - if writes: + command = str(given.get("command") or "") + command = command.replace("\\", "/") + + # A shell command may read a template and write a file + # in one go, so it is read for both. + if name in SHELLS and entry.get("vendor"): + uses.extend((turn, template) + for template in read_templates(command)) + if name in WRITES or (name in SHELLS + and shell_writes(command)): if first_write is None: first_write = turn elif name == "Read" and entry.get("vendor"): path = str(given.get("file_path") or "") - path = path.replace("\\", "/") - if marker in path: - template = path.split(marker, 1)[1] - if not known or template in known: - uses.append((turn, template)) + uses.extend((turn, template) for template in + read_templates(path.replace("\\", "/"))) elif name == "Skill" and entry.get("skills"): skill = str(given.get("skill") or "").strip() if skill in known: @@ -3002,7 +3021,12 @@ def shown(value, places=1): if row["arm"] != "lazyref": continue lines.append("") - if row["up_front"]: + if not row["wrote"]: + lines.append("Beside H7: no `lazyref` trial's first write could " + "be placed, so the map's use says nothing about " + "whether the templates were read up front or on " + "demand.") + elif row["up_front"]: lines.append("Beside H7: `lazyref` read every template of its map " "before its first write in %d of the %d trials that " "wrote. Those trials measured reading up front, not " @@ -3024,17 +3048,21 @@ def shown(value, places=1): SCREEN_ROWS = ROUND5D_ROWS + ("reliability",) -def round6_screen(table, results): +def round6_screen(trials, table, results): """Each candidate against the bare arm: out where a deciding row reads worse, the rest ranked by rows better and then by mean cost, the top four going on to round 6 once every candidate is read. A candidate the - run holds no contrast for is named as missing, and nothing goes on - until it is read too.""" + run holds no trial of is named as missing, and nothing goes on until + it is read too.""" rows = [] missing = [] + + # Every declared contrast has a result, computed or not, so an arm's + # presence is read from the trials and not from the results. + present = {arm_of(name) for name in trials} for arm in SCREEN_CANDIDATES: label = "%s-%s" % (arm, BARE) - if not any(label in results.get(key, {}) for key in SCREEN_ROWS): + if arm not in present or BARE not in present: missing.append(arm) continue readings = {key: row_reading(results.get(key, {}).get(label)) @@ -3055,10 +3083,10 @@ def round6_screen(table, results): return rows, missing -def screen_lines(table, results): +def screen_lines(trials, table, results): """The screen as a table, and the arms round 6 runs, or the candidates still to be read before it names them.""" - rows, missing = round6_screen(table, results) + rows, missing = round6_screen(trials, table, results) lines = ["### Round 6's arms, by the screen of 13d.9", "", "Each candidate is read against `%s` by the rules of 13d.7. An " "arm worse on a deciding row is out; the rest rank by how many " @@ -3100,7 +3128,7 @@ def round5e_section(root, trials, table, results, seed, margins, uses=None): lines.extend(map_use_lines( trials, map_uses(root, trials) if uses is None else uses)) lines.append("") - lines.extend(screen_lines(table, results)) + lines.extend(screen_lines(trials, table, results)) return lines @@ -3194,12 +3222,13 @@ def line(kind, message_id, *blocks): handle.write(line("assistant", "a1", {"type": "text", "text": "ok"})) handle.write(line("assistant", "a2", call( "Read", file_path="/pen/%s/templates/core/quality.md" % into))) - handle.write(line("assistant", "a3", call("Bash", command="ls src"))) + handle.write(line("assistant", "a3", call( + "Bash", command="ls src 2>/dev/null; pytest -q 2>&1 | tail -3"))) handle.write(line("assistant", "a4", call( "Bash", command="echo x > x.py"))) handle.write(line("assistant", "a5", call("Write", file_path="y.py"))) handle.write(line("assistant", "a6", call( - "Read", file_path="/pen/%s/templates/backend/http.md" % into))) + "Bash", command="cat %s/templates/backend/http.md | head" % into))) handle.write(line("assistant", "a7", call( "Read", file_path="/pen/%s/templates/core/oop.md" % into))) handle.write(line("assistant", "a8", call("Read", @@ -3251,6 +3280,23 @@ def line(kind, message_id, *blocks): for _, template in reading["uses"]) and summary[0][3] == 1 and summary[0][5] == 0, (reading, summary))) + checks.append(("a shell read of a template counts, and a redirection to " + "the null device or into another stream is no write", + (6, "templates/backend/http.md") in reading["uses"] + and not shell_writes("ls src 2>/dev/null") + and not shell_writes("pytest 2>&1 | tail") + and not shell_writes("Get-Content x.py > $null") + and shell_writes("echo x > x.py") + and shell_writes("cat a >> b.txt") + and shell_writes("mkdir src"), + reading["uses"])) + silent_note = "\n".join(map_use_lines({"lazyref-2": {}}, + {"lazyref-2": never_wrote})) + checks.append(("with no trial that wrote, the note beside H7 withholds " + "the reading", + "says nothing about whether" in silent_note + and "on-demand reading" not in silent_note, + silent_note[-300:])) checks.append(("every trial's reads are listed with their turns", "| lazyref-1 | 4 | 1: core/quality.md, 2: core/quality.md, " "6: backend/http.md |" in detail, detail)) @@ -3287,7 +3333,14 @@ def line(kind, message_id, *blocks): results[key]["inline-none"]["verdict"] = "better" results[key]["hybrid-none"]["verdict"] = "better" results["task_success"]["reference-none"]["verdict"] = "worse" - partial_rows, missing = round6_screen(table, results) + + # Every declared contrast has a result whether its arms ran or not, so + # the planted results carry the absent arms' labels too. + for arm in ROUND5E_ARMS: + for key in SCREEN_ROWS: + results[key]["%s-none" % arm] = {"verdict": "not computed"} + held = {"%s-1" % arm: {} for arm in list(costs) + [BARE]} + partial_rows, missing = round6_screen(held, table, results) partial = {row["arm"]: (row["rank"], row["round6"], row["worse"]) for row in partial_rows} checks.append(("the screen ranks what it holds and names no arm for " @@ -3295,16 +3348,17 @@ def line(kind, message_id, *blocks): missing == list(ROUND5E_ARMS) and partial["hybrid"] == (1, False, []) and "names no arms for round 6 yet" in - "\n".join(screen_lines(table, results)) + "\n".join(screen_lines(held, table, results)) and "`lazyref` and `lazyskills` are not in this root" - in "\n".join(screen_lines(table, results)), + in "\n".join(screen_lines(held, table, results)), (partial, missing))) for arm in ROUND5E_ARMS: costs[arm] = 30.0 + held["%s-1" % arm] = {} table["cost_usd"]["values"][arm] = {1: 30.0, 2: 30.0} for key in SCREEN_ROWS: results[key]["%s-none" % arm] = {"verdict": "held"} - full_rows, missing = round6_screen(table, results) + full_rows, missing = round6_screen(held, table, results) screen = {row["arm"]: (row["rank"], row["round6"], row["worse"]) for row in full_rows} checks.append(("the screen drops an arm worse than none on a deciding " @@ -3321,7 +3375,7 @@ def line(kind, message_id, *blocks): "reference": (None, False, ["task_success"])}, screen)) - text = "\n".join(screen_lines(table, results)) + text = "\n".join(screen_lines(held, table, results)) checks.append(("the screen names the arms round 6 runs", "Round 6 runs `none` and `hybrid`, `inline`, `skills` and " "`hand`." in text From ea08f481cd242d0f5937d6bfb10f6269a53ac935 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:03:57 +0200 Subject: [PATCH 04/21] fix(efficacy): round 5e's reading after review round 3 Quoted text is no shell operator, so a command whose argument quotes an arrow or a verb writes nothing. A shell command reads a template only where a reading command names it; one that lists or tests the path does not. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 48 ++++++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index b0e862a..509737b 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 4216674..3363cc3 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2827,11 +2827,29 @@ def round5d_section(trials, table, results, seed, margins, NULL_REDIRECT = re.compile( r"\d?>{1,2}\s*(&\d|/dev/null|\$null|NUL\b)", re.IGNORECASE) +# Quoted text is an argument, not an operator or a command, so it is taken +# out before a command is read for a write. +QUOTED = re.compile(r"'[^']*'|\"[^\"]*\"") + +# The commands that put a file's contents in front of the agent. A path a +# shell command merely lists or tests is not read. +SHELL_READ = re.compile( + r"\b(?:cat|type|head|tail|sed|less|more|bat|grep|rg|awk|Get-Content|gc|" + r"Select-String)\b[^|;&\n]*?" + re.escape(VENDORED["into"] + "/") + + r"(templates/[\w./-]+\.md)", re.IGNORECASE) + def shell_writes(command): """Whether a shell command writes a file of the trial's own: it redirects into a file, or copies, moves or creates one.""" - return SHELL_WRITE.search(NULL_REDIRECT.sub(" ", command)) is not None + bare = QUOTED.sub(" ", NULL_REDIRECT.sub(" ", command)) + return SHELL_WRITE.search(bare) is not None + + +def shell_reads(command): + """The templates a shell command reads, in order: those a reading + command names under the vendored copy.""" + return SHELL_READ.findall(command) def mapped_templates(arm): @@ -2858,9 +2876,9 @@ def map_use(files, arm, templates=None): marker = VENDORED["into"] + "/" named = re.compile(re.escape(marker) + r"(templates/[\w./-]+\.md)") - def read_templates(text): - """The templates of the map a path or a command names, in order.""" - return [template for template in named.findall(text) + def mapped(templates): + """Those of the templates that are on the arm's map.""" + return [template for template in templates if not known or template in known] uses = [] first_write = None @@ -2897,8 +2915,8 @@ def read_templates(text): # A shell command may read a template and write a file # in one go, so it is read for both. if name in SHELLS and entry.get("vendor"): - uses.extend((turn, template) - for template in read_templates(command)) + uses.extend((turn, template) for template + in mapped(shell_reads(command))) if name in WRITES or (name in SHELLS and shell_writes(command)): if first_write is None: @@ -2906,7 +2924,8 @@ def read_templates(text): elif name == "Read" and entry.get("vendor"): path = str(given.get("file_path") or "") uses.extend((turn, template) for template in - read_templates(path.replace("\\", "/"))) + mapped(named.findall( + path.replace("\\", "/")))) elif name == "Skill" and entry.get("skills"): skill = str(given.get("skill") or "").strip() if skill in known: @@ -3290,6 +3309,21 @@ def line(kind, message_id, *blocks): and shell_writes("cat a >> b.txt") and shell_writes("mkdir src"), reading["uses"])) + quality = "%s/templates/core/quality.md" % into + checks.append(("quoted text is no shell operator, and a path a shell " + "command lists or tests is not read", + not shell_writes("git log --format='%h -> %s'") + and not shell_writes("echo 'mkdir src'") + and shell_writes("echo 'x' > 'my file.py'") + and shell_reads("ls %s" % quality) == [] + and shell_reads("test -f %s && echo yes" % quality) == [] + and shell_reads("cat %s" % quality) + == ["templates/core/quality.md"] + and shell_reads("sed -n 1,40p %s | head" % quality) + == ["templates/core/quality.md"] + and shell_reads("Get-Content %s" % quality) + == ["templates/core/quality.md"], + None)) silent_note = "\n".join(map_use_lines({"lazyref-2": {}}, {"lazyref-2": never_wrote})) checks.append(("with no trial that wrote, the note beside H7 withholds " From 12f46533e89d8a7ccc963bfebab81c1ffba3c6f2 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:13:05 +0200 Subject: [PATCH 05/21] fix(efficacy): round 5e's reading after review round 4 A shell command is read one simple command at a time, split at pipes, semicolons and the logical operators. Its command is the first word after any assignments, with the directory and `.exe` taken off, so a verb in an argument is no command; every template a reading command names counts. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 76 ++++++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 509737b..a6b34d6 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 3363cc3..5900a02 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2818,9 +2818,20 @@ def round5d_section(trials, table, results, seed, margins, # before any work. WRITES = ("Write", "Edit", "MultiEdit", "NotebookEdit") SHELLS = ("Bash", "PowerShell") -SHELL_WRITE = re.compile( - r"(>|\btee\b|\btouch\b|\bmkdir\b|\bcp\b|\bmv\b" - r"|New-Item|Set-Content|Add-Content|Out-File|Copy-Item|Move-Item)") + +# A shell command is read one simple command at a time: the text between +# pipes, semicolons, `&&`, `||` and line breaks. The command is its first +# word, after any variable assignments and with any directory and `.exe` +# taken off, so a word that is an argument never counts as a command. +SEGMENT = re.compile(r"\|\||&&|[|;\n]") +ASSIGNMENT = re.compile(r"^[A-Za-z_]\w*=") +WRITE_COMMANDS = ("tee", "touch", "mkdir", "cp", "mv", "new-item", + "set-content", "add-content", "out-file", "copy-item", + "move-item") +READ_COMMANDS = ("cat", "type", "head", "tail", "sed", "less", "more", "bat", + "grep", "rg", "awk", "get-content", "gc", "select-string") +TEMPLATE_PATH = re.compile(re.escape(VENDORED["into"] + "/") + + r"(templates/[\w./-]+\.md)") # A redirection that writes no file: to the null device, or of one stream # into another. Taken out of a command before it is read for a write. @@ -2831,25 +2842,41 @@ def round5d_section(trials, table, results, seed, margins, # out before a command is read for a write. QUOTED = re.compile(r"'[^']*'|\"[^\"]*\"") -# The commands that put a file's contents in front of the agent. A path a -# shell command merely lists or tests is not read. -SHELL_READ = re.compile( - r"\b(?:cat|type|head|tail|sed|less|more|bat|grep|rg|awk|Get-Content|gc|" - r"Select-String)\b[^|;&\n]*?" + re.escape(VENDORED["into"] + "/") - + r"(templates/[\w./-]+\.md)", re.IGNORECASE) + +def simple_commands(command, keep_quotes=False): + """A shell command's simple commands, each as (command word, text), the + null redirections taken out and, unless asked to keep them, the quoted + arguments too.""" + bare = NULL_REDIRECT.sub(" ", command) + if not keep_quotes: + bare = QUOTED.sub(" ", bare) + found = [] + for segment in SEGMENT.split(bare): + words = [word for word in segment.split() + if not ASSIGNMENT.match(word)] + if not words: + continue + word = words[0].replace("\\", "/").rsplit("/", 1)[-1].lower() + if word.endswith(".exe"): + word = word[:-len(".exe")] + found.append((word, segment)) + return found def shell_writes(command): - """Whether a shell command writes a file of the trial's own: it - redirects into a file, or copies, moves or creates one.""" - bare = QUOTED.sub(" ", NULL_REDIRECT.sub(" ", command)) - return SHELL_WRITE.search(bare) is not None + """Whether a shell command writes a file of the trial's own: a simple + command that redirects into a file, or copies, moves or creates one.""" + return any(word in WRITE_COMMANDS or ">" in text + for word, text in simple_commands(command)) def shell_reads(command): - """The templates a shell command reads, in order: those a reading + """The templates a shell command reads, in order: every one a reading command names under the vendored copy.""" - return SHELL_READ.findall(command) + return [template + for word, text in simple_commands(command, keep_quotes=True) + if word in READ_COMMANDS + for template in TEMPLATE_PATH.findall(text)] def mapped_templates(arm): @@ -3324,6 +3351,25 @@ def line(kind, message_id, *blocks): and shell_reads("Get-Content %s" % quality) == ["templates/core/quality.md"], None)) + http = "%s/templates/backend/http.md" % into + checks.append(("a shell command is read one simple command at a time: " + "every operand of a reading command counts, and a verb " + "in an argument is no command", + shell_reads("cat %s %s" % (quality, http)) + == ["templates/core/quality.md", + "templates/backend/http.md"] + and shell_reads("cat '%s' | head" % quality) + == ["templates/core/quality.md"] + and shell_reads("ls %s && cat %s" % (quality, http)) + == ["templates/backend/http.md"] + and not shell_writes("rg -n mkdir src") + and not shell_writes("echo mkdir src") + and shell_writes("/usr/bin/cp a b") + and shell_writes("FOO=1 mkdir x") + and shell_writes("pytest -q | tee log.txt") + and shell_writes("C:\\Windows\\System32\\xcopy.exe a b" + " > out.txt"), + None)) silent_note = "\n".join(map_use_lines({"lazyref-2": {}}, {"lazyref-2": never_wrote})) checks.append(("with no trial that wrote, the note beside H7 withholds " From 0b8fe53a4035a0f778079cf902d55b81cb312680 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:27:20 +0200 Subject: [PATCH 06/21] fix(efficacy): round 5e's reading after review round 5 A subagent's transcript is read with the session's, its calls charged to the turn that delegated to it, and the aggregate and the per-trial table say how many uses a subagent made. A wildcard operand of a reading command stands for every template of the map it matches. A map no trial read is said to be ignored, not read on demand. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- docs/rounds/round-5e.md | 19 +-- tests/efficacy/report.py | 242 ++++++++++++++++++++++++++++----------- 3 files changed, 189 insertions(+), 74 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index a6b34d6..52ca8de 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/docs/rounds/round-5e.md b/docs/rounds/round-5e.md index 3234c3b..ba26834 100644 --- a/docs/rounds/round-5e.md +++ b/docs/rounds/round-5e.md @@ -146,14 +146,17 @@ round-6 screen of 13d.9, which round 5e's arms join as candidates. alone; - cost, turns, tokens and wall time, and the words each arm puts in context on every turn; -- **use of the map**, per trial, from the transcript: how many templates of the - map the agent read (`lazyref`, a read of a file of the chain under the - vendored path, by the read tool or a shell command) or loaded (`lazyskills`, a - skill call naming one of the arm's skills), which ones, the turn each happened - at, and how many happened before the trial's first write to a file of its own: - a write tool's call, or a shell command that redirects into a file, copies, - moves or creates. A trial that never wrote says nothing about reading up - front, and the note beside H7 says so where no trial wrote. +- **use of the map**, per trial, from the transcript, a subagent's included and + charged to the turn that delegated to it: how many templates of the map the + agent read (`lazyref`, a read of a file of the chain under the vendored path, + by the read tool or a shell command that reads, a wildcard standing for every + template it matches) or loaded (`lazyskills`, a skill call naming one of the + arm's skills), which ones, the turn each happened at, and how many happened + before the trial's first write to a file of its own: a write tool's call, or a + shell command that redirects into a file, copies, moves or creates. A trial + that never wrote says nothing about reading up front, a map no trial read was + ignored rather than read on demand, and the note beside H7 says which case + holds. ### 13e.5 Before the first trial diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 5900a02..e11ae9a 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -16,6 +16,7 @@ import argparse import datetime +import fnmatch import glob import io import json @@ -2833,6 +2834,11 @@ def round5d_section(trials, table, results, seed, margins, TEMPLATE_PATH = re.compile(re.escape(VENDORED["into"] + "/") + r"(templates/[\w./-]+\.md)") +# A shell operand under the vendored copy that may carry a wildcard, which +# is resolved against the map's templates rather than read as no file. +TEMPLATE_OPERAND = re.compile(re.escape(VENDORED["into"] + "/") + + r"(templates/[\w./*?\[\]-]+)") + # A redirection that writes no file: to the null device, or of one stream # into another. Taken out of a command before it is read for a write. NULL_REDIRECT = re.compile( @@ -2870,13 +2876,21 @@ def shell_writes(command): for word, text in simple_commands(command)) -def shell_reads(command): +def shell_reads(command, known=()): """The templates a shell command reads, in order: every one a reading - command names under the vendored copy.""" - return [template - for word, text in simple_commands(command, keep_quotes=True) - if word in READ_COMMANDS - for template in TEMPLATE_PATH.findall(text)] + command names under the vendored copy, a wildcard operand standing for + each template of the map it matches.""" + found = [] + for word, text in simple_commands(command, keep_quotes=True): + if word not in READ_COMMANDS: + continue + for operand in TEMPLATE_OPERAND.findall(text): + if any(mark in operand for mark in "*?["): + found.extend(template for template in known + if fnmatch.fnmatchcase(template, operand)) + elif operand.endswith(".md"): + found.append(operand) + return found def mapped_templates(arm): @@ -2893,22 +2907,17 @@ def mapped_templates(arm): return [] -def map_use(files, arm, templates=None): - """How one trial used what its file points at, from its transcripts: - each template read from the vendored copy or loaded as a skill, as - (turn, template) in order, and the turn of the trial's first write to a - file of its own, or None.""" - entry = ARMS.get(arm) or {} - known = set(mapped_templates(arm) if templates is None else templates) - marker = VENDORED["into"] + "/" - named = re.compile(re.escape(marker) + r"(templates/[\w./-]+\.md)") +# The tools that hand work to a subagent, whose transcript sits beside the +# session's. What the subagent read or wrote is charged to the turn that +# delegated it. +DELEGATIONS = ("Agent", "Task") - def mapped(templates): - """Those of the templates that are on the arm's map.""" - return [template for template in templates - if not known or template in known] - uses = [] - first_write = None + +def tool_calls_by_turn(files): + """Every tool call in the transcripts as (turn, tool, input), a turn + being one message of the model: several lines may share a message id, + so a new id is what counts a turn.""" + calls = [] turn = 0 last_message = object() for file in files: @@ -2922,42 +2931,71 @@ def mapped(templates): or record.get("type") != "assistant": continue message = record.get("message") or {} - - # One turn of the model may be written as several lines that - # share a message id, so a new id is what counts a turn. if message.get("id") != last_message: last_message = message.get("id") turn += 1 content = message.get("content") for block in content if isinstance(content, list) else []: - if not isinstance(block, dict) \ - or block.get("type") != "tool_use": - continue - given = block.get("input") - given = given if isinstance(given, dict) else {} - name = block.get("name") - command = str(given.get("command") or "") - command = command.replace("\\", "/") - - # A shell command may read a template and write a file - # in one go, so it is read for both. - if name in SHELLS and entry.get("vendor"): - uses.extend((turn, template) for template - in mapped(shell_reads(command))) - if name in WRITES or (name in SHELLS - and shell_writes(command)): - if first_write is None: - first_write = turn - elif name == "Read" and entry.get("vendor"): - path = str(given.get("file_path") or "") - uses.extend((turn, template) for template in - mapped(named.findall( - path.replace("\\", "/")))) - elif name == "Skill" and entry.get("skills"): - skill = str(given.get("skill") or "").strip() - if skill in known: - uses.append((turn, skill)) - return {"uses": uses, "first_write": first_write} + if isinstance(block, dict) \ + and block.get("type") == "tool_use": + given = block.get("input") + calls.append((turn, block.get("name"), + given if isinstance(given, dict) + else {})) + return calls + + +def map_use(files, arm, templates=None, delegated=()): + """How one trial used what its file points at, from its transcripts: + each template read from the vendored copy or loaded as a skill, as + (turn, template) in order, the turn of the trial's first write to a + file of its own, or None, and how many of the uses a subagent made. + + A subagent's transcript, in `delegated`, is read after the session's, + its calls charged to the turn the session first delegated at. + """ + entry = ARMS.get(arm) or {} + known = set(mapped_templates(arm) if templates is None else templates) + marker = VENDORED["into"] + "/" + named = re.compile(re.escape(marker) + r"(templates/[\w./-]+\.md)") + + def mapped(templates): + """Those of the templates that are on the arm's map.""" + return [template for template in templates + if not known or template in known] + own = [(turn, name, given, False) + for turn, name, given in tool_calls_by_turn(files)] + delegation = next((turn for turn, name, _, _ in own + if name in DELEGATIONS), None) + calls = own + [(delegation if delegation is not None else turn, + name, given, True) + for turn, name, given in tool_calls_by_turn(delegated)] + calls.sort(key=lambda call: call[0]) + uses = [] + first_write = None + by_subagent = 0 + for turn, name, given, from_subagent in calls: + command = str(given.get("command") or "").replace("\\", "/") + found = [] + + # A shell command may read a template and write a file in one go, + # so it is read for both. + if name in SHELLS and entry.get("vendor"): + found = mapped(shell_reads(command, sorted(known))) + if name in WRITES or (name in SHELLS and shell_writes(command)): + if first_write is None: + first_write = turn + elif name == "Read" and entry.get("vendor"): + path = str(given.get("file_path") or "").replace("\\", "/") + found = mapped(named.findall(path)) + elif name == "Skill" and entry.get("skills"): + skill = str(given.get("skill") or "").strip() + found = [skill] if skill in known else [] + uses.extend((turn, template) for template in found) + if from_subagent: + by_subagent += len(found) + return {"uses": uses, "first_write": first_write, + "by_subagent": by_subagent} def map_uses(root, trials): @@ -2975,13 +3013,30 @@ def map_uses(root, trials): templates = mapped_templates(arm) if not templates: continue - files = transcript_files(home, record.get("workspace") or "", - started(record)) + workspace = record.get("workspace") or "" + files = transcript_files(home, workspace, started(record)) if files: - uses[name] = map_use(files, arm, templates) + uses[name] = map_use(files, arm, templates, + subagent_files(home, workspace, + started(record))) return uses +def subagent_files(home, workspace, since=None): + """The transcripts of the subagents a session in `workspace` started, + filed under the session's folder, left out where written before + `since`.""" + folder = os.path.dirname(transcript_files(home, workspace)[0]) \ + if transcript_files(home, workspace) else None + if not folder: + return [] + files = sorted(glob.glob(os.path.join(folder, "*", "subagents", + "*.jsonl"))) + if since is None: + return files + return [file for file in files if os.path.getmtime(file) >= since] + + def mean_of(values): """The mean of the values, or None of none.""" return statistics.fmean(values) if values else None @@ -3018,6 +3073,7 @@ def map_use_rows(trials, uses): rows.append({"arm": arm, "trials": len(names), "total": total, "read": mean_of(counts), "before": mean_of(before), "wrote": len(before), "first": median_of(firsts), + "unused": sum(1 for count in counts if not count), "up_front": sum(1 for count in before if total and count >= total)}) return rows @@ -3027,8 +3083,11 @@ def map_use_detail(trials, uses): """Every trial's map use, one row each: the turn of its first write and each template with the turn it was read or loaded at.""" lines = ["#### Per trial", "", - "| Trial | First write at turn | Templates, by turn |", - "| --- | --- | --- |"] + "A subagent's reads are charged to the turn that delegated " + "to it.", "", + "| Trial | First write at turn | By a subagent " + "| Templates, by turn |", + "| --- | --- | --- | --- |"] for name in ordered(trials): if name not in uses: continue @@ -3037,9 +3096,9 @@ def map_use_detail(trials, uses): if template.startswith("templates/") else template) for turn, template in use["uses"]) or "none" - lines.append("| %s | %s | %s |" % ( + lines.append("| %s | %s | %d | %s |" % ( name, "—" if use["first_write"] is None else use["first_write"], - reads)) + use.get("by_subagent", 0), reads)) return lines @@ -3072,6 +3131,10 @@ def shown(value, places=1): "be placed, so the map's use says nothing about " "whether the templates were read up front or on " "demand.") + elif row["unused"] == row["trials"]: + lines.append("Beside H7: no `lazyref` trial read a template of " + "its map, so H7 compares a map ignored against " + "templates read up front, not on-demand reading.") elif row["up_front"]: lines.append("Beside H7: `lazyref` read every template of its map " "before its first write in %d of the %d trials that " @@ -3080,7 +3143,10 @@ def shown(value, places=1): else: lines.append("Beside H7: no `lazyref` trial read every template " "of its map before its first write, so H7 reads " - "on-demand reading.") + "on-demand reading%s." % ( + ", and %d of %d trials read none" + % (row["unused"], row["trials"]) + if row["unused"] else "")) lines.append("") lines.extend(map_use_detail(trials, uses)) return lines @@ -3310,10 +3376,10 @@ def line(kind, message_id, *blocks): reading == {"uses": [(1, "templates/core/quality.md"), (2, "templates/core/quality.md"), (6, "templates/backend/http.md")], - "first_write": 4} + "first_write": 4, "by_subagent": 0} and loading == {"uses": [(1, "base-quality"), (3, "backend-api")], - "first_write": 3} + "first_write": 3, "by_subagent": 0} and never_wrote["first_write"] is None and summary == [("lazyref", 2.0, 1.0, 1, 1.0, 0), ("lazyskills", 2.0, 1.0, 1, 1.0, 0)], @@ -3378,13 +3444,58 @@ def line(kind, message_id, *blocks): and "on-demand reading" not in silent_note, silent_note[-300:])) checks.append(("every trial's reads are listed with their turns", - "| lazyref-1 | 4 | 1: core/quality.md, 2: core/quality.md, " - "6: backend/http.md |" in detail, detail)) + "| lazyref-1 | 4 | 0 | 1: core/quality.md, " + "2: core/quality.md, 6: backend/http.md |" in detail, + detail)) + + # A subagent read all of the map at the parent's turn 2, before the + # parent's first write at turn 3; a wildcard stands for every template + # of the map it matches; a map read by nobody is said to be ignored. + scratch = os.path.join(tempfile.gettempdir(), + "efficacy-report-map-use-self-test") + os.makedirs(scratch) + parent = os.path.join(scratch, "parent.jsonl") + with io.open(parent, "w", encoding="utf-8", newline="\n") as handle: + handle.write(line("assistant", "p1", call("Bash", command="ls"))) + handle.write(line("assistant", "p2", call( + "Agent", prompt="read the templates"))) + handle.write(line("assistant", "p3", call("Write", file_path="a.py"))) + child = os.path.join(scratch, "agent.jsonl") + with io.open(child, "w", encoding="utf-8", newline="\n") as handle: + handle.write(line("assistant", "c1", call( + "Bash", command="cat %s/templates/core/*.md" % into))) + handle.write(line("assistant", "c2", call( + "Read", file_path="/pen/%s/templates/backend/http.md" % into))) + chain = ["templates/core/quality.md", "templates/core/git.md", + "templates/backend/http.md"] + with_subagent = map_use([parent], "lazyref", chain, [child]) + delegated_rows = map_use_rows({"lazyref-1": {}}, + {"lazyref-1": with_subagent}) + shutil.rmtree(scratch, ignore_errors=True) + checks.append(("a subagent's reads count at the turn that delegated, and " + "a wildcard stands for every template of the map it " + "matches", + with_subagent == { + "uses": [(2, "templates/core/git.md"), + (2, "templates/core/quality.md"), + (2, "templates/backend/http.md")], + "first_write": 3, "by_subagent": 3} + and delegated_rows[0]["before"] == 3.0 + and shell_reads("cat %s/templates/core/q*.md" % into, + chain) == ["templates/core/quality.md"], + with_subagent)) + ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { + "uses": [], "first_write": 2, "by_subagent": 0}}) + checks.append(("a map no trial read is said to be ignored, not read on " + "demand", + "compares a map ignored" in "\n".join(ignored) + and "so H7 reads on-demand" not in "\n".join(ignored), + ignored[-6:])) planted_uses = {"lazyref-1": reading} kept = aggregate(1, {}, {}, {}, {}, None, None, planted_uses)["map_use"] checks.append(("the aggregate keeps each trial's map use", kept == {"lazyref-1": { - "first_write": 4, + "first_write": 4, "by_subagent": 0, "uses": [{"turn": 1, "template": "templates/core/quality.md"}, {"turn": 2, @@ -5095,6 +5206,7 @@ def aggregate(seed, trials, table, results, withdrawn, check, iso, if uses is not None: payload["map_use"] = { name: {"first_write": use["first_write"], + "by_subagent": use.get("by_subagent", 0), "uses": [{"turn": turn, "template": template} for turn, template in use["uses"]]} for name, use in sorted(uses.items())} From cdfe56afee3cbdc37e044c465edf6daf620dae76 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:36:30 +0200 Subject: [PATCH 07/21] fix(efficacy): round 5e's reading after review round 6 Each subagent's calls are charged to the turn of the session's line its transcript points back to, the moment it was started, so a second delegation after the first write stays after it. A separator inside a quoted shell argument splits no command. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 108 +++++++++++++++++++++++++++++++++------ 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 52ca8de..7ad3873 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index e11ae9a..adbddbe 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2852,12 +2852,17 @@ def round5d_section(trials, table, results, seed, margins, def simple_commands(command, keep_quotes=False): """A shell command's simple commands, each as (command word, text), the null redirections taken out and, unless asked to keep them, the quoted - arguments too.""" - bare = NULL_REDIRECT.sub(" ", command) - if not keep_quotes: - bare = QUOTED.sub(" ", bare) + arguments too. A separator inside quotes separates nothing.""" + quoted = [] + + def stash(match): + quoted.append(match.group(0)) + return "\x00%d\x00" % (len(quoted) - 1) + masked = QUOTED.sub(stash, NULL_REDIRECT.sub(" ", command)) found = [] - for segment in SEGMENT.split(bare): + for segment in SEGMENT.split(masked): + segment = re.sub(r"\x00(\d+)\x00", lambda match: ( + quoted[int(match.group(1))] if keep_quotes else " "), segment) words = [word for word in segment.split() if not ASSIGNMENT.match(word)] if not words: @@ -2913,10 +2918,11 @@ def mapped_templates(arm): DELEGATIONS = ("Agent", "Task") -def tool_calls_by_turn(files): +def tool_calls_by_turn(files, written_at=None): """Every tool call in the transcripts as (turn, tool, input), a turn being one message of the model: several lines may share a message id, - so a new id is what counts a turn.""" + so a new id is what counts a turn. Given a dict as `written_at`, each + line's uuid is filed under the turn current once it was written.""" calls = [] turn = 0 last_message = object() @@ -2927,13 +2933,17 @@ def tool_calls_by_turn(files): record = json.loads(line) except ValueError: continue - if not isinstance(record, dict) \ - or record.get("type") != "assistant": + if not isinstance(record, dict): continue message = record.get("message") or {} - if message.get("id") != last_message: + if record.get("type") == "assistant" \ + and message.get("id") != last_message: last_message = message.get("id") turn += 1 + if written_at is not None and record.get("uuid"): + written_at[record["uuid"]] = turn + if record.get("type") != "assistant": + continue content = message.get("content") for block in content if isinstance(content, list) else []: if isinstance(block, dict) \ @@ -2945,6 +2955,26 @@ def tool_calls_by_turn(files): return calls +def delegation_turn(file, written_at, fallback): + """The session's turn a subagent's transcript was started at: the turn + of the session's line its first record points back to, or `fallback` + where it points at none the session wrote.""" + with io.open(file, encoding="utf-8", errors="replace") as handle: + for line in handle: + try: + record = json.loads(line) + except ValueError: + continue + if not isinstance(record, dict): + continue + parent = record.get("parentLastUuid") or record.get("parentUuid") + if parent in written_at: + return written_at[parent] + if record.get("type") == "assistant": + break + return fallback + + def map_use(files, arm, templates=None, delegated=()): """How one trial used what its file points at, from its transcripts: each template read from the vendored copy or loaded as a skill, as @@ -2952,7 +2982,9 @@ def map_use(files, arm, templates=None, delegated=()): file of its own, or None, and how many of the uses a subagent made. A subagent's transcript, in `delegated`, is read after the session's, - its calls charged to the turn the session first delegated at. + its calls charged to the turn of the session's line it points back to, + the moment it was started; one pointing nowhere the session wrote is + charged to the session's first delegation. """ entry = ARMS.get(arm) or {} known = set(mapped_templates(arm) if templates is None else templates) @@ -2963,13 +2995,16 @@ def mapped(templates): """Those of the templates that are on the arm's map.""" return [template for template in templates if not known or template in known] + written_at = {} own = [(turn, name, given, False) - for turn, name, given in tool_calls_by_turn(files)] - delegation = next((turn for turn, name, _, _ in own - if name in DELEGATIONS), None) - calls = own + [(delegation if delegation is not None else turn, - name, given, True) - for turn, name, given in tool_calls_by_turn(delegated)] + for turn, name, given in tool_calls_by_turn(files, written_at)] + first_delegation = next((turn for turn, name, _, _ in own + if name in DELEGATIONS), None) + calls = list(own) + for file in delegated: + at = delegation_turn(file, written_at, first_delegation) + calls.extend((at if at is not None else turn, name, given, True) + for turn, name, given in tool_calls_by_turn([file])) calls.sort(key=lambda call: call[0]) uses = [] first_write = None @@ -3484,6 +3519,45 @@ def line(kind, message_id, *blocks): and shell_reads("cat %s/templates/core/q*.md" % into, chain) == ["templates/core/quality.md"], with_subagent)) + # Two delegations: each subagent is charged to the line it points back + # to, so the second one's read at turn 3 falls after the write at turn + # 2, and a quoted separator splits no command. + os.makedirs(scratch) + + def stamped(kind, message_id, uuid, *blocks): + record = json.loads(line(kind, message_id, *blocks)) + record["uuid"] = uuid + return json.dumps(record) + "\n" + parent = os.path.join(scratch, "parent.jsonl") + with io.open(parent, "w", encoding="utf-8", newline="\n") as handle: + handle.write(stamped("assistant", "p1", "u1", call( + "Agent", prompt="read quality"))) + handle.write(stamped("assistant", "p2", "u2", call( + "Write", file_path="a.py"))) + handle.write(stamped("assistant", "p3", "u3", call( + "Agent", prompt="read http"))) + children = [] + for index, (uuid, template) in enumerate( + (("u1", "core/quality.md"), ("u3", "backend/http.md"))): + child = os.path.join(scratch, "agent-%d.jsonl" % index) + with io.open(child, "w", encoding="utf-8", newline="\n") as handle: + handle.write(json.dumps({"type": "fork-context-ref", + "parentLastUuid": uuid}) + "\n") + handle.write(line("assistant", "c%d" % index, call( + "Read", file_path="/pen/%s/templates/%s" % (into, template)))) + children.append(child) + twice = map_use([parent], "lazyref", chain, children) + shutil.rmtree(scratch, ignore_errors=True) + checks.append(("each subagent is charged to the turn that started it, " + "and a separator inside quotes splits no command", + twice == {"uses": [(1, "templates/core/quality.md"), + (3, "templates/backend/http.md")], + "first_write": 2, "by_subagent": 2} + and shell_reads('echo "x; cat %s"' % quality, chain) == [] + and shell_reads('cat "%s"; ls' % quality, chain) + == ["templates/core/quality.md"] + and not shell_writes('echo "a > b"'), + twice)) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { "uses": [], "first_write": 2, "by_subagent": 0}}) checks.append(("a map no trial read is said to be ignored, not read on " From 62bac5ad41e31b543f97e7e1db166438679e40fd Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:49:58 +0200 Subject: [PATCH 08/21] fix(efficacy): round 5e's reading after review round 7 A read in a simple command before the writing one of the same shell call came before the write, so a trial's templates read before its first write are kept by name and no longer compared by turn alone. A here-document's body is data, taken out before a command is read. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 129 ++++++++++++++++++++++++++++----------- 2 files changed, 94 insertions(+), 37 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 7ad3873..974fd41 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index adbddbe..855f814 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2849,16 +2849,23 @@ def round5d_section(trials, table, results, seed, margins, QUOTED = re.compile(r"'[^']*'|\"[^\"]*\"") +# A here-document's body is data, not commands, and is taken out whole. +HEREDOC = re.compile(r"<<-?\s*(['\"]?)(\w+)\1[^\n]*\n.*?\n\s*\2\s*(?=\n|$)", + re.DOTALL) + + def simple_commands(command, keep_quotes=False): """A shell command's simple commands, each as (command word, text), the - null redirections taken out and, unless asked to keep them, the quoted - arguments too. A separator inside quotes separates nothing.""" + null redirections and here-document bodies taken out and, unless asked + to keep them, the quoted arguments too. A separator inside quotes + separates nothing.""" quoted = [] def stash(match): quoted.append(match.group(0)) return "\x00%d\x00" % (len(quoted) - 1) - masked = QUOTED.sub(stash, NULL_REDIRECT.sub(" ", command)) + masked = QUOTED.sub(stash, NULL_REDIRECT.sub(" ", HEREDOC.sub( + " ", command))) found = [] for segment in SEGMENT.split(masked): segment = re.sub(r"\x00(\d+)\x00", lambda match: ( @@ -2874,27 +2881,37 @@ def stash(match): return found +def first_writing_command(command): + """The index of the first simple command that writes a file of the + trial's own, one that redirects into a file or copies, moves or creates + one; None where none does.""" + for index, (word, text) in enumerate(simple_commands(command)): + if word in WRITE_COMMANDS or ">" in text: + return index + return None + + def shell_writes(command): - """Whether a shell command writes a file of the trial's own: a simple - command that redirects into a file, or copies, moves or creates one.""" - return any(word in WRITE_COMMANDS or ">" in text - for word, text in simple_commands(command)) + """Whether a shell command writes a file of the trial's own.""" + return first_writing_command(command) is not None def shell_reads(command, known=()): - """The templates a shell command reads, in order: every one a reading - command names under the vendored copy, a wildcard operand standing for - each template of the map it matches.""" + """The templates a shell command reads, as (index of its simple + command, template) in order: every one a reading command names under + the vendored copy, a wildcard operand standing for each template of the + map it matches.""" found = [] - for word, text in simple_commands(command, keep_quotes=True): + for index, (word, text) in enumerate( + simple_commands(command, keep_quotes=True)): if word not in READ_COMMANDS: continue for operand in TEMPLATE_OPERAND.findall(text): if any(mark in operand for mark in "*?["): - found.extend(template for template in known + found.extend((index, template) for template in known if fnmatch.fnmatchcase(template, operand)) elif operand.endswith(".md"): - found.append(operand) + found.append((index, operand)) return found @@ -3007,30 +3024,41 @@ def mapped(templates): for turn, name, given in tool_calls_by_turn([file])) calls.sort(key=lambda call: call[0]) uses = [] + before = set() first_write = None by_subagent = 0 for turn, name, given, from_subagent in calls: command = str(given.get("command") or "").replace("\\", "/") found = [] + writes_at = None # A shell command may read a template and write a file in one go, - # so it is read for both. + # so it is read for both, and a read in a simple command before the + # writing one came before the write. if name in SHELLS and entry.get("vendor"): - found = mapped(shell_reads(command, sorted(known))) - if name in WRITES or (name in SHELLS and shell_writes(command)): - if first_write is None: - first_write = turn + writes_at = first_writing_command(command) + for index, template in shell_reads(command, sorted(known)): + if template in known or not known: + found.append(template) + if first_write is None and (writes_at is None + or index < writes_at): + before.add(template) elif name == "Read" and entry.get("vendor"): path = str(given.get("file_path") or "").replace("\\", "/") found = mapped(named.findall(path)) elif name == "Skill" and entry.get("skills"): skill = str(given.get("skill") or "").strip() found = [skill] if skill in known else [] + if name not in SHELLS and first_write is None: + before.update(found) + if first_write is None and (name in WRITES or writes_at is not None): + first_write = turn uses.extend((turn, template) for template in found) if from_subagent: by_subagent += len(found) return {"uses": uses, "first_write": first_write, - "by_subagent": by_subagent} + "before_write": sorted(before) if first_write is not None + else None, "by_subagent": by_subagent} def map_uses(root, trials): @@ -3101,8 +3129,7 @@ def map_use_rows(trials, uses): # A trial that never wrote has no "before", and says nothing # about reading up front. if use["first_write"] is not None: - before.append(len({template for turn, template in use["uses"] - if turn < use["first_write"]})) + before.append(len(use.get("before_write") or ())) if use["uses"]: firsts.append(use["uses"][0][0]) rows.append({"arm": arm, "trials": len(names), "total": total, @@ -3347,6 +3374,9 @@ def results_for(label, **overrides): got == ["supported", "supported", "refuted", "refuted", "inconclusive"], got)) + def read_names(command, known=()): + """The templates a shell command reads, by name alone.""" + return [template for _, template in shell_reads(command, known)] scratch = os.path.join(tempfile.gettempdir(), "efficacy-report-map-use-self-test") shutil.rmtree(scratch, ignore_errors=True) @@ -3411,10 +3441,12 @@ def line(kind, message_id, *blocks): reading == {"uses": [(1, "templates/core/quality.md"), (2, "templates/core/quality.md"), (6, "templates/backend/http.md")], - "first_write": 4, "by_subagent": 0} + "first_write": 4, "by_subagent": 0, + "before_write": ["templates/core/quality.md"]} and loading == {"uses": [(1, "base-quality"), (3, "backend-api")], - "first_write": 3, "by_subagent": 0} + "first_write": 3, "by_subagent": 0, + "before_write": ["base-quality"]} and never_wrote["first_write"] is None and summary == [("lazyref", 2.0, 1.0, 1, 1.0, 0), ("lazyskills", 2.0, 1.0, 1, 1.0, 0)], @@ -3443,25 +3475,25 @@ def line(kind, message_id, *blocks): not shell_writes("git log --format='%h -> %s'") and not shell_writes("echo 'mkdir src'") and shell_writes("echo 'x' > 'my file.py'") - and shell_reads("ls %s" % quality) == [] - and shell_reads("test -f %s && echo yes" % quality) == [] - and shell_reads("cat %s" % quality) + and read_names("ls %s" % quality) == [] + and read_names("test -f %s && echo yes" % quality) == [] + and read_names("cat %s" % quality) == ["templates/core/quality.md"] - and shell_reads("sed -n 1,40p %s | head" % quality) + and read_names("sed -n 1,40p %s | head" % quality) == ["templates/core/quality.md"] - and shell_reads("Get-Content %s" % quality) + and read_names("Get-Content %s" % quality) == ["templates/core/quality.md"], None)) http = "%s/templates/backend/http.md" % into checks.append(("a shell command is read one simple command at a time: " "every operand of a reading command counts, and a verb " "in an argument is no command", - shell_reads("cat %s %s" % (quality, http)) + read_names("cat %s %s" % (quality, http)) == ["templates/core/quality.md", "templates/backend/http.md"] - and shell_reads("cat '%s' | head" % quality) + and read_names("cat '%s' | head" % quality) == ["templates/core/quality.md"] - and shell_reads("ls %s && cat %s" % (quality, http)) + and read_names("ls %s && cat %s" % (quality, http)) == ["templates/backend/http.md"] and not shell_writes("rg -n mkdir src") and not shell_writes("echo mkdir src") @@ -3514,9 +3546,12 @@ def line(kind, message_id, *blocks): "uses": [(2, "templates/core/git.md"), (2, "templates/core/quality.md"), (2, "templates/backend/http.md")], - "first_write": 3, "by_subagent": 3} + "first_write": 3, "by_subagent": 3, + "before_write": ["templates/backend/http.md", + "templates/core/git.md", + "templates/core/quality.md"]} and delegated_rows[0]["before"] == 3.0 - and shell_reads("cat %s/templates/core/q*.md" % into, + and read_names("cat %s/templates/core/q*.md" % into, chain) == ["templates/core/quality.md"], with_subagent)) # Two delegations: each subagent is charged to the line it points back @@ -3552,12 +3587,32 @@ def stamped(kind, message_id, uuid, *blocks): "and a separator inside quotes splits no command", twice == {"uses": [(1, "templates/core/quality.md"), (3, "templates/backend/http.md")], - "first_write": 2, "by_subagent": 2} - and shell_reads('echo "x; cat %s"' % quality, chain) == [] - and shell_reads('cat "%s"; ls' % quality, chain) + "first_write": 2, "by_subagent": 2, + "before_write": ["templates/core/quality.md"]} + and read_names('echo "x; cat %s"' % quality, chain) == [] + and read_names('cat "%s"; ls' % quality, chain) == ["templates/core/quality.md"] and not shell_writes('echo "a > b"'), twice)) + one_go = os.path.join(scratch, "one-go.jsonl") + os.makedirs(scratch) + heredoc = "python - <<'PY'\nprint(2 > 1)\nPY" + with io.open(one_go, "w", encoding="utf-8", newline="\n") as handle: + handle.write(line("assistant", "g1", call("Bash", command=heredoc))) + handle.write(line("assistant", "g2", call( + "Bash", command="cat %s/%s %s/%s && mkdir -p src && cat %s/%s" + % (into, chain[0], into, chain[1], into, chain[2])))) + in_one_go = map_use([one_go], "lazyref", chain) + shutil.rmtree(scratch, ignore_errors=True) + checks.append(("a read before the writing command of one shell call " + "comes before the write, and a here-document body is " + "no command", + in_one_go["first_write"] == 2 + and in_one_go["before_write"] == sorted(chain[:2]) + and len(in_one_go["uses"]) == 3 + and not shell_writes(heredoc) + and shell_writes("cat a <<'EOF'\nx\nEOF\necho y > z"), + in_one_go)) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { "uses": [], "first_write": 2, "by_subagent": 0}}) checks.append(("a map no trial read is said to be ignored, not read on " @@ -3570,6 +3625,7 @@ def stamped(kind, message_id, uuid, *blocks): checks.append(("the aggregate keeps each trial's map use", kept == {"lazyref-1": { "first_write": 4, "by_subagent": 0, + "before_write": ["templates/core/quality.md"], "uses": [{"turn": 1, "template": "templates/core/quality.md"}, {"turn": 2, @@ -5280,6 +5336,7 @@ def aggregate(seed, trials, table, results, withdrawn, check, iso, if uses is not None: payload["map_use"] = { name: {"first_write": use["first_write"], + "before_write": use.get("before_write"), "by_subagent": use.get("by_subagent", 0), "uses": [{"turn": turn, "template": template} for turn, template in use["uses"]]} From aef0fd730bafcd6da37eb4af8b6709860ada9b1c Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:59:54 +0200 Subject: [PATCH 09/21] fix(efficacy): round 5e's reading after review round 8 A shell write counts for every arm, a skills arm's included. A here-document's body goes and the rest of its opening line stays, so a redirection after the delimiter is a write. A subagent that points at the line before the delegating message is charged to that message. A search's or a script's first operand is what to look for, not a file it reads. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 71 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 974fd41..4dcc184 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 855f814..690f511 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2849,10 +2849,15 @@ def round5d_section(trials, table, results, seed, margins, QUOTED = re.compile(r"'[^']*'|\"[^\"]*\"") -# A here-document's body is data, not commands, and is taken out whole. -HEREDOC = re.compile(r"<<-?\s*(['\"]?)(\w+)\1[^\n]*\n.*?\n\s*\2\s*(?=\n|$)", +# A here-document's body is data, not commands, and is taken out whole; +# the rest of its opening line, a redirection perhaps, stays. +HEREDOC = re.compile(r"(<<-?\s*(['\"]?)(\w+)\2[^\n]*)\n.*?\n\s*\3\s*(?=\n|$)", re.DOTALL) +# The reading commands whose first operand is a pattern or a program, not +# a file to read. +PATTERN_FIRST = ("grep", "rg", "awk", "sed", "select-string") + def simple_commands(command, keep_quotes=False): """A shell command's simple commands, each as (command word, text), the @@ -2865,7 +2870,7 @@ def stash(match): quoted.append(match.group(0)) return "\x00%d\x00" % (len(quoted) - 1) masked = QUOTED.sub(stash, NULL_REDIRECT.sub(" ", HEREDOC.sub( - " ", command))) + r"\1", command))) found = [] for segment in SEGMENT.split(masked): segment = re.sub(r"\x00(\d+)\x00", lambda match: ( @@ -2906,6 +2911,13 @@ def shell_reads(command, known=()): simple_commands(command, keep_quotes=True)): if word not in READ_COMMANDS: continue + + # A search's or a script's first operand is what to look for, not + # a file it reads, so it is left out of the files. + if word in PATTERN_FIRST: + operands = [token for token in text.split()[1:] + if not token.startswith("-")] + text = " ".join(operands[1:]) for operand in TEMPLATE_OPERAND.findall(text): if any(mark in operand for mark in "*?["): found.extend((index, template) for template in known @@ -3020,6 +3032,12 @@ def mapped(templates): calls = list(own) for file in delegated: at = delegation_turn(file, written_at, first_delegation) + + # The line a subagent points back to is the one before the message + # that delegated, so the delegation is the first one from there on. + if at is not None: + at = next((turn for turn, name, _, _ in own + if name in DELEGATIONS and turn >= at), at) calls.extend((at if at is not None else turn, name, given, True) for turn, name, given in tool_calls_by_turn([file])) calls.sort(key=lambda call: call[0]) @@ -3035,8 +3053,9 @@ def mapped(templates): # A shell command may read a template and write a file in one go, # so it is read for both, and a read in a simple command before the # writing one came before the write. - if name in SHELLS and entry.get("vendor"): + if name in SHELLS: writes_at = first_writing_command(command) + if name in SHELLS and entry.get("vendor"): for index, template in shell_reads(command, sorted(known)): if template in known or not known: found.append(template) @@ -3613,6 +3632,50 @@ def stamped(kind, message_id, uuid, *blocks): and not shell_writes(heredoc) and shell_writes("cat a <<'EOF'\nx\nEOF\necho y > z"), in_one_go)) + # A skills arm's shell write counts; a redirection after a here-document + # opener stays; a subagent pointing at the line before the delegating + # message is charged to that message; a search's pattern is no file. + os.makedirs(scratch) + skilled = os.path.join(scratch, "skilled.jsonl") + with io.open(skilled, "w", encoding="utf-8", newline="\n") as handle: + handle.write(line("assistant", "k1", call("Bash", + command="echo x > app.py"))) + handle.write(line("assistant", "k2", call("Skill", + skill="base-quality"))) + handle.write(line("assistant", "k3", call("Edit", file_path="a.py"))) + shell_first = map_use([skilled], "lazyskills", ["base-quality"]) + parent = os.path.join(scratch, "parent.jsonl") + with io.open(parent, "w", encoding="utf-8", newline="\n") as handle: + handle.write(stamped("user", "q0", "u0", {"type": "text", + "text": "go"})) + handle.write(stamped("assistant", "q1", "u1", call( + "Bash", command="ls"))) + handle.write(stamped("user", "q1r", "u1r", {"type": "text", + "text": "ok"})) + handle.write(stamped("assistant", "q2", "u2", call( + "Agent", prompt="read quality"))) + child = os.path.join(scratch, "agent.jsonl") + with io.open(child, "w", encoding="utf-8", newline="\n") as handle: + handle.write(json.dumps({"type": "fork-context-ref", + "parentLastUuid": "u1r"}) + "\n") + handle.write(line("assistant", "c1", call( + "Read", file_path="/pen/%s/%s" % (into, chain[0])))) + anchored = map_use([parent], "lazyref", chain, [child]) + shutil.rmtree(scratch, ignore_errors=True) + checks.append(("a skills arm's shell write counts, a redirection after a " + "here-document opener stays, a subagent is charged to the " + "delegating message, and a search's pattern is no file", + shell_first["first_write"] == 1 + and shell_first["before_write"] == [] + and shell_writes("cat <<'EOF' > app.py\nx\nEOF") + and not shell_writes("cat <<'EOF'\nx > y\nEOF") + and anchored["uses"] == [(2, chain[0])] + and read_names("rg '%s' README.md" % quality) == [] + and read_names("grep -n x %s" % quality) + == ["templates/core/quality.md"] + and read_names("sed -n 1,40p %s" % quality) + == ["templates/core/quality.md"], + (shell_first, anchored))) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { "uses": [], "first_write": 2, "by_subagent": 0}}) checks.append(("a map no trial read is said to be ignored, not read on " From 71543c0a5890a7cbec4c0bdea7eb1740fdd967e5 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:11:28 +0200 Subject: [PATCH 10/21] fix(efficacy): the plain report qualifies H7 with the map's use What `lazyref`'s use of its map says about H7 is one sentence, built once and printed beside H7 in the record and under its answer in the plain report, so a map ignored or read up front is never presented as on-demand reading. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 80 +++++++++++++++++++++++++--------------- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 4dcc184..1790cd5 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -170,7 +170,7 @@ when: | FR-12-09 | Self-test | `report.py` "withdrawal blanks every value of the row"
`report.py` "its verdict vector row reads withdrawn"
`report.py` "the withdrawal section names it and why"
`report.py` "a run graded by another revision withdraws nothing"
`report.py` "a metric not withdrawn keeps its verdict" | | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | -| FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's" | +| FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | | FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 690f511..cb18b48 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -1849,7 +1849,7 @@ def write_report(root, trials, table, results, seed, out_dir, appendix: appendix_lines(trials, table, results, k, seed, generation, report, record, iso), report: plain_report_lines(root, trials, table, results, radar, - appendix, k, iso)} + appendix, k, iso, uses)} for document, text in documents.items(): with io.open(os.path.join(out_dir, document), "w", encoding="utf-8", newline="\n") as handle: @@ -2239,7 +2239,7 @@ def sureness_lines(trials, k): def plain_report_lines(root, trials, table, results, radar, appendix, k, - iso=None): + iso=None, uses=None): """The report a reader opens: the radars, each approach in plain words, the round's questions answered, and how sure the answers are. `iso` is the ISO reading where the round draws that radar.""" @@ -2285,6 +2285,13 @@ def plain_report_lines(root, trials, table, results, radar, appendix, k, state, _ = round5d_hypothesis(results, label, wanted) lines.append("- %s **%s.**" % (PLAIN_QUESTIONS[label], sentence_case(PLAIN_ANSWERS[state]))) + + # H7's answer is about on-demand reading only where the trials + # read on demand, so what the map's use says goes beside it. + if label == "lazyref-reference" and uses is not None: + note = h7_note(map_use_rows(trials, uses)) + if note: + lines.append(" - %s" % sentence_case(note)) lines.append("") elif is_round5(trials): lines.extend(["## The questions this round asked", ""]) @@ -3203,36 +3210,41 @@ def shown(value, places=1): row["arm"], row["trials"], row["total"], shown(row["read"]), shown(row["before"]), shown(row["first"], 0), row["up_front"], row["wrote"])) - for row in rows: - if row["arm"] != "lazyref": - continue - lines.append("") - if not row["wrote"]: - lines.append("Beside H7: no `lazyref` trial's first write could " - "be placed, so the map's use says nothing about " - "whether the templates were read up front or on " - "demand.") - elif row["unused"] == row["trials"]: - lines.append("Beside H7: no `lazyref` trial read a template of " - "its map, so H7 compares a map ignored against " - "templates read up front, not on-demand reading.") - elif row["up_front"]: - lines.append("Beside H7: `lazyref` read every template of its map " - "before its first write in %d of the %d trials that " - "wrote. Those trials measured reading up front, not " - "on demand." % (row["up_front"], row["wrote"])) - else: - lines.append("Beside H7: no `lazyref` trial read every template " - "of its map before its first write, so H7 reads " - "on-demand reading%s." % ( - ", and %d of %d trials read none" - % (row["unused"], row["trials"]) - if row["unused"] else "")) + note = h7_note(rows) + if note: + lines.extend(["", "Beside H7: %s" % note]) lines.append("") lines.extend(map_use_detail(trials, uses)) return lines +def h7_note(rows): + """What `lazyref`'s use of its map says about H7, in one sentence: the + hypothesis reads on-demand reading only where the trials wrote, read + their map, and did not read all of it before writing. None where the + run holds no `lazyref` trial with a transcript.""" + row = next((row for row in rows if row["arm"] == "lazyref"), None) + if row is None: + return None + if not row["wrote"]: + return ("no `lazyref` trial's first write could be placed, so the " + "map's use says nothing about whether the templates were " + "read up front or on demand.") + if row["unused"] == row["trials"]: + return ("no `lazyref` trial read a template of its map, so H7 " + "compares a map ignored against templates read up front, " + "not on-demand reading.") + if row["up_front"]: + return ("`lazyref` read every template of its map before its first " + "write in %d of the %d trials that wrote. Those trials " + "measured reading up front, not on demand." + % (row["up_front"], row["wrote"])) + return ("no `lazyref` trial read every template of its map before its " + "first write, so H7 reads on-demand reading%s." + % (", and %d of %d trials read none" + % (row["unused"], row["trials"]) if row["unused"] else "")) + + # Round 5d's screen for round 6: the candidates, read against the bare arm, # and how many of them go on. SCREEN_CANDIDATES = ("inline", "hybrid", "reference", "skills", "hand", @@ -3785,6 +3797,16 @@ def stamped(kind, message_id, uuid, *blocks): and PLAIN_QUESTIONS["lazyskills-lazyref"] in plain and PLAIN_QUESTIONS["hand-none"] not in plain, plain[plain.find("## The questions"):][:400])) + ignored_uses = {"lazyref-%d" % index: {"uses": [], "first_write": 2, + "by_subagent": 0} + for index in range(1, 4)} + qualified = " ".join(rendered_plain(run, 20260912, ignored_uses).split()) + checks.append(("the plain report qualifies H7's answer with what the " + "map's use says", + "compares a map ignored" in qualified + and qualified.find("compares a map ignored") + > qualified.find(PLAIN_QUESTIONS["lazyref-reference"]), + qualified[qualified.find("## The questions"):][:500])) return checks @@ -6220,7 +6242,7 @@ def rendered(trials, seed, withdrawn): return before, table, text -def rendered_plain(trials, seed): +def rendered_plain(trials, seed, uses=None): """The plain report a planted run renders, as text.""" table = collect(trials) results = round_contrasts(trials, table, seed) @@ -6229,7 +6251,7 @@ def rendered_plain(trials, seed): shutil.rmtree(scratch, ignore_errors=True) os.makedirs(scratch) target = write_report(scratch, trials, table, results, seed, - out_dir=scratch) + out_dir=scratch, uses=uses) with io.open(target, encoding="utf-8") as handle: text = handle.read() shutil.rmtree(scratch, ignore_errors=True) From 74667fb475980ab59616616e8d0c44973dbe1178 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 15:02:20 +0200 Subject: [PATCH 11/21] fix(efficacy): a subagent is charged to the delegation it follows, and a shell path follows cd Three corner cases of the use-of-the-map reading: - a fork pointing back at the previous delegation's result is charged to its own delegation, found by line order rather than by turn; - a quoted search pattern with spaces is one operand, so a template path inside it is no read; - a relative path after a cd in the same shell call is resolved against the directory it moved into. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 156 ++++++++++++++++++++++++++++++--------- 2 files changed, 124 insertions(+), 34 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 1790cd5..25fbf76 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, and a path follows the call's directory change" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index cb18b48..6454ee7 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -22,6 +22,7 @@ import json import math import os +import posixpath import random import re import shutil @@ -2865,6 +2866,28 @@ def round5d_section(trials, table, results, seed, margins, # a file to read. PATTERN_FIRST = ("grep", "rg", "awk", "sed", "select-string") +# The commands that change the directory the simple commands after them in +# the same shell call run in, so a relative path they name is resolved +# against it. +CHANGE_DIR = ("cd", "pushd", "set-location", "sl") + +# A path that starts somewhere other than the current directory: at a +# root, a drive or the home directory. +ABSOLUTE = re.compile(r"^(/|[A-Za-z]:|~)") + + +def words_of(text): + """A simple command's words, a quoted argument staying one word for + all the spaces in it.""" + quoted = [] + + def stash(match): + quoted.append(match.group(0)) + return "\x00%d\x00" % (len(quoted) - 1) + return [re.sub(r"\x00(\d+)\x00", + lambda match: quoted[int(match.group(1))], word) + for word in QUOTED.sub(stash, text).split()] + def simple_commands(command, keep_quotes=False): """A shell command's simple commands, each as (command word, text), the @@ -2914,23 +2937,39 @@ def shell_reads(command, known=()): the vendored copy, a wildcard operand standing for each template of the map it matches.""" found = [] + directory = "" for index, (word, text) in enumerate( simple_commands(command, keep_quotes=True)): + words = [token for token in words_of(text)[1:] + if not ASSIGNMENT.match(token)] + operands = [token for token in words if not token.startswith("-")] + if word in CHANGE_DIR: + target = operands[0].strip("'\"") if operands else "" + directory = "" if target in ("", "-") else posixpath.normpath( + target if ABSOLUTE.match(target) + else posixpath.join(directory, target)) + continue if word not in READ_COMMANDS: continue # A search's or a script's first operand is what to look for, not # a file it reads, so it is left out of the files. - if word in PATTERN_FIRST: - operands = [token for token in text.split()[1:] - if not token.startswith("-")] - text = " ".join(operands[1:]) - for operand in TEMPLATE_OPERAND.findall(text): - if any(mark in operand for mark in "*?["): - found.extend((index, template) for template in known - if fnmatch.fnmatchcase(template, operand)) - elif operand.endswith(".md"): - found.append((index, operand)) + if word in PATTERN_FIRST and operands: + words.remove(operands[0]) + for token in words: + matched = TEMPLATE_OPERAND.findall(token) + + # A path with no vendored copy in it may be relative to the + # directory an earlier command of the call moved into. + if not matched and directory and not token.startswith("-"): + matched = TEMPLATE_OPERAND.findall(posixpath.normpath( + posixpath.join(directory, token.strip("'\"")))) + for operand in matched: + if any(mark in operand for mark in "*?["): + found.extend((index, template) for template in known + if fnmatch.fnmatchcase(template, operand)) + elif operand.endswith(".md"): + found.append((index, operand)) return found @@ -2955,16 +2994,19 @@ def mapped_templates(arm): def tool_calls_by_turn(files, written_at=None): - """Every tool call in the transcripts as (turn, tool, input), a turn - being one message of the model: several lines may share a message id, - so a new id is what counts a turn. Given a dict as `written_at`, each - line's uuid is filed under the turn current once it was written.""" + """Every tool call in the transcripts as (turn, tool, input, line), a + turn being one message of the model and the line the call's place in + the transcripts: several lines may share a message id, so a new id is + what counts a turn. Given a dict as `written_at`, each line's uuid is + filed under its (turn, line).""" calls = [] turn = 0 + at = 0 last_message = object() for file in files: with io.open(file, encoding="utf-8", errors="replace") as handle: for line in handle: + at += 1 try: record = json.loads(line) except ValueError: @@ -2977,7 +3019,7 @@ def tool_calls_by_turn(files, written_at=None): last_message = message.get("id") turn += 1 if written_at is not None and record.get("uuid"): - written_at[record["uuid"]] = turn + written_at[record["uuid"]] = (turn, at) if record.get("type") != "assistant": continue content = message.get("content") @@ -2987,14 +3029,14 @@ def tool_calls_by_turn(files, written_at=None): given = block.get("input") calls.append((turn, block.get("name"), given if isinstance(given, dict) - else {})) + else {}, at)) return calls -def delegation_turn(file, written_at, fallback): - """The session's turn a subagent's transcript was started at: the turn - of the session's line its first record points back to, or `fallback` - where it points at none the session wrote.""" +def delegation_anchor(file, written_at): + """The (turn, line) of the session's line a subagent's transcript + points back to from its first record, or None where it points at none + the session wrote.""" with io.open(file, encoding="utf-8", errors="replace") as handle: for line in handle: try: @@ -3008,7 +3050,7 @@ def delegation_turn(file, written_at, fallback): return written_at[parent] if record.get("type") == "assistant": break - return fallback + return None def map_use(files, arm, templates=None, delegated=()): @@ -3032,21 +3074,24 @@ def mapped(templates): return [template for template in templates if not known or template in known] written_at = {} - own = [(turn, name, given, False) - for turn, name, given in tool_calls_by_turn(files, written_at)] - first_delegation = next((turn for turn, name, _, _ in own - if name in DELEGATIONS), None) + parsed = tool_calls_by_turn(files, written_at) + own = [(turn, name, given, False) for turn, name, given, _ in parsed] + delegations = [(line, turn) for turn, name, _, line in parsed + if name in DELEGATIONS] calls = list(own) for file in delegated: - at = delegation_turn(file, written_at, first_delegation) - - # The line a subagent points back to is the one before the message - # that delegated, so the delegation is the first one from there on. - if at is not None: - at = next((turn for turn, name, _, _ in own - if name in DELEGATIONS and turn >= at), at) + anchor = delegation_anchor(file, written_at) + + # The line a subagent points back to is the delegating message or + # the one before it, a result of the same turn or of the one before + # perhaps, so the delegation is the first one from that line on. + if anchor is not None: + at = next((turn for line, turn in delegations + if line >= anchor[1]), anchor[0]) + else: + at = delegations[0][1] if delegations else None calls.extend((at if at is not None else turn, name, given, True) - for turn, name, given in tool_calls_by_turn([file])) + for turn, name, given, _ in tool_calls_by_turn([file])) calls.sort(key=lambda call: call[0]) uses = [] before = set() @@ -3688,6 +3733,51 @@ def stamped(kind, message_id, uuid, *blocks): and read_names("sed -n 1,40p %s" % quality) == ["templates/core/quality.md"], (shell_first, anchored))) + # Two delegations in a row: the second subagent points back at the + # first one's result, written in the first one's turn, and is charged + # to the second delegation all the same. A quoted pattern with spaces + # is one operand; a path is resolved against the directory an earlier + # command of the call moved into. + os.makedirs(scratch) + parent = os.path.join(scratch, "parent.jsonl") + with io.open(parent, "w", encoding="utf-8", newline="\n") as handle: + handle.write(stamped("user", "r0", "v0", {"type": "text", + "text": "go"})) + handle.write(stamped("assistant", "r1", "v1", call( + "Agent", prompt="read quality"))) + handle.write(stamped("user", "r1r", "v1r", {"type": "text", + "text": "done"})) + handle.write(stamped("assistant", "r2", "v2", call( + "Agent", prompt="read http"))) + handle.write(stamped("assistant", "r3", "v3", call( + "Write", file_path="a.py"))) + children = [] + for index, (uuid, template) in enumerate( + (("v0", "core/quality.md"), ("v1r", "backend/http.md"))): + child = os.path.join(scratch, "agent-%d.jsonl" % index) + with io.open(child, "w", encoding="utf-8", newline="\n") as handle: + handle.write(json.dumps({"type": "fork-context-ref", + "parentLastUuid": uuid}) + "\n") + handle.write(line("assistant", "d%d" % index, call( + "Read", file_path="/pen/%s/templates/%s" % (into, template)))) + children.append(child) + in_a_row = map_use([parent], "lazyref", chain, children) + shutil.rmtree(scratch, ignore_errors=True) + checks.append(("a subagent pointing at the previous delegation's result " + "is charged to its own delegation, a quoted pattern is one " + "operand, and a path follows the call's directory change", + in_a_row["uses"] == [(1, chain[0]), (2, chain[2])] + and read_names('grep "mention %s" README.md' % quality) + == [] + and read_names("grep 'x y' %s" % quality) + == ["templates/core/quality.md"] + and read_names("cd %s && cat templates/core/quality.md" + % into) == ["templates/core/quality.md"] + and read_names("cd %s/templates; cat core/git.md " + "../templates/core/quality.md; cd ..; ls" % into) + == ["templates/core/git.md", "templates/core/quality.md"] + and read_names("cd src && cat core/quality.md") == [], + in_a_row)) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { "uses": [], "first_write": 2, "by_subagent": 0}}) checks.append(("a map no trial read is said to be ignored, not read on " From 39ed1318bfb1b6c9f967fd48ec58bdde9f85edb0 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 15:14:02 +0200 Subject: [PATCH 12/21] fix(efficacy): the screen waits for a whole run, and H7's note for a trial that read and wrote A short run decides nothing, so the round-6 screen ranks what it holds but names no arm while the run owes blocks. The note beside H7 claims on-demand reading only where a trial both read a template of its map and wrote a file; one that only read, or only wrote, shows nothing. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 4 +-- tests/efficacy/report.py | 54 ++++++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 25fbf76..e6241c0 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,8 +171,8 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, and a path follows the call's directory change" | -| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, and a path follows the call's directory change" | +| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 6454ee7..0ff05c3 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -3207,6 +3207,9 @@ def map_use_rows(trials, uses): "read": mean_of(counts), "before": mean_of(before), "wrote": len(before), "first": median_of(firsts), "unused": sum(1 for count in counts if not count), + "read_and_wrote": sum( + 1 for name in names if uses[name]["uses"] + and uses[name]["first_write"] is not None), "up_front": sum(1 for count in before if total and count >= total)}) return rows @@ -3275,18 +3278,23 @@ def h7_note(rows): return ("no `lazyref` trial's first write could be placed, so the " "map's use says nothing about whether the templates were " "read up front or on demand.") - if row["unused"] == row["trials"]: - return ("no `lazyref` trial read a template of its map, so H7 " - "compares a map ignored against templates read up front, " - "not on-demand reading.") + + # Only a trial that both read and wrote shows where its reads fell; + # one that read and never wrote, or wrote and never read, shows nothing + # about reading on demand. + if not row["read_and_wrote"]: + return ("no `lazyref` trial that wrote read a template of its map, " + "so H7 compares a map ignored against templates read up " + "front, not on-demand reading.") if row["up_front"]: return ("`lazyref` read every template of its map before its first " "write in %d of the %d trials that wrote. Those trials " "measured reading up front, not on demand." % (row["up_front"], row["wrote"])) return ("no `lazyref` trial read every template of its map before its " - "first write, so H7 reads on-demand reading%s." - % (", and %d of %d trials read none" + "first write, so H7 reads on-demand reading in the %d trials " + "that read and wrote%s." + % (row["read_and_wrote"], ", while %d of %d trials read none" % (row["unused"], row["trials"]) if row["unused"] else "")) @@ -3301,9 +3309,10 @@ def h7_note(rows): def round6_screen(trials, table, results): """Each candidate against the bare arm: out where a deciding row reads worse, the rest ranked by rows better and then by mean cost, the top - four going on to round 6 once every candidate is read. A candidate the - run holds no trial of is named as missing, and nothing goes on until - it is read too.""" + four going on to round 6 once every candidate is read and the run is + whole. A candidate the run holds no trial of is named as missing, and + nothing goes on until it is read too, nor while the run is short of + its K: a short run decides nothing.""" rows = [] missing = [] @@ -3327,9 +3336,10 @@ def round6_screen(trials, table, results): kept = [row for row in rows if not row["worse"]] kept.sort(key=lambda row: (-row["better"], row["cost"] if row["cost"] is not None else float("inf"))) + short = bool(owed_blocks(trials)) for rank, row in enumerate(kept, 1): row["rank"] = rank - row["round6"] = rank <= SCREEN_KEEPS and not missing + row["round6"] = rank <= SCREEN_KEEPS and not missing and not short return rows, missing @@ -3356,11 +3366,16 @@ def screen_lines(trials, table, results): "—" if row["cost"] is None else "$%.2f" % row["cost"], screen)) chosen = [row["arm"] for row in sorted( (row for row in rows if row["round6"]), key=lambda row: row["rank"])] + owed = owed_blocks(trials) if missing: lines.extend(["", "The screen is partial: %s %s not in this root, so " "it names no arms for round 6 yet." % ( spoken(["`%s`" % arm for arm in missing]), "is" if len(missing) == 1 else "are")]) + elif owed: + lines.extend(["", "The screen is provisional: the run still owes %s, " + "and a short run decides nothing, so it names no arms " + "for round 6 yet." % blocks_named(owed)]) else: lines.extend(["", "Round 6 runs `%s`%s." % ( BARE, " and " + spoken(["`%s`" % arm for arm in chosen]) @@ -3785,6 +3800,14 @@ def stamped(kind, message_id, uuid, *blocks): "compares a map ignored" in "\n".join(ignored) and "so H7 reads on-demand" not in "\n".join(ignored), ignored[-6:])) + apart = h7_note(map_use_rows( + {"lazyref-1": {}, "lazyref-2": {}}, + {"lazyref-1": never_wrote, + "lazyref-2": {"uses": [], "first_write": 2, "by_subagent": 0}})) + checks.append(("a trial that read and never wrote beside one that wrote " + "and never read shows no on-demand reading", + "compares a map ignored" in apart + and "so H7 reads on-demand" not in apart, apart)) planted_uses = {"lazyref-1": reading} kept = aggregate(1, {}, {}, {}, {}, None, None, planted_uses)["map_use"] checks.append(("the aggregate keeps each trial's map use", @@ -3844,6 +3867,17 @@ def stamped(kind, message_id, uuid, *blocks): table["cost_usd"]["values"][arm] = {1: 30.0, 2: 30.0} for key in SCREEN_ROWS: results[key]["%s-none" % arm] = {"verdict": "held"} + short_rows, _ = round6_screen(held, table, results) + short_text = "\n".join(screen_lines(held, table, results)) + checks.append(("the screen names no arm for round 6 while the run is " + "short of its K", + not any(row["round6"] for row in short_rows) + and "still owes blocks 2 to 15" in short_text + and "names no arms for round 6 yet" in short_text, + short_text.splitlines()[-1])) + for arm in ROUND5E_ARMS: + for block in range(2, ROUND5_K + 1): + held[trial_name(arm, block)] = {} full_rows, missing = round6_screen(held, table, results) screen = {row["arm"]: (row["rank"], row["round6"], row["worse"]) for row in full_rows} From c9fa3f41aac6b613754879a78c2cd4b84c184530 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 15:32:52 +0200 Subject: [PATCH 13/21] fix(efficacy): the screen owes every arm it reads, and a wildcard stands for no slash A reused arm short of its K holds the screen as a fresh one does, since the screen reads them alike. A shell wildcard matches a template part by part, as a shell's does, so templates/*.md names no template in a subfolder. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 4 +-- tests/efficacy/report.py | 63 ++++++++++++++++++++++++++++++++++------ 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index e6241c0..596803f 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,8 +171,8 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, and a path follows the call's directory change" | -| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, and a wildcard stands for no slash" | +| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 0ff05c3..312338d 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2889,6 +2889,15 @@ def stash(match): for word in QUOTED.sub(stash, text).split()] +def glob_matches(pattern, path): + """Whether a shell wildcard pattern matches a path, a wildcard standing + for no slash: the pattern and the path match part by part.""" + parts = pattern.split("/") + pieces = path.split("/") + return len(parts) == len(pieces) and all( + fnmatch.fnmatchcase(piece, part) for part, piece in zip(parts, pieces)) + + def simple_commands(command, keep_quotes=False): """A shell command's simple commands, each as (command word, text), the null redirections and here-document bodies taken out and, unless asked @@ -2967,7 +2976,7 @@ def shell_reads(command, known=()): for operand in matched: if any(mark in operand for mark in "*?["): found.extend((index, template) for template in known - if fnmatch.fnmatchcase(template, operand)) + if glob_matches(operand, template)) elif operand.endswith(".md"): found.append((index, operand)) return found @@ -3336,13 +3345,30 @@ def round6_screen(trials, table, results): kept = [row for row in rows if not row["worse"]] kept.sort(key=lambda row: (-row["better"], row["cost"] if row["cost"] is not None else float("inf"))) - short = bool(owed_blocks(trials)) + short = bool(screen_owed(trials)) for rank, row in enumerate(kept, 1): row["rank"] = rank row["round6"] = rank <= SCREEN_KEEPS and not missing and not short return rows, missing +def screen_owed(trials): + """The blocks of round 5's K the run still owes each arm the screen + reads, the bare arm and every candidate present, as (arm, blocks); + empty once every one of them has all K trials. A reused arm counts as + much as a fresh one here, since the screen reads them alike.""" + present = {arm_of(name) for name in trials} + owed = [] + for arm in (BARE,) + SCREEN_CANDIDATES: + if arm not in present: + continue + blocks = [block for block in range(1, ROUND5_K + 1) + if trial_name(arm, block) not in trials] + if blocks: + owed.append((arm, blocks)) + return owed + + def screen_lines(trials, table, results): """The screen as a table, and the arms round 6 runs, or the candidates still to be read before it names them.""" @@ -3366,7 +3392,7 @@ def screen_lines(trials, table, results): "—" if row["cost"] is None else "$%.2f" % row["cost"], screen)) chosen = [row["arm"] for row in sorted( (row for row in rows if row["round6"]), key=lambda row: row["rank"])] - owed = owed_blocks(trials) + owed = screen_owed(trials) if missing: lines.extend(["", "The screen is partial: %s %s not in this root, so " "it names no arms for round 6 yet." % ( @@ -3375,7 +3401,9 @@ def screen_lines(trials, table, results): elif owed: lines.extend(["", "The screen is provisional: the run still owes %s, " "and a short run decides nothing, so it names no arms " - "for round 6 yet." % blocks_named(owed)]) + "for round 6 yet." % spoken([ + "`%s` %s" % (arm, blocks_named(blocks)) + for arm, blocks in owed])]) else: lines.extend(["", "Round 6 runs `%s`%s." % ( BARE, " and " + spoken(["`%s`" % arm for arm in chosen]) @@ -3780,7 +3808,8 @@ def stamped(kind, message_id, uuid, *blocks): shutil.rmtree(scratch, ignore_errors=True) checks.append(("a subagent pointing at the previous delegation's result " "is charged to its own delegation, a quoted pattern is one " - "operand, and a path follows the call's directory change", + "operand, a path follows the call's directory change, and " + "a wildcard stands for no slash", in_a_row["uses"] == [(1, chain[0]), (2, chain[2])] and read_names('grep "mention %s" README.md' % quality) == [] @@ -3791,7 +3820,10 @@ def stamped(kind, message_id, uuid, *blocks): and read_names("cd %s/templates; cat core/git.md " "../templates/core/quality.md; cd ..; ls" % into) == ["templates/core/git.md", "templates/core/quality.md"] - and read_names("cd src && cat core/quality.md") == [], + and read_names("cd src && cat core/quality.md") == [] + and read_names("cat %s/templates/*.md" % into, chain) == [] + and read_names("cat %s/templates/*/q*.md" % into, chain) + == ["templates/core/quality.md"], in_a_row)) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { "uses": [], "first_write": 2, "by_subagent": 0}}) @@ -3872,12 +3904,25 @@ def stamped(kind, message_id, uuid, *blocks): checks.append(("the screen names no arm for round 6 while the run is " "short of its K", not any(row["round6"] for row in short_rows) - and "still owes blocks 2 to 15" in short_text + and "still owes `none` blocks 2 to 15" in short_text + and "`lazyskills` blocks 2 to 15, and a short run" + in short_text and "names no arms for round 6 yet" in short_text, short_text.splitlines()[-1])) - for arm in ROUND5E_ARMS: + for arm in list(costs) + [BARE]: for block in range(2, ROUND5_K + 1): - held[trial_name(arm, block)] = {} + if (arm, block) != ("hand", 7): + held[trial_name(arm, block)] = {} + reused_short, _ = round6_screen(held, table, results) + checks.append(("a reused arm short of its K holds the screen as a fresh " + "one does", + not any(row["round6"] for row in reused_short) + and screen_owed(held) == [("hand", [7])] + and "still owes `hand` block 7" + in "\n".join( + screen_lines(held, table, results)), + screen_owed(held))) + held[trial_name("hand", 7)] = {} full_rows, missing = round6_screen(held, table, results) screen = {row["arm"]: (row["rank"], row["round6"], row["worse"]) for row in full_rows} From 7793024c755e4b7c8c7c8764553a1c38e2c791e1 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 15:44:37 +0200 Subject: [PATCH 14/21] fix(efficacy): the screen waits for every deciding row, and a shell loop's files count as read A row not computed yet, or one crossing roots, is no reading, so the screen ranks what it holds but names no arm until every candidate's deciding rows are read. In a shell command, a word that opens a loop's or a branch's body is no command, and the files a loop runs over count as read. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 4 +-- tests/efficacy/report.py | 64 +++++++++++++++++++++++++++++++++++----- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 596803f..7f90634 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,8 +171,8 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, and a wildcard stands for no slash" | -| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, and a loop's files count as read" | +| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "a deciding row not computed yet holds the screen"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 312338d..e743883 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2866,6 +2866,10 @@ def round5d_section(trials, table, results, seed, margins, # a file to read. PATTERN_FIRST = ("grep", "rg", "awk", "sed", "select-string") +# A word that opens a loop's or a branch's body, or a subshell, is no +# command: the command is the word after it. +BODY_OPENERS = ("do", "then", "else", "{", "(") + # The commands that change the directory the simple commands after them in # the same shell call run in, so a relative path they name is resolved # against it. @@ -2916,9 +2920,12 @@ def stash(match): quoted[int(match.group(1))] if keep_quotes else " "), segment) words = [word for word in segment.split() if not ASSIGNMENT.match(word)] + while words and words[0].lower() in BODY_OPENERS: + words.pop(0) if not words: continue - word = words[0].replace("\\", "/").rsplit("/", 1)[-1].lower() + word = words[0].lstrip("(").replace("\\", "/").rsplit("/", 1)[-1] + word = word.lower() if word.endswith(".exe"): word = word[:-len(".exe")] found.append((word, segment)) @@ -2949,8 +2956,9 @@ def shell_reads(command, known=()): directory = "" for index, (word, text) in enumerate( simple_commands(command, keep_quotes=True)): - words = [token for token in words_of(text)[1:] - if not ASSIGNMENT.match(token)] + words = [token for token in words_of(text) + if not ASSIGNMENT.match(token) + and token.lower() not in BODY_OPENERS][1:] operands = [token for token in words if not token.startswith("-")] if word in CHANGE_DIR: target = operands[0].strip("'\"") if operands else "" @@ -2958,7 +2966,12 @@ def shell_reads(command, known=()): target if ABSOLUTE.match(target) else posixpath.join(directory, target)) continue - if word not in READ_COMMANDS: + + # A loop over files reads them in its body, so the files it runs + # over count as read where the body's own words name none. + if word == "for": + words = words[words.index("in") + 1:] if "in" in words else [] + elif word not in READ_COMMANDS: continue # A search's or a script's first operand is what to look for, not @@ -3335,7 +3348,13 @@ def round6_screen(trials, table, results): continue readings = {key: row_reading(results.get(key, {}).get(label)) for key in SCREEN_ROWS} + + # A row not computed yet, or one crossing roots, is no reading: it + # is neither better nor worse, and the screen waits for it. rows.append({"arm": arm, + "unread": [key for key in SCREEN_ROWS + if not row_read(results.get(key, {}) + .get(label))], "worse": [key for key in SCREEN_ROWS if readings[key] == "worse"], "better": sum(1 for reading in readings.values() @@ -3345,13 +3364,20 @@ def round6_screen(trials, table, results): kept = [row for row in rows if not row["worse"]] kept.sort(key=lambda row: (-row["better"], row["cost"] if row["cost"] is not None else float("inf"))) - short = bool(screen_owed(trials)) + waiting = bool(screen_owed(trials)) or any(row["unread"] for row in rows) for rank, row in enumerate(kept, 1): row["rank"] = rank - row["round6"] = rank <= SCREEN_KEEPS and not missing and not short + row["round6"] = rank <= SCREEN_KEEPS and not missing and not waiting return rows, missing +def row_read(contrast): + """Whether a contrast's row has been read at all: computed, from both + arms of one root.""" + return contrast is not None and contrast.get("verdict") not in ( + None, "not computed", CROSSING_VERDICT) + + def screen_owed(trials): """The blocks of round 5's K the run still owes each arm the screen reads, the bare arm and every candidate present, as (arm, blocks); @@ -3404,6 +3430,12 @@ def screen_lines(trials, table, results): "for round 6 yet." % spoken([ "`%s` %s" % (arm, blocks_named(blocks)) for arm, blocks in owed])]) + elif any(row["unread"] for row in rows): + lines.extend(["", "The screen is provisional: %s not computed yet, " + "so it names no arms for round 6 yet." % spoken([ + "`%s`'s %s" % (row["arm"], spoken( + [SHORT.get(key, key) for key in row["unread"]])) + for row in rows if row["unread"]])]) else: lines.extend(["", "Round 6 runs `%s`%s." % ( BARE, " and " + spoken(["`%s`" % arm for arm in chosen]) @@ -3808,8 +3840,9 @@ def stamped(kind, message_id, uuid, *blocks): shutil.rmtree(scratch, ignore_errors=True) checks.append(("a subagent pointing at the previous delegation's result " "is charged to its own delegation, a quoted pattern is one " - "operand, a path follows the call's directory change, and " - "a wildcard stands for no slash", + "operand, a path follows the call's directory change, a " + "wildcard stands for no slash, and a loop's files count " + "as read", in_a_row["uses"] == [(1, chain[0]), (2, chain[2])] and read_names('grep "mention %s" README.md' % quality) == [] @@ -3823,6 +3856,12 @@ def stamped(kind, message_id, uuid, *blocks): and read_names("cd src && cat core/quality.md") == [] and read_names("cat %s/templates/*.md" % into, chain) == [] and read_names("cat %s/templates/*/q*.md" % into, chain) + == ["templates/core/quality.md"] + and read_names('for f in %s/templates/*/*.md; do cat "$f"; ' + 'done' % into, chain) == chain + and read_names("(cd %s && cat templates/core/git.md)" + % into) == ["templates/core/git.md"] + and read_names("if test -f x; then cat %s; fi" % quality) == ["templates/core/quality.md"], in_a_row)) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { @@ -3923,6 +3962,15 @@ def stamped(kind, message_id, uuid, *blocks): screen_lines(held, table, results)), screen_owed(held))) held[trial_name("hand", 7)] = {} + results["judge_security"]["hand-none"] = {"verdict": "not computed"} + unread_rows, _ = round6_screen(held, table, results) + unread_text = "\n".join(screen_lines(held, table, results)) + checks.append(("a deciding row not computed yet holds the screen", + not any(row["round6"] for row in unread_rows) + and "`hand`'s %s not computed yet" % SHORT["judge_security"] + in unread_text, + unread_text.splitlines()[-1])) + results["judge_security"]["hand-none"] = {"verdict": "held"} full_rows, missing = round6_screen(held, table, results) screen = {row["arm"]: (row["rank"], row["round6"], row["worse"]) for row in full_rows} From 7993a3507966c85dae0cc36d3484202667811e53 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 15:54:45 +0200 Subject: [PATCH 15/21] fix(efficacy): a loop's files count as read only when its body reads, and a quoted null device is no write Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 7f90634..6ec246e 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, and a loop's files count as read" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, a loop's files count as read when its body reads, and a quoted null device is no write" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "a deciding row not computed yet holds the screen"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index e743883..df83ed0 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2850,7 +2850,7 @@ def round5d_section(trials, table, results, seed, margins, # A redirection that writes no file: to the null device, or of one stream # into another. Taken out of a command before it is read for a write. NULL_REDIRECT = re.compile( - r"\d?>{1,2}\s*(&\d|/dev/null|\$null|NUL\b)", re.IGNORECASE) + r"\d?>{1,2}\s*(['\"]?)(&\d|/dev/null|\$null|NUL\b)\1", re.IGNORECASE) # Quoted text is an argument, not an operator or a command, so it is taken # out before a command is read for a write. @@ -2954,8 +2954,8 @@ def shell_reads(command, known=()): map it matches.""" found = [] directory = "" - for index, (word, text) in enumerate( - simple_commands(command, keep_quotes=True)): + commands = simple_commands(command, keep_quotes=True) + for index, (word, text) in enumerate(commands): words = [token for token in words_of(text) if not ASSIGNMENT.match(token) and token.lower() not in BODY_OPENERS][1:] @@ -2967,9 +2967,14 @@ def shell_reads(command, known=()): else posixpath.join(directory, target)) continue - # A loop over files reads them in its body, so the files it runs - # over count as read where the body's own words name none. + # A loop over files counts them as read when its body, up to + # `done`, reads what it is given; a body that only names them does + # not. if word == "for": + body = itertools.takewhile(lambda step: step[0] != "done", + commands[index + 1:]) + if not any(step[0] in READ_COMMANDS for step in body): + continue words = words[words.index("in") + 1:] if "in" in words else [] elif word not in READ_COMMANDS: continue @@ -3841,8 +3846,9 @@ def stamped(kind, message_id, uuid, *blocks): checks.append(("a subagent pointing at the previous delegation's result " "is charged to its own delegation, a quoted pattern is one " "operand, a path follows the call's directory change, a " - "wildcard stands for no slash, and a loop's files count " - "as read", + "wildcard stands for no slash, a loop's files count as " + "read when its body reads, and a quoted null device is " + "no write", in_a_row["uses"] == [(1, chain[0]), (2, chain[2])] and read_names('grep "mention %s" README.md' % quality) == [] @@ -3859,6 +3865,10 @@ def stamped(kind, message_id, uuid, *blocks): == ["templates/core/quality.md"] and read_names('for f in %s/templates/*/*.md; do cat "$f"; ' 'done' % into, chain) == chain + and read_names('for f in %s/templates/*/*.md; do echo "$f"; ' + 'done; cat README.md' % into, chain) == [] + and not shell_writes('cat %s 2>"/dev/null"' % quality) + and not shell_writes("cat %s 2>'/dev/null'" % quality) and read_names("(cd %s && cat templates/core/git.md)" % into) == ["templates/core/git.md"] and read_names("if test -f x; then cat %s; fi" % quality) From 3f450d339d8d4246eacce913e4231cc70d1bb276 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:41:07 +0200 Subject: [PATCH 16/21] fix(efficacy): the screen waits for no row of a candidate out, a loop's reads go to the command reading its variable, and a flag names a search's pattern Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 4 +- tests/efficacy/report.py | 107 +++++++++++++++++++++++++++------------ 2 files changed, 78 insertions(+), 33 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index 6ec246e..e7cdcac 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,8 +171,8 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, a loop's files count as read when its body reads, and a quoted null device is no write" | -| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "a deciding row not computed yet holds the screen"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, a loop's files are read by the body's command that reads its variable, a flag names a search's pattern, and a quoted null device is no write" | +| FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "a deciding row not computed yet holds the screen"
`report.py` "a candidate out on a row read worse holds the screen for no unread row"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index df83ed0..450c2e9 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2863,8 +2863,9 @@ def round5d_section(trials, table, results, seed, margins, re.DOTALL) # The reading commands whose first operand is a pattern or a program, not -# a file to read. +# a file to read, unless a flag names the pattern or the program instead. PATTERN_FIRST = ("grep", "rg", "awk", "sed", "select-string") +PATTERN_FLAGS = ("-e", "--regexp", "-f", "--file", "-pattern") # A word that opens a loop's or a branch's body, or a subshell, is no # command: the command is the word after it. @@ -2955,6 +2956,24 @@ def shell_reads(command, known=()): found = [] directory = "" commands = simple_commands(command, keep_quotes=True) + + def noted(tokens, at): + """Every template the tokens name, under the vendored copy or + relative to the directory moved into, charged to command `at`.""" + for token in tokens: + matched = TEMPLATE_OPERAND.findall(token) + + # A path with no vendored copy in it may be relative to the + # directory an earlier command of the call moved into. + if not matched and directory and not token.startswith("-"): + matched = TEMPLATE_OPERAND.findall(posixpath.normpath( + posixpath.join(directory, token.strip("'\"")))) + for operand in matched: + if any(mark in operand for mark in "*?["): + found.extend((at, template) for template in known + if glob_matches(operand, template)) + elif operand.endswith(".md"): + found.append((at, operand)) for index, (word, text) in enumerate(commands): words = [token for token in words_of(text) if not ASSIGNMENT.match(token) @@ -2967,36 +2986,34 @@ def shell_reads(command, known=()): else posixpath.join(directory, target)) continue - # A loop over files counts them as read when its body, up to - # `done`, reads what it is given; a body that only names them does - # not. + # A loop's files are read by the command of its body, up to `done`, + # that reads its variable, and are charged to that command; a body + # that only names them, or reads something else, reads none. if word == "for": - body = itertools.takewhile(lambda step: step[0] != "done", - commands[index + 1:]) - if not any(step[0] in READ_COMMANDS for step in body): - continue - words = words[words.index("in") + 1:] if "in" in words else [] - elif word not in READ_COMMANDS: + variable = re.compile(r"\$\{?%s\b" % re.escape(words[0])) if words else None + files = words[words.index("in") + 1:] if "in" in words else [] + for at, (verb, body) in enumerate(commands[index + 1:], + index + 1): + if verb == "done": + break + if verb in READ_COMMANDS and variable \ + and variable.search(body): + noted(files, at) + continue + if word not in READ_COMMANDS: continue # A search's or a script's first operand is what to look for, not - # a file it reads, so it is left out of the files. + # a file it reads, unless a flag names it, so it is left out of the + # files. if word in PATTERN_FIRST and operands: - words.remove(operands[0]) - for token in words: - matched = TEMPLATE_OPERAND.findall(token) - - # A path with no vendored copy in it may be relative to the - # directory an earlier command of the call moved into. - if not matched and directory and not token.startswith("-"): - matched = TEMPLATE_OPERAND.findall(posixpath.normpath( - posixpath.join(directory, token.strip("'\"")))) - for operand in matched: - if any(mark in operand for mark in "*?["): - found.extend((index, template) for template in known - if glob_matches(operand, template)) - elif operand.endswith(".md"): - found.append((index, operand)) + flagged = next((at for at, token in enumerate(words[:-1]) + if token.lower() in PATTERN_FLAGS), None) + if flagged is None: + words.remove(operands[0]) + else: + words.pop(flagged + 1) + noted(words, index) return found @@ -3369,13 +3386,21 @@ def round6_screen(trials, table, results): kept = [row for row in rows if not row["worse"]] kept.sort(key=lambda row: (-row["better"], row["cost"] if row["cost"] is not None else float("inf"))) - waiting = bool(screen_owed(trials)) or any(row["unread"] for row in rows) + waiting = bool(screen_owed(trials)) or any( + row["unread"] for row in screen_unread(rows)) for rank, row in enumerate(kept, 1): row["rank"] = rank row["round6"] = rank <= SCREEN_KEEPS and not missing and not waiting return rows, missing +def screen_unread(rows): + """The screen's rows of a candidate still in with a deciding row not + read yet. A candidate out on a row read worse needs no more reading; + one whose builds all failed never gets its build-only rows.""" + return [row for row in rows if row["unread"] and not row["worse"]] + + def row_read(contrast): """Whether a contrast's row has been read at all: computed, from both arms of one root.""" @@ -3435,12 +3460,12 @@ def screen_lines(trials, table, results): "for round 6 yet." % spoken([ "`%s` %s" % (arm, blocks_named(blocks)) for arm, blocks in owed])]) - elif any(row["unread"] for row in rows): + elif screen_unread(rows): lines.extend(["", "The screen is provisional: %s not computed yet, " "so it names no arms for round 6 yet." % spoken([ "`%s`'s %s" % (row["arm"], spoken( [SHORT.get(key, key) for key in row["unread"]])) - for row in rows if row["unread"]])]) + for row in screen_unread(rows)])]) else: lines.extend(["", "Round 6 runs `%s`%s." % ( BARE, " and " + spoken(["`%s`" % arm for arm in chosen]) @@ -3846,8 +3871,9 @@ def stamped(kind, message_id, uuid, *blocks): checks.append(("a subagent pointing at the previous delegation's result " "is charged to its own delegation, a quoted pattern is one " "operand, a path follows the call's directory change, a " - "wildcard stands for no slash, a loop's files count as " - "read when its body reads, and a quoted null device is " + "wildcard stands for no slash, a loop's files are read " + "by the body's command that reads its variable, a flag " + "names a search's pattern, and a quoted null device is " "no write", in_a_row["uses"] == [(1, chain[0]), (2, chain[2])] and read_names('grep "mention %s" README.md' % quality) @@ -3867,6 +3893,17 @@ def stamped(kind, message_id, uuid, *blocks): 'done' % into, chain) == chain and read_names('for f in %s/templates/*/*.md; do echo "$f"; ' 'done; cat README.md' % into, chain) == [] + and read_names('for f in %s/templates/*/*.md; do cat ' + 'README.md; done' % into, chain) == [] + and shell_reads('for f in %s/templates/*/*.md; do echo s > ' + 'n.txt; cat "${f}"; done' % into, chain) + == [(2, template) for template in chain] + and first_writing_command( + 'for f in x; do echo s > n.txt; cat "$f"; done') == 1 + and read_names("Select-String -Path %s -Pattern TODO" + % quality) == ["templates/core/quality.md"] + and read_names("grep -e TODO %s" % quality) + == ["templates/core/quality.md"] and not shell_writes('cat %s 2>"/dev/null"' % quality) and not shell_writes("cat %s 2>'/dev/null'" % quality) and read_names("(cd %s && cat templates/core/git.md)" @@ -3981,7 +4018,15 @@ def stamped(kind, message_id, uuid, *blocks): in unread_text, unread_text.splitlines()[-1])) results["judge_security"]["hand-none"] = {"verdict": "held"} + results["judge_security"]["reference-none"] = {"verdict": "not computed"} full_rows, missing = round6_screen(held, table, results) + checks.append(("a candidate out on a row read worse holds the screen for " + "no unread row", + any(row["round6"] for row in full_rows) + and next(row["unread"] for row in full_rows + if row["arm"] == "reference") + == ["judge_security"], + [(row["arm"], row["round6"]) for row in full_rows])) screen = {row["arm"]: (row["rank"], row["round6"], row["worse"]) for row in full_rows} checks.append(("the screen drops an arm worse than none on a deciding " From 9bf29fb1d8717cd4cc183b1c7950c60a66fec8d6 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:54:00 +0200 Subject: [PATCH 17/21] fix(efficacy): a backslash before a line break continues a shell command Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index e7cdcac..c1569e1 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, and a here-document body is no command"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, a loop's files are read by the body's command that reads its variable, a flag names a search's pattern, and a quoted null device is no write" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, a here-document body is no command, and a backslash continues a line"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, a loop's files are read by the body's command that reads its variable, a flag names a search's pattern, and a quoted null device is no write" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "a deciding row not computed yet holds the screen"
`report.py` "a candidate out on a row read worse holds the screen for no unread row"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 450c2e9..63ef6c7 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2857,6 +2857,11 @@ def round5d_section(trials, table, results, seed, margins, QUOTED = re.compile(r"'[^']*'|\"[^\"]*\"") +# A backslash before a line break continues the command on the next line, +# so the two lines are one command. +CONTINUATION = re.compile(r"\\\r?\n") + + # A here-document's body is data, not commands, and is taken out whole; # the rest of its opening line, a redirection perhaps, stays. HEREDOC = re.compile(r"(<<-?\s*(['\"]?)(\w+)\2[^\n]*)\n.*?\n\s*\3\s*(?=\n|$)", @@ -3142,7 +3147,8 @@ def mapped(templates): first_write = None by_subagent = 0 for turn, name, given, from_subagent in calls: - command = str(given.get("command") or "").replace("\\", "/") + command = CONTINUATION.sub(" ", str(given.get("command") or "") + ).replace("\\", "/") found = [] writes_at = None @@ -3781,13 +3787,13 @@ def stamped(kind, message_id, uuid, *blocks): with io.open(one_go, "w", encoding="utf-8", newline="\n") as handle: handle.write(line("assistant", "g1", call("Bash", command=heredoc))) handle.write(line("assistant", "g2", call( - "Bash", command="cat %s/%s %s/%s && mkdir -p src && cat %s/%s" + "Bash", command="cat %s/%s \\\n %s/%s && mkdir -p src && cat %s/%s" % (into, chain[0], into, chain[1], into, chain[2])))) in_one_go = map_use([one_go], "lazyref", chain) shutil.rmtree(scratch, ignore_errors=True) checks.append(("a read before the writing command of one shell call " - "comes before the write, and a here-document body is " - "no command", + "comes before the write, a here-document body is no " + "command, and a backslash continues a line", in_one_go["first_write"] == 2 and in_one_go["before_write"] == sorted(chain[:2]) and len(in_one_go["uses"]) == 3 From 1fbca5230c2065f374b39e28295e2bbd7702263b Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:07:37 +0200 Subject: [PATCH 18/21] fix(efficacy): an edit in place or a download is a shell write, and a brace list expands Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xNajarzjtZvD46RAGT --- docs/coverage.md | 2 +- tests/efficacy/report.py | 48 ++++++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/docs/coverage.md b/docs/coverage.md index c1569e1..d84bdc3 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -171,7 +171,7 @@ when: | FR-12-10 | Self-test | `score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused"
`report.py` "a run graded by another revision withdraws nothing" | | FR-12-12 | Self-test | `report.py` "a sub-score is the share of its measured targets met, and one with none reads not measured"
`report.py` "an axis is the mean of its measured sub-scores, each weighing the same"
`report.py` "an arm is the mean over its trials"
`report.py` "a broken build counts against Reliability only"
`report.py` "a marker turns only past the axis's margin"
`report.py` "an axis that could not be read carries no marker"
`report.py` "the move shown is the contrast's mean over the blocks it paired"
`report.py` "a withdrawn metric's target is not measured"
`report.py` "an axis contrast over fewer pairs than blocks names its count"
`report.py` "the aggregate keeps the ISO reading where the round draws it"
`report.py` "the plain words follow the ISO markers, with the cost on its own line"
`report.py` "an axis not measured leaves no vertex, unlike a measured 0 %"
`report.py` "every axis label fits inside the image and clear of the other panel"
`report.py` "every target reads a metric row, a probe or a reading of the radar's own"
`report.py` "every axis carries a margin"
`report.py` "the tables mark a thin sub-characteristic and read an empty one as not measured"
`report.py` "the ISO radar draws a panel per arm with its cost, the target ring, the markers by shape, in both themes"
`report.py` "an axis label reads its share and its move past the margin"
`report.py` "a round after the pilot draws the ISO radar, and the pilot its own"
`report.py` "a later round's report, appendix and images carry the ISO radar" | | FR-12-13 | Self-test | `report.py` "round 5e reads under round 5d's rules, against its own registration, owing its own arms' blocks"
`report.py` "round 5e's contrasts are declared: each map arm against none and every reused arm, and the skill against the file"
`report.py` "H7 to H9 are supported when every row is held or better, refuted by any worse row, reliability's included"
`report.py` "the plain report asks round 5e's questions, not round 5d's"
`report.py` "the plain report qualifies H7's answer with what the map's use says" | -| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, and a redirection to the null device or into another stream is no write"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, a here-document body is no command, and a backslash continues a line"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, a loop's files are read by the body's command that reads its variable, a flag names a search's pattern, and a quoted null device is no write" | +| FR-12-14 | Self-test | `report.py` "the map's use counts each template read or skill loaded, with its turn, and those before the first write"
`report.py` "an arm's map is its skills or its vendored chain, and the bare arm has none"
`report.py` "a shell command that writes counts as the first write, a template off the map is not counted, and a trial that never wrote says nothing about reading up front"
`report.py` "every trial's reads are listed with their turns"
`report.py` "the aggregate keeps each trial's map use"
`report.py` "a shell read of a template counts, a redirection to the null device or into another stream is no write, an edit in place or a download is one, and a brace list expands"
`report.py` "with no trial that wrote, the note beside H7 withholds the reading"
`report.py` "quoted text is no shell operator, and a path a shell command lists or tests is not read"
`report.py` "a shell command is read one simple command at a time: every operand of a reading command counts, and a verb in an argument is no command"
`report.py` "a subagent's reads count at the turn that delegated, and a wildcard stands for every template of the map it matches"
`report.py` "a map no trial read is said to be ignored, not read on demand"
`report.py` "a trial that read and never wrote beside one that wrote and never read shows no on-demand reading"
`report.py` "each subagent is charged to the turn that started it, and a separator inside quotes splits no command"
`report.py` "a read before the writing command of one shell call comes before the write, a here-document body is no command, and a backslash continues a line"
`report.py` "a skills arm's shell write counts, a redirection after a here-document opener stays, a subagent is charged to the delegating message, and a search's pattern is no file"
`report.py` "a subagent pointing at the previous delegation's result is charged to its own delegation, a quoted pattern is one operand, a path follows the call's directory change, a wildcard stands for no slash, a loop's files are read by the body's command that reads its variable, a flag names a search's pattern, and a quoted null device is no write" | | FR-12-15 | Self-test | `report.py` "the screen drops an arm worse than none on a deciding row, ranks the rest by rows better and then by cost, and keeps four"
`report.py` "the screen names the arms round 6 runs"
`report.py` "the screen names no arm for round 6 while the run is short of its K"
`report.py` "a reused arm short of its K holds the screen as a fresh one does"
`report.py` "a deciding row not computed yet holds the screen"
`report.py` "a candidate out on a row read worse holds the screen for no unread row"
`report.py` "the screen ranks what it holds and names no arm for round 6 while a candidate is missing" | ## 13 Records and archive diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 63ef6c7..1e03bb9 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2938,16 +2938,40 @@ def stash(match): return found +# The flags that turn a reading or fetching command into a writing one: +# an edit in place, or a download to a file. +WRITING_FLAGS = {"sed": ("-i", "--in-place"), + "curl": ("-o", "-O", "--output", "--remote-name"), + "wget": ("-O", "--output-document")} + + def first_writing_command(command): """The index of the first simple command that writes a file of the - trial's own, one that redirects into a file or copies, moves or creates - one; None where none does.""" + trial's own, one that redirects into a file, copies, moves or creates + one, edits in place or downloads to a file; None where none does. A + program's own writes, a script's say, are not read.""" for index, (word, text) in enumerate(simple_commands(command)): - if word in WRITE_COMMANDS or ">" in text: + flags = [token for token in words_of(text)[1:] + if token.startswith("-")] + if word in WRITE_COMMANDS or ">" in text or any( + flag.split("=")[0] in WRITING_FLAGS.get(word, ()) + or (word == "sed" and flag.startswith("-i")) + for flag in flags): return index return None +def brace_expanded(token): + """The words a shell makes of a brace list, a{b,c} as ab and ac; the + token itself where it has none.""" + match = re.search(r"\{([^{}]*,[^{}]*)\}", token) + if not match: + return [token] + head, tail = token[:match.start()], token[match.end():] + return [word for part in match.group(1).split(",") + for word in brace_expanded(head + part + tail)] + + def shell_writes(command): """Whether a shell command writes a file of the trial's own.""" return first_writing_command(command) is not None @@ -2965,7 +2989,8 @@ def shell_reads(command, known=()): def noted(tokens, at): """Every template the tokens name, under the vendored copy or relative to the directory moved into, charged to command `at`.""" - for token in tokens: + for token in itertools.chain.from_iterable(map(brace_expanded, + tokens)): matched = TEMPLATE_OPERAND.findall(token) # A path with no vendored copy in it may be relative to the @@ -3646,15 +3671,24 @@ def line(kind, message_id, *blocks): for _, template in reading["uses"]) and summary[0][3] == 1 and summary[0][5] == 0, (reading, summary))) - checks.append(("a shell read of a template counts, and a redirection to " - "the null device or into another stream is no write", + checks.append(("a shell read of a template counts, a redirection to " + "the null device or into another stream is no write, an " + "edit in place or a download is one, and a brace list " + "expands", (6, "templates/backend/http.md") in reading["uses"] and not shell_writes("ls src 2>/dev/null") and not shell_writes("pytest 2>&1 | tail") and not shell_writes("Get-Content x.py > $null") and shell_writes("echo x > x.py") and shell_writes("cat a >> b.txt") - and shell_writes("mkdir src"), + and shell_writes("mkdir src") + and shell_writes("sed -i 's/a/b/' app.py") + and shell_writes("curl -o app.py https://x") + and shell_writes("wget -O app.py https://x") + and not shell_writes("sed -n 1p app.py") + and not shell_writes("curl -s https://x") + and read_names("cat %s/templates/{core,backend}/*.md" % into, + chain) == chain, reading["uses"])) quality = "%s/templates/core/quality.md" % into checks.append(("quoted text is no shell operator, and a path a shell " From 6338b5647907337af53ec368b626b9078c63e320 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Fri, 6 Nov 2026 10:31:09 +0200 Subject: [PATCH 19/21] fix(efficacy): a program's inline code writes, and a writing loop reads one file before it A program run with its code in the command, python -c or a here-document say, counted as no write, so a template read after it was taken as read before any work. The code it carries is now read: a shell's as a shell command, an interpreter's for a call that opens a file to write. A script run from a file stays unread, since the trial wrote that file first. A loop whose body reads a template and writes a file charged every template to the reading command, before the write. Only the first file is read before the body has written; the rest are charged to the loop's end. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xQQ4hBtuBqvpuv9xGj --- tests/efficacy/report.py | 144 +++++++++++++++++++++++++++++++++++---- 1 file changed, 131 insertions(+), 13 deletions(-) diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 1e03bb9..82ee49e 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2944,12 +2944,61 @@ def stash(match): "curl": ("-o", "-O", "--output", "--remote-name"), "wget": ("-O", "--output-document")} +# A program run with its code in the command, as a quoted argument or a +# here-document, writes where the code does: a shell's code is read as a +# shell command of its own, an interpreter's for a call that opens a file +# to write. A script run from a file of the trial's own is not read: the +# trial wrote that file first, and that write was counted. +SHELL_PROGRAMS = ("bash", "sh", "zsh", "pwsh", "powershell", "cmd") +INTERPRETERS = ("python", "python3", "py", "node", "ruby", "perl") +WRITING_CODE = re.compile( + r"write_text\(|write_bytes\(|open\([^)]*,\s*['\"][wax]" + r"|open\([^)]*mode\s*=\s*['\"][wax]|writeFile|appendFile" + r"|createWriteStream|File\.(write|open\([^)]*['\"][wa])" + r"|set-content|out-file|add-content", re.IGNORECASE) + + +def heredoc_bodies(command): + """Each here-document of a shell command, as (its delimiter, its + body).""" + return [(match.group(3), match.group(0)[len(match.group(1)):]) + for match in HEREDOC.finditer(command)] + + +def program_code(text, bodies): + """The code a program run carries: its quoted arguments, and the body + of a here-document the run reads.""" + code = QUOTED.findall(text) + code.extend(body for delimiter, body in bodies + if "<<" in text and delimiter in text) + return "\n".join(code) + + +def unquoted(piece): + """A quoted argument without its outer quotes, one pair only.""" + if len(piece) >= 2 and piece[0] == piece[-1] and piece[0] in "'\"": + return piece[1:-1] + return piece + + +def program_writes(word, text, bodies): + """Whether a program run writes a file in the code it carries.""" + code = program_code(text, bodies) + if not code: + return False + if word in SHELL_PROGRAMS: + return any(first_writing_command(unquoted(piece)) is not None + for piece in code.split("\n")) + return WRITING_CODE.search(code) is not None + def first_writing_command(command): """The index of the first simple command that writes a file of the trial's own, one that redirects into a file, copies, moves or creates - one, edits in place or downloads to a file; None where none does. A - program's own writes, a script's say, are not read.""" + one, edits in place or downloads to a file, or runs code that does; + None where none does.""" + bodies = heredoc_bodies(command) + kept = simple_commands(command, keep_quotes=True) for index, (word, text) in enumerate(simple_commands(command)): flags = [token for token in words_of(text)[1:] if token.startswith("-")] @@ -2958,6 +3007,9 @@ def first_writing_command(command): or (word == "sed" and flag.startswith("-i")) for flag in flags): return index + if word in SHELL_PROGRAMS + INTERPRETERS and program_writes( + word, kept[index][1], bodies): + return index return None @@ -2985,10 +3037,16 @@ def shell_reads(command, known=()): found = [] directory = "" commands = simple_commands(command, keep_quotes=True) + writing = first_writing_command(command) def noted(tokens, at): + """Every template the tokens name, charged to command `at`.""" + found.extend((at, template) for template in named(tokens)) + + def named(tokens): """Every template the tokens name, under the vendored copy or - relative to the directory moved into, charged to command `at`.""" + relative to the directory moved into, in order.""" + templates = [] for token in itertools.chain.from_iterable(map(brace_expanded, tokens)): matched = TEMPLATE_OPERAND.findall(token) @@ -3000,10 +3058,11 @@ def noted(tokens, at): posixpath.join(directory, token.strip("'\"")))) for operand in matched: if any(mark in operand for mark in "*?["): - found.extend((at, template) for template in known - if glob_matches(operand, template)) + templates.extend(template for template in known + if glob_matches(operand, template)) elif operand.endswith(".md"): - found.append((at, operand)) + templates.append(operand) + return templates for index, (word, text) in enumerate(commands): words = [token for token in words_of(text) if not ASSIGNMENT.match(token) @@ -3018,17 +3077,31 @@ def noted(tokens, at): # A loop's files are read by the command of its body, up to `done`, # that reads its variable, and are charged to that command; a body - # that only names them, or reads something else, reads none. + # that only names them, or reads something else, reads none. A body + # that also writes has written by its second iteration, so only the + # first file's read is charged to the reading command: the rest are + # charged to the loop's end, after the write. if word == "for": - variable = re.compile(r"\$\{?%s\b" % re.escape(words[0])) if words else None + variable = (re.compile(r"\$\{?%s\b" % re.escape(words[0])) + if words else None) files = words[words.index("in") + 1:] if "in" in words else [] - for at, (verb, body) in enumerate(commands[index + 1:], + end = next((at for at, (verb, _) in enumerate( + commands[index + 1:], index + 1) if verb == "done"), + len(commands)) + body_writes = writing is not None and index < writing < end + for at, (verb, body) in enumerate(commands[index + 1:end], index + 1): - if verb == "done": - break if verb in READ_COMMANDS and variable \ and variable.search(body): - noted(files, at) + templates = named(files) + if body_writes: + found.extend((at, template) + for template in templates[:1]) + found.extend((end, template) + for template in templates[1:]) + else: + found.extend((at, template) + for template in templates) continue if word not in READ_COMMANDS: continue @@ -3937,7 +4010,8 @@ def stamped(kind, message_id, uuid, *blocks): 'README.md; done' % into, chain) == [] and shell_reads('for f in %s/templates/*/*.md; do echo s > ' 'n.txt; cat "${f}"; done' % into, chain) - == [(2, template) for template in chain] + == [(2, chain[0])] + [(3, template) + for template in chain[1:]] and first_writing_command( 'for f in x; do echo s > n.txt; cat "$f"; done') == 1 and read_names("Select-String -Path %s -Pattern TODO" @@ -3951,6 +4025,50 @@ def stamped(kind, message_id, uuid, *blocks): and read_names("if test -f x; then cat %s; fi" % quality) == ["templates/core/quality.md"], in_a_row)) + checks.append(("a loop whose body writes reads its first file before " + "the write and the rest after it", + shell_reads('for f in %s/templates/*/*.md; do cat "$f"; ' + 'echo done >> notes.txt; done' % into, chain) + == [(1, chain[0])] + [(3, template) + for template in chain[1:]] + and shell_reads('for f in %s/templates/*/*.md; do cat ' + '"$f" >> all.md; done' % into, chain) + == [(1, chain[0])] + [(2, template) + for template in chain[1:]] + and shell_reads('echo s > n.txt; for f in %s/templates/' + '*/*.md; do cat "$f"; done' % into, chain) + == [(2, template) for template in chain] + and shell_reads('for f in %s/templates/*/*.md; do cat ' + '"$f"; done; echo s > n.txt' % into, chain) + == [(1, template) for template in chain], + shell_reads('for f in %s/templates/*/*.md; do cat "$f"; ' + 'echo done >> notes.txt; done' % into, + chain))) + checks.append(("a program run writes where the code it carries does, " + "and a script run from a file is no write of its own", + shell_writes("python -c \"open('x.py', 'w').write('a')\"") + and shell_writes("python3 -c 'from pathlib import Path; " + "Path(\"x\").write_text(\"a\")'") + and shell_writes("py - <<'EOF'\nimport json\n" + "with open('x.json', mode='w') as f:\n" + " json.dump({}, f)\nEOF") + and shell_writes("node -e \"require('fs').writeFileSync(" + "'x.js', 'a')\"") + and shell_writes("bash -c 'echo a > x.txt'") + and shell_writes("pwsh -Command 'Set-Content x.txt a'") + and shell_writes("bash <<'EOF'\nmkdir src\nEOF") + and not shell_writes( + "python -c 'print(open(\"x\").read())'") + and not shell_writes("python -c 'print(1 > 0)'") + and not shell_writes("bash -c 'echo \"a > b\"'") + and not shell_writes("python build.py") + and not shell_writes("py -m pytest -q") + and not shell_writes("node x.js") + and not shell_writes( + "cat <<'EOF'\nopen(\"x\", \"w\")\nEOF") + and first_writing_command( + "cat %s; python -c \"open('x', 'w')\"" % quality) == 1, + None)) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { "uses": [], "first_write": 2, "by_subagent": 0}}) checks.append(("a map no trial read is said to be ignored, not read on " From 82788e8cb43e94695b7e932f89455a8ca5dbf13a Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Fri, 6 Nov 2026 10:42:22 +0200 Subject: [PATCH 20/21] fix(efficacy): a null-device download is no write, an inline shell reads, a flag carries its pattern A download to the null device, a connectivity check say, counted as a write for its -o flag alone. The flag's destination is read, and the null device writes nothing. A shell run with its code in the command, bash -c "cat ..." say, had its reads skipped since the outer word is no reading command. The code's reads are now the command's own, as its writes already were. A search's pattern given in the flag itself, as --regexp=TODO or -eTODO, went unseen, so the file was dropped as the pattern. The attached forms are read as naming the pattern. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xQQ4hBtuBqvpuv9xGj --- tests/efficacy/report.py | 96 +++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 10 deletions(-) diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 82ee49e..8e55028 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -2944,6 +2944,31 @@ def stash(match): "curl": ("-o", "-O", "--output", "--remote-name"), "wget": ("-O", "--output-document")} +# The null device as a download's destination: no file is written. +NULL_DEVICE = re.compile(r"^(/dev/null|\$null|NUL)$", re.IGNORECASE) + + +def writes_by_flag(word, tokens): + """Whether a reading or fetching command's flags make it a writing + one: an edit in place, or a download to a file rather than to the + null device. The flag's value is attached with `=` or is the next + token.""" + names = WRITING_FLAGS.get(word, ()) + for at, token in enumerate(tokens): + if not token.startswith("-"): + continue + if word == "sed" and token.startswith("-i"): + return True + name, _, value = token.partition("=") + if name not in names: + continue + if not value and at + 1 < len(tokens) \ + and not tokens[at + 1].startswith("-"): + value = tokens[at + 1] + if not NULL_DEVICE.match(unquoted(value)): + return True + return False + # A program run with its code in the command, as a quoted argument or a # here-document, writes where the code does: a shell's code is read as a # shell command of its own, an interpreter's for a call that opens a file @@ -3000,12 +3025,8 @@ def first_writing_command(command): bodies = heredoc_bodies(command) kept = simple_commands(command, keep_quotes=True) for index, (word, text) in enumerate(simple_commands(command)): - flags = [token for token in words_of(text)[1:] - if token.startswith("-")] - if word in WRITE_COMMANDS or ">" in text or any( - flag.split("=")[0] in WRITING_FLAGS.get(word, ()) - or (word == "sed" and flag.startswith("-i")) - for flag in flags): + if word in WRITE_COMMANDS or ">" in text or writes_by_flag( + word, words_of(kept[index][1])[1:]): return index if word in SHELL_PROGRAMS + INTERPRETERS and program_writes( word, kept[index][1], bodies): @@ -3037,6 +3058,7 @@ def shell_reads(command, known=()): found = [] directory = "" commands = simple_commands(command, keep_quotes=True) + bodies = heredoc_bodies(command) writing = first_writing_command(command) def noted(tokens, at): @@ -3103,23 +3125,45 @@ def named(tokens): found.extend((at, template) for template in templates) continue + + # A shell run with its code in the command reads where the code + # does, and those reads are this one command's. + if word in SHELL_PROGRAMS: + for piece in program_code(text, bodies).split("\n"): + found.extend((index, template) for _, template + in shell_reads(unquoted(piece), known)) + continue if word not in READ_COMMANDS: continue # A search's or a script's first operand is what to look for, not # a file it reads, unless a flag names it, so it is left out of the - # files. + # files. A flag carries the pattern in itself, as --regexp=TODO, + # -pattern:TODO or -eTODO, or in the token after it. if word in PATTERN_FIRST and operands: flagged = next((at for at, token in enumerate(words[:-1]) if token.lower() in PATTERN_FLAGS), None) - if flagged is None: - words.remove(operands[0]) - else: + if flagged is not None: words.pop(flagged + 1) + elif not any(map(pattern_attached, words)): + words.remove(operands[0]) noted(words, index) return found +def pattern_attached(token): + """Whether a flag carries a search's pattern in itself: --regexp=TODO, + -pattern:TODO or -eTODO.""" + lower = token.lower() + for flag in PATTERN_FLAGS: + if lower.startswith(flag + "=") or lower.startswith(flag + ":"): + return True + if len(flag) == 2 and len(lower) > 2 and lower.startswith(flag) \ + and not lower.startswith("--"): + return True + return False + + def mapped_templates(arm): """What an arm's file points the agent at: the skills it carries, by name, or the templates it vendors, by path; empty for an arm with @@ -4069,6 +4113,38 @@ def stamped(kind, message_id, uuid, *blocks): and first_writing_command( "cat %s; python -c \"open('x', 'w')\"" % quality) == 1, None)) + checks.append(("a download to the null device is no write, an inline " + "shell's reads are the command's, and a flag carries a " + "search's pattern in itself", + not shell_writes("curl -s -o /dev/null https://x") + and not shell_writes("curl -s --output=/dev/null https://x") + and not shell_writes("curl -s -o NUL https://x") + and not shell_writes('curl -s -o "/dev/null" https://x') + and not shell_writes("wget -O $null https://x") + and shell_writes("curl -s -o out.html https://x") + and shell_writes("curl -O https://x/app.py") + and shell_writes("wget -O app.py https://x") + and shell_reads('bash -c "cat %s/templates/*/*.md"' % into, + chain) == [(0, template) for template in chain] + and shell_reads("pwsh -Command 'Get-Content %s'" % quality, + chain) == [(0, "templates/core/quality.md")] + and shell_reads("bash <<'EOF'\ncat %s\nEOF" % quality, + chain) == [(0, "templates/core/quality.md")] + and shell_reads("ls; sh -c 'cat %s'" % quality, chain) + == [(1, "templates/core/quality.md")] + and first_writing_command( + "bash -c 'cat %s; echo a > b'" % quality) == 0 + and read_names("rg --regexp=TODO %s" % quality) + == ["templates/core/quality.md"] + and read_names("grep -eTODO %s" % quality) + == ["templates/core/quality.md"] + and read_names("Select-String -Pattern:TODO %s" % quality) + == ["templates/core/quality.md"] + and read_names("grep --extended-regexp TODO %s" % quality) + == ["templates/core/quality.md"] + and read_names("grep -n TODO %s" % quality) + == ["templates/core/quality.md"], + None)) ignored = map_use_lines({"lazyref-1": {}}, {"lazyref-1": { "uses": [], "first_write": 2, "by_subagent": 0}}) checks.append(("a map no trial read is said to be ignored, not read on " From df7b57f73ae822d8359b801c089babfd5c8cddb2 Mon Sep 17 00:00:00 2001 From: Branimir Georgiev <66906831+braboj@users.noreply.github.com> Date: Fri, 6 Nov 2026 11:30:54 +0200 Subject: [PATCH 21/21] docs(efficacy): the map-use counts approximate what a shell did The use-of-the-map section and round 5e's registration say that a shell call is read from its text, one simple command at a time, so a read or a write the text does not show is not seen, and an inline shell's reads and writes are the one command's. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DpT5xQQ4hBtuBqvpuv9xGj --- docs/rounds/round-5e.md | 11 +++++++---- tests/efficacy/report.py | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/rounds/round-5e.md b/docs/rounds/round-5e.md index ba26834..be211b6 100644 --- a/docs/rounds/round-5e.md +++ b/docs/rounds/round-5e.md @@ -153,10 +153,13 @@ round-6 screen of 13d.9, which round 5e's arms join as candidates. template it matches) or loaded (`lazyskills`, a skill call naming one of the arm's skills), which ones, the turn each happened at, and how many happened before the trial's first write to a file of its own: a write tool's call, or a - shell command that redirects into a file, copies, moves or creates. A trial - that never wrote says nothing about reading up front, a map no trial read was - ignored rather than read on demand, and the note beside H7 says which case - holds. + shell command that redirects into a file, copies, moves or creates. A shell + call is read from its text, one simple command at a time, so the counts + approximate what a shell did: a read or a write its text does not show, + inside a program it ran say, is not seen, and an inline shell's reads and + writes are the one command's. A trial that never wrote says nothing about + reading up front, a map no trial read was ignored rather than read on demand, + and the note beside H7 says which case holds. ### 13e.5 Before the first trial diff --git a/tests/efficacy/report.py b/tests/efficacy/report.py index 8e55028..4b4da35 100644 --- a/tests/efficacy/report.py +++ b/tests/efficacy/report.py @@ -3437,7 +3437,11 @@ def map_use_lines(trials, uses): "From each trial's transcript: the templates it read from the " "vendored copy or loaded as skills, counted once each, the " "turn the first happened at, and how many came before the " - "trial's first write to a file of its own.", "", + "trial's first write to a file of its own. A shell call is " + "read from its text, one simple command at a time, so the " + "counts approximate what a shell did: a read or a write its " + "text does not show, inside a program it ran say, is not " + "seen.", "", "| Arm | Trials | Templates in the map | Read or loaded, mean " "| Before the first write, mean | First at turn, median " "| Read all before writing |",