Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ when:
| FR-02-04 | Self-test | `report.py` "every per-KLOC row carries the static margin"<br>`report.py` "every primary the judge asks for is led with, worded and given its margins" |
| FR-02-05 | Self-test | `report.py` "round 5 holds adherence within one item, 8 pp" |
| FR-02-06 | Self-test | `report.py` "a rise inside the band is held"<br>`report.py` "a rise wholly past the band is worse"<br>`report.py` "one that straddles the band is undecided"<br>`report.py` "a band that holds zero is held"<br>`report.py` "round 5 reads a 10 % rise in app code as held" |
| FR-02-07 | Missing | #109 |
| FR-02-08 | Missing | #109 |
| FR-02-07 | Untestable | No script applies it: from round 5d adherence decides nothing, so the rule binds a person reading an earlier round's report. |
| FR-02-08 | Untestable | No script calls a trim free; a person reading the report applies it, on the held rows the report prints. |
| FR-02-09 | Self-test | `report.py` "from six blocks no interval is called descriptive"<br>`report.py` "a round too small to decide says so in the report and the appendix" |

## 03 Trial count and escalation
Expand Down Expand Up @@ -83,7 +83,7 @@ when:
| FR-05-01 | Self-test | `harness.py` "the scratch home is the home"<br>`harness.py` "the settings file carries the rules and the isolation"<br>`harness.py` "a trial reads the workspace's project settings and no other source" |
| FR-05-02 | Self-test | `harness.py` "ANTHROPIC_API_KEY is removed"<br>`harness.py` "CLAUDECODE is removed"<br>`harness.py` "VIRTUAL_ENV is removed"<br>`harness.py` "the interpreter leaves PATH" |
| FR-05-03 | Self-test | `harness.py` "other trials, their change tasks, home and void are denied"<br>`harness.py` "this repository and the scoring area are denied"<br>`harness.py` "tarballs and run records are denied"<br>`harness.py` "the templates source is denied whenever one is set"<br>`harness.py` "the trial's own workspace is not denied" |
| FR-05-04 | Missing | #109 |
| FR-05-04 | Self-test | `harness.py` "a trial may not fetch or search the web" |
| FR-05-05 | Self-test | `harness.py` "a planted Git helper answers outside a trial"<br>`harness.py` "it does not answer inside one" |
| FR-05-06 | Self-test | `harness.py` "every kill by name meets a deny rule" |
| FR-05-07 | Self-test | `harness.py` "every call reaching past the trial is flagged"<br>`harness.py` "the root, another pen and a climb out of the pen are flagged"<br>`harness.py` "a fetch of the templates is flagged, and only that"<br>`harness.py` "a kill by name that ran, or never answered, is a hit"<br>`harness.py` "a scorable trial with a reach becomes reached"<br>`harness.py` "the trial's own paths are not flagged, a pip extra included" |
Expand All @@ -106,18 +106,18 @@ when:
| -- | ---- | ---------- |
| FR-07-01 | Self-test | `score.py` "the battery installs from a lock it resolved" |
| FR-07-02 | Self-test | `score.py` "only the tools reach the lock"<br>`score.py` "the lock carries none of the trial's dependencies" |
| FR-07-03 | Missing | #109 |
| FR-07-03 | Self-test | `score.py` "ruff and mypy take the harness's configuration, not the trial's" |
| FR-07-04 | Self-test | `score.py` "a scoring environment runs the spec's Python"<br>`score.py` "no Python at the spec's version refuses to score"<br>`score.py` "a score on another Python refuses the root"<br>`report.py` "scores on two Pythons are refused" |
| FR-07-05 | Self-test | `score.py` "the planted package is discovered"<br>`score.py` "an empty tree yields no roots" |
| FR-07-06 | Self-test | `score.py` "every extra and every group requirement is installed" |
| FR-07-07 | Missing | #109 |
| FR-07-07 | Self-test | `score.py` "a test dependency the lock refuses leaves coverage missing" |

## 08 Flexibility

| ID | Kind | Checked by |
| -- | ---- | ---------- |
| FR-08-01 | Self-test | `judge.py` "the trial's code reaches the bundle"<br>`judge.py` "scoring's output and the environment's stay out of the bundle"<br>`judge.py` "the skills arm's skills stay out of the bundle" |
| FR-08-02 | Missing | #109 |
| FR-08-02 | Self-test | `judge.py` "one seed gives one judging order"<br>`judge.py` "the order is not the arms' order, and holds every repeat"<br>`judge.py` "the unblinding map is written outside the bundles the judge reads" |
| FR-08-03 | Self-test | `judge.py` "a path naming the trial is a leak"<br>`judge.py` "an escaped path naming the trial is a leak"<br>`judge.py` "a leak in a directory the copy skips is found"<br>`judge.py` "a bundle holding neither has no leak"<br>`generate_arm.py` "the leak scan reports a planted token and passes clean text" |

