runner.py¶
acceptance/runner.py
Plan and preflight a run.
check_declaration_applied
None acceptance.runner.check_declaration_applied(Rubric rubric, dict build_meta)
Refuse unless the built index recorded every declared section.
Called by provision, test_a_section_level_option_is_recognised_by_its_section_name, test_no_declaration_needs_no_build_meta, test_unapplied_declaration_is_refused
Calls none
Source · 50 lines
def check_declaration_applied(rubric: Rubric, build_meta: dict) -> None:
"""THE CHECK WHOSE ABSENCE LET A WHOLE PHASE OF WORK GO UNMEASURED. A committed declaration
that never reached the build makes the measured index differ from the intended one, and
every downstream result describes a build nobody chose.
THE SIGNAL IS THE TIER, NOT THE KEY'S PRESENCE. `build_meta` stamps `options.<leaf>.tier` for
EVERY option it knows about, declared or not, and an undeclared one reads `heuristic`. So a
key-presence check passes on a build that ignored the declaration entirely — which is the
exact failure this exists to catch, dressed as a pass.
IT ALSO COMPARES AT THE LEAF, NOT THE SECTION. A rubric declares `preprocessor.predefined`;
the index records `options.predefined`. The first version compared section names to leaf keys
and refused a build whose declaration had landed perfectly. It refused loudly rather than
passing wrongly, which is the only reason that was cheap.
@brief The declaration reached the build.
@return None.
@version 2
"""
if not rubric.declare:
return
rows = build_meta or {}
## EITHER NAME COUNTS, because the pipeline stamps at two different levels and the rubric
## cannot know which. `preprocessor` is the one section whose inner keys are themselves
## options (`options.predefined`); a manifest or document option is stamped under its SECTION
## name (`options.index_scope`, `options.thread_patterns`, `options.locks`). Comparing only
## at the leaf refused a rubric declaring `index_scope: {roots: [...]}` — looking for
## `options.roots.tier`, which no build stamps — on a build whose declaration had landed.
## `locks` passed only because its inner key happens to repeat its section name.
def _applied(names: set[str]) -> bool:
return any(
str(rows.get(f"options.{name}.tier", "")) not in ("", "heuristic") for name in names
)
wanted: set[str] = set()
unapplied: list[str] = []
for section, body in rubric.declare.items():
leaves = set(body) if isinstance(body, dict) else set()
names = {section} | leaves
wanted |= names
if not _applied(names):
unapplied.append(section)
unapplied = sorted(unapplied)
if unapplied:
raise ValueError(
f"the rubric declares {sorted(wanted)} but the built index records no explicit tier "
f"for {unapplied} — the declaration did not reach the build, so the index under test "
f"is not the index the rubric describes"
)1 more lines, not shown
Activity · 15 steps
Flows
check_revision
None acceptance.runner.check_revision(Rubric rubric, Path root)
Refuse unless the checkout is at the rubric's pinned commit.
Called by cmd_generate, provision, test_dirty_tree_is_refused_at_the_pin, test_wrong_revision_is_refused
Calls none
Source · 47 lines
def check_revision(rubric: Rubric, root: Path) -> None:
"""A rubric verified against one tree and run against another grades code the answer never
saw, and every mark's line number is then a claim about a different file.
@brief Checkout is at the pin.
@return None.
@version 1
"""
try:
got = subprocess.run(
["git", "-C", str(root), "rev-parse", "HEAD"],
capture_output=True,
text=True,
timeout=30,
check=False,
)
except (OSError, subprocess.TimeoutExpired) as exc:
raise ValueError(f"{root}: cannot read HEAD: {exc}") from exc
head = got.stdout.strip()
if head != rubric.commit:
raise ValueError(
f"{root} is at {head or '<unknown>'} but the rubric pins {rubric.commit}. "
f"Check out the pin; do not adjust the rubric to match the tree"
)
## HEAD IS NOT THE TREE. A dirty working tree passes a rev-parse check while both arms read
## files the rubric was never verified against — every line number in it is then a claim
## about content nobody checked. A freshly fetched target cannot be dirty; a LOCAL checkout
## reused as a target silently can, which is exactly how two of the reference targets are
## provisioned.
try:
dirty = subprocess.run(
["git", "-C", str(root), "status", "--porcelain", "--untracked-files=no"],
capture_output=True,
text=True,
timeout=60,
check=False,
).stdout.strip()
except (OSError, subprocess.TimeoutExpired) as exc:
raise ValueError(f"{root}: cannot read working-tree state: {exc}") from exc
if dirty:
raise ValueError(
f"{root} is at the pinned commit but its working tree is MODIFIED:\n{dirty}\n"
f"The rubric was verified against the pin, not against these edits. Stash or commit "
f"them; do not measure a tree nobody checked"
)
Activity · 13 steps
Flows
check_tool_tree
None acceptance.runner.check_tool_tree(dict|None identity=None)
Refuse unless the clew under test is a clean tree at a known commit.
Source · 32 lines
def check_tool_tree(identity: dict | None = None) -> None:
"""`check_revision` REFUSES A MODIFIED TARGET; NOTHING REFUSED A MODIFIED CLEW. `clew_dirty`
was recorded in `run.json`, every window and `provision.json`, and read by nothing — so the
1.2.0 grid ran dirty and its RESULTS.md had to concede that `844fee55` does not resolve to the
tree that answered. A recorded flag nobody acts on is a disclosure, not a guard.
UNKNOWN REFUSES TOO. `tool_identity` drops `clew_commit` when git cannot answer, which is right
for a record — absent, never blank — and wrong for a gate. A number that cannot be attributed
to a build of clew is not evidence about clew, so "nobody could check" is refused exactly like
"checked and dirty". Untracked files do not count: the check matches `check_revision`'s
`--untracked-files=no`, since an untracked file is not part of any commit either side names.
@brief The clew tree is clean and named.
@return None.
@version 1
"""
record = tool_identity() if identity is None else identity
commit = record.get("clew_commit")
if not commit:
raise ValueError(
"cannot establish which clew is under test: git could not report its commit or "
"working-tree state. A result that cannot be attributed to a build of clew is not "
"evidence about clew; run the harness from a git checkout of clew"
)
if record.get("clew_dirty", True):
raise ValueError(
f"the clew under test is at {commit} but its working tree is MODIFIED, so that commit "
f"does not describe the code that would answer. Commit or stash the changes; do not "
f"measure a tree nobody can resolve"
)