## 09 Scoring
Expand All @@ -128,7 +128,7 @@ when:
| FR-09-02 | Self-test | `score.py` "an application that seeds on start, and has no default secret, boots under scoring"<br>`score.py` "a build capped below Python 3.13 installs" |
| FR-09-03 | Self-test | `score.py` "an hx-* error is set aside and another counts" |
| FR-09-04 | Self-test | `score.py` "app code is the app's Python and templates, not its tests"<br>`score.py` "test code is a tests directory or a pytest name, anywhere"<br>`score.py` "docs and configuration count toward no size"<br>`score.py` "committed bytecode and a database are artifacts nobody asked for" |
| FR-09-05 | Missing | #109 |
| FR-09-05 | Self-test | `score.py` "the checklist holds 13 items and reads none as any arm" |
| FR-09-06 | Missing | #109 |
| FR-09-07 | Self-test | `score.py` "churn counts an edit and a new file, not an environment"<br>`score.py` "the churn plant landed" |
| FR-09-08 | Self-test | `harness.py` "the change prompt names the API and fields the grader drives"<br>`harness.py` "the change prompt is read whole from its file" |
Expand All @@ -145,7 +145,7 @@ when:
| FR-10-05 | Self-test | `report.py` "a direction the other judge reverses loses its verdict"<br>`report.py` "a direction both judges read keeps its verdict"<br>`report.py` "a contrast the other judge did not read keeps its verdict"<br>`report.py` "the rounds' own judge is caught posing as the other" |
| FR-10-06 | Self-test | `report.py` "the judge is checked by its evidence, not a person" |
| FR-10-07 | Self-test | `control/control.py` "the domain imports flask"<br>`control/control.py` "ValidationError derives from TariffError"<br>`control/control.py` "the secret key is a literal"<br>`control/control.py` "customer data is written to the log" |
| FR-10-08 | Missing | #109 |
| FR-10-08 | Self-test | `control/control.py` "a base archive with another sha256 is refused" |
| FR-10-09 | Untestable | A judged control root is read by hand, and [validation](validation.md) records each reading. |

## 11 Security and data protection
Expand Down Expand Up @@ -179,7 +179,7 @@ when:
| ID | Kind | Checked by |
| -- | ---- | ---------- |
| FR-13-01 | Self-test | `harness.py` "the record is written as every trial starts and ends"<br>`harness.py` "every trial records the CLI's version, read as it starts" |
| FR-13-02 | Missing | #109 |
| FR-13-02 | Self-test | `generate_arm.py` "every generated arm's file has its generation record beside it" |
| FR-13-03 | Self-test | `archive.py` "readings, judgings, map and lock come; bundles do not"<br>`archive.py` "the original tarball's hash is recorded"<br>`archive.py` "the revisions are recorded"<br>`archive.py` "a reading changed in the archive fails the verify" |
| FR-13-04 | Self-test | `archive.py` "a reading changed after the stamp is a problem"<br>`archive.py` "the report refuses docs/audits/ without a current stamp"<br>`report.py` "a report into a templates source's docs/audits needs the stamp" |
| FR-13-05 | Self-test | `archive.py` "the restored root reads as the original does"<br>`archive.py` "a restored record points at the restored tarball and void"<br>`archive.py` "a restored transcript keeps its time" |
Expand Down
11 changes: 11 additions & 0 deletions tests/efficacy/control/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,17 @@ def main(argv):
try:
made = build(os.path.join(scratch, "run"))
rows = landings(made)

# A base whose content changed would compare a later run against
# a different application, so any digest but the pinned one stops
# the build.
try:
pinned(BASE, "0" * 64)
refused = False
except ControlError:
refused = True
rows.append(("a base archive with another sha256 is refused",
{}, refused))
finally:
shutil.rmtree(scratch, ignore_errors=True)
elif options.root:
Expand Down
16 changes: 16 additions & 0 deletions tests/efficacy/generate_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,22 @@ def self_test():
print("FAIL: the budget clause is not in short's instruction alone")
return 1
print("the budget is stated in short's instruction and no other")

# A generated file without its record cannot say which source, model and
# ref made it, so the report could not cite how its arm was built.
for arm in GENERATED:
path = record_path(arm)
if not os.path.isfile(output_path(arm)):
continue
try:
with io.open(path, encoding="utf-8") as handle:
record = json.load(handle)
except (OSError, ValueError):
record = {}
if record.get("arm") != arm or record.get("outcome") != "generated":
print("FAIL: %s has no generation record beside it" % arm)
return 1
print("every generated arm's file has its generation record beside it")
return 0


Expand Down
9 changes: 8 additions & 1 deletion tests/efficacy/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -3472,7 +3472,14 @@ def round5_checks():
checks.append(("a trial reads the workspace's project settings and no "
"other source",
argv[argv.index("--setting-sources") + 1] == "project"))
listed = "review\n- write-tests\n`add-check`\ndataviz"

# The web tools go after the flag that names them; anything else there
# would be read as one more tool to refuse, or as the prompt.
refused = (argv[argv.index("--disallowed-tools") + 1:][:2]
if "--disallowed-tools" in argv else [])
checks.append(("a trial may not fetch or search the web",
sorted(refused) == ["WebFetch", "WebSearch"]))
listed ="review\n- write-tests\n`add-check`\ndataviz"
checks.append(("the skills probe finds a listed kind and names a missing "
"one",
missing_skills(listed, ["add-check", "review",
Expand Down
50 changes: 44 additions & 6 deletions tests/efficacy/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ def highest_label(judging):
match = re.match(r"T(\d+)\.json$", os.path.basename(file))
if match:
numbers.append(int(match.group(1)))
path = os.path.join(judging, "map.json")
path = unblinding_map(judging)
if os.path.isfile(path):
with io.open(path, encoding="utf-8") as handle:
for label in json.load(handle).get("blind", {}).values():
Expand All @@ -749,6 +749,24 @@ def highest_label(judging):
return max(numbers)


# Where the bundles go, under the judging area; the judge is pointed here and
# nowhere else.
BUNDLES = "bundles"


def judging_order(wanted, owed, seed):
"""Every judging owed, in an order the seed alone decides."""
shuffler = random.Random(seed)
order = [name for name in wanted for _ in range(owed[name])]
shuffler.shuffle(order)
return order


def unblinding_map(judging):
"""Where the map from blind labels back to trials is kept."""
return os.path.join(judging, "map.json")


def blind_labels(order, after):
"""A blind label per trial in `order`, numbered from `after` + 1, so a
root holding an earlier round's judgings never reuses one of theirs."""
Expand Down Expand Up @@ -841,7 +859,7 @@ def judge_trials(options, available, wanted):
lib.print_verdict(False, "no trial judged")
return 2

bundles = os.path.join(judging, "bundles")
bundles = os.path.join(judging, BUNDLES)
os.makedirs(bundles, exist_ok=True)

# Shuffled with a recorded seed, so the order is reproducible and is not
Expand All @@ -852,9 +870,7 @@ def judge_trials(options, available, wanted):
# list is shuffled together, so its repeats are spread through the run
# rather than made back to back. Each repeat is a separate blind label: it
# is a separate reading of the same tree, and the report means them.
shuffler = random.Random(options.seed)
order = [name for name in wanted for _ in range(owed[name])]
shuffler.shuffle(order)
order = judging_order(wanted, owed, options.seed)
labels = blind_labels(range(len(order)), highest_label(judging))
repeats = {}

Expand Down Expand Up @@ -911,7 +927,7 @@ def judge_trials(options, available, wanted):

# The unblinding map, written last and kept out of the bundles directory
# the judge was pointed at. An earlier round's entries stay in it.
path = os.path.join(judging, "map.json")
path = unblinding_map(judging)
mapping = {"seed": options.seed, "blind": {}, "repeats": {}}
if os.path.isfile(path):
with io.open(path, encoding="utf-8") as handle:
Expand Down Expand Up @@ -1208,6 +1224,27 @@ def refuses(call):
return checks


def order_checks(scratch):
"""The judging order is the seed's alone, and the key stays out of the
judge's reach."""
wanted = ["hybrid-1", "inline-1", "none-1", "reference-1", "skills-1"]
owed = {name: 3 for name in wanted}
first = judging_order(wanted, owed, 20260912)
judging = os.path.join(scratch, "order", "judge")
bundles = os.path.abspath(os.path.join(judging, BUNDLES))
return [
("one seed gives one judging order",
first == judging_order(wanted, owed, 20260912)
and first != judging_order(wanted, owed, 1)),
("the order is not the arms' order, and holds every repeat",
first != sorted(first) and sorted(first) == sorted(
name for name in wanted for _ in range(3))),
("the unblinding map is written outside the bundles the judge reads",
not os.path.abspath(unblinding_map(judging)).startswith(
bundles + os.sep)),
]


def label_checks(scratch):
"""Blind labels continue past an earlier round's, and a judged trial is
known by its canonical name."""
Expand Down Expand Up @@ -1333,6 +1370,7 @@ def self_test():
checks = bundle_checks(scratch)
checks.extend(spec_checks(scratch))
checks.extend(label_checks(scratch))
checks.extend(order_checks(scratch))
checks.extend(launch_checks(scratch))
checks.extend(backend_checks(scratch))
checks.extend(claim_checks(scratch))
Expand Down
73 changes: 72 additions & 1 deletion tests/efficacy/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,75 @@ def boot_checks(scratch, venv):
'''


def ruler_checks(scratch):
"""Prove the rulers take the harness's configuration, and that a test
dependency the lock will not admit leaves coverage missing.

The tools are stubbed: what is checked is the command each is given and
what is recorded when an install fails, not the tools themselves.
"""
called = []

def stub_module(venv, module, args, cwd=None, timeout=TOOL_TIMEOUT):
called.append((module, list(args)))
return {"failed": "stubbed", "status": 1, "stdout": "", "stderr": "",
"argv": [module] + list(args)}

def refusing_pip(venv, *args, **kwargs):
return {"failed": None, "status": 1, "stdout": "",
"stderr": "ResolutionImpossible: ruff conflicts with the lock",
"argv": ["pip"] + list(args)}

planted = os.path.join(scratch, "conflict")
os.makedirs(os.path.join(planted, "tests"))
with io.open(os.path.join(planted, "pyproject.toml"), "w",
encoding="utf-8") as handle:
handle.write(PLANTED_TEST_DEPENDENCIES)
saved = {name: globals()[name] for name in ("run_module", "pip")}
globals().update(run_module=stub_module, pip=refusing_pip)
try:
roots = [os.path.join(planted, "pkg")]
ruff_findings(planted, planted, roots, {})
ruff_format(planted, planted, roots, {})
mypy_errors(planted, planted, roots, {})
conflicted = own_test_coverage(planted, planted, roots, {})
finally:
globals().update(saved)
ruff_args = [args for module, args in called if module == "ruff"]
mypy_args = [args for module, args in called if module == "mypy"]
return [
("ruff and mypy take the harness's configuration, not the trial's",
len(ruff_args) == 2 and len(mypy_args) == 1
and all(RUFF_CONFIG in args for args in ruff_args)
and MYPY_CONFIG in mypy_args[0]),
("a test dependency the lock refuses leaves coverage missing",
conflicted.get("value") is None
and "would not install beside the scoring lock"
in (conflicted.get("missing") or "")
and "ResolutionImpossible" in (conflicted.get("missing") or "")),
]


def adherence_checks(scratch):
"""Prove the checklist holds its 13 items and reads the bare arm as it
reads any other."""
planted = os.path.join(scratch, "adherence")
os.makedirs(planted)
scores = {"ruff": measured(0), "mypy": measured(0),
"ruff_format": measured(0), "coverage": measured({"line": 85}),
"complexity": measured({"over_15": 0}),
"discovery": {"roots": [os.path.join(planted, "src", "pkg")]},
"structure": measured({"exception_bases": ["PkgError"],
"print_calls": [], "citations": [],
"logging": {"used": True,
"null_handler": True}})}
read = {arm: adherence(planted, dict(scores, arm=arm))
for arm in ("none", "hybrid")}
return [("the checklist holds 13 items and reads none as any arm",
read["none"].get("total_items") == 13
and read["none"] == read["hybrid"])]


def coverage_checks(scratch):
"""Prove the coverage run installs what the trial's tests declare.

Expand Down Expand Up @@ -1920,7 +1989,9 @@ def self_test():
+ lock_checks() + html_checks() + readonly_checks(scratch)
+ lock_source_checks(scratch) + unrun_checks(scratch)
+ claim_checks(scratch) + security_checks(scratch)
+ coverage_checks(scratch) + python_files_checks(scratch)
+ coverage_checks(scratch) + ruler_checks(scratch)
+ adherence_checks(scratch)
+ python_files_checks(scratch)
+ scope_checks(scratch))
dropped = create_venv(os.path.join(scratch, "dropped"))
drop_venv(dropped)
Expand Down
Loading