diff --git a/.github/workflows/self-tests.yml b/.github/workflows/self-tests.yml
index 1a949a5..7a5dde3 100644
--- a/.github/workflows/self-tests.yml
+++ b/.github/workflows/self-tests.yml
@@ -67,17 +67,26 @@ jobs:
- name: Install pyflakes
run: python -m pip install --disable-pip-version-check pyflakes
+ # Each self-test's output is kept, so the trace below can look up the
+ # labels the requirements name without running every self-test again.
- name: Run every self-test
working-directory: solid-ai-benchmark
run: |
- set -e
+ set -eo pipefail
+ outputs="$RUNNER_TEMP/self-tests"
+ mkdir -p "$outputs"
for module in harness generate_arm score judge report archive reuse \
- security control/control; do
+ progress security control/control trace; do
echo "::group::$module"
- python "tests/efficacy/$module.py" --self-test
+ python "tests/efficacy/$module.py" --self-test \
+ | tee "$outputs/$(basename "$module").txt"
echo "::endgroup::"
done
+ - name: Trace the requirements to the self-tests
+ working-directory: solid-ai-benchmark
+ run: python tests/efficacy/trace.py --outputs "$RUNNER_TEMP/self-tests"
+
- name: Pyflakes
working-directory: solid-ai-benchmark
run: python -m pyflakes tests
diff --git a/AGENTS.md b/AGENTS.md
index 4ec07df..41bc83c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -21,9 +21,15 @@ py tests/efficacy/reuse.py --self-test
py tests/efficacy/progress.py --self-test
py tests/efficacy/security.py --self-test
py tests/efficacy/control/control.py --self-test
+py tests/efficacy/trace.py --self-test
+py tests/efficacy/trace.py
py -m pyflakes tests
```
+`trace.py` runs every self-test and fails on a rule in
+[`docs/requirements.md`](docs/requirements.md) whose checks no self-test
+prints. A new rule gets a row there, and a new check its label.
+
A self-test makes no model call and runs no trial. Running a trial or a
judging spends a plan's limit, so ask first.
diff --git a/docs/architecture/08-crosscutting-concepts.md b/docs/architecture/08-crosscutting-concepts.md
index 85596f9..a5f28e2 100644
--- a/docs/architecture/08-crosscutting-concepts.md
+++ b/docs/architecture/08-crosscutting-concepts.md
@@ -1,176 +1,238 @@
# 8. Crosscutting concepts
-The ideas that more than one building block applies. Each states the rule
-and where it lives in the code.
+The rules that more than one script follows, and why each exists.
+
+- Each rule has an ID and a check behind it in the
+ [requirements](../requirements.md). This chapter gives the reasons.
+- A round's registration under `docs/rounds/` can add rules or tighten these.
+ Round 5d, for example, registers its own verdict rules and radar.
+- Some rules start at a given round. Earlier rounds re-read the way they were
+ reported, so the report keeps their old rules too.
+
+Where each concept acts on a trial:
+
+```mermaid
+flowchart LR
+ reg["Register the round
8.1"] --> run["Run the trials
8.2 isolation"]
+ run --> score["Score
8.3 missing, 8.4 one ruler, 8.6.1-8.6.4"]
+ score --> probe["Probe
8.6.8"]
+ probe --> judge["Judge
8.5 blind, 8.6.5-8.6.7"]
+ judge --> arch["Archive
8.8"]
+ arch --> rep["Report
8.1, 8.7"]
+```
## 8.1 The registered rules
-Fixed before the first run, so no metric or threshold can be chosen after
-the numbers are seen.
+Every rule for reading a result is fixed before the first trial. Nobody can
+then choose a metric or a threshold after seeing the numbers.
### 8.1.1 Rules, fixed before the first run
-The question, the metrics and the rule for reading a result are written down
-before any trial runs. Nobody can then pick the metric or the threshold that
-makes the templates look good after seeing the numbers.
+**A round's registration comes before its first trial.** From round 5 on, the
+report refuses a round when:
-From round 5 on, the report holds a round to that order. It refuses a round
-whose registration under `docs/rounds/`:
+- its registration landed on `main` after the first trial started
+ - it reads `main`'s first-parent line, so a merge counts at the merge
+- its registration differs from `main`'s copy, or has uncommitted changes
+- a trial built from a spec or prompt other than the registered one, by
+ content
+- a trial with something to score records no spec or no prompt
-- landed on `main` after the round's first trial started, read on `main`'s
- first-parent line so a merge counts at the merge
-- differs from `main`'s copy, or has changes not yet committed
-- holds a trial that built from a spec other than the one it registers, by
- content, or a trial with something to score that records no spec
+The harness checks the spec before every trial too. An edit made mid-run
+refuses the trials after it, instead of building them.
-The harness checks the spec too, before every trial, so an edit made while a
-run is under way refuses the trials after it rather than building them.
+Two details keep the order honest on any machine:
-Trials record their start with its UTC offset, so the order holds on any
-machine; a start with no offset is refused rather than guessed. A
-fast-forward pushed from a clone keeps its branch commit's date, so
-registrations land through a pull request's squash or rebase merge.
+- A trial records its start with its UTC offset. A start with no offset is
+ refused, not guessed.
+- Registrations land through a pull request's squash or rebase merge. A
+ fast-forward pushed from a clone keeps its branch commit's older date.
-| Setting | Value | Why |
-|---|---|---|
-| Unit compared | The difference between two arms' trials in the same block: `full-1` minus `none-1` | The arms in a block meet the same model on the same day |
-| Result | The mean of the K differences, per metric, per contrast | — |
-| Interval | Bias-corrected and accelerated bootstrap over the K differences: 10,000 resamples, 95 %, seed recorded | Shows how steady the effect is |
-| Direction | Declared per metric (section 8.7.2) | Half the metrics improve downward |
-| Verdict | **Better**: interval wholly on the improving side of zero. **Worse**: wholly on the other side. **No improvement shown**: contains zero | "No improvement shown" does not mean "equal"; section 8.1.2 covers that |
+**How a result is read.**
-### 8.1.2 Rules for claiming "nothing got worse"
+| Step | Rule |
+|---|---|
+| Unit | One block's difference between two arms, such as `hand-1` minus `none-1`. Arms in a block meet the same model on the same day |
+| Result | The mean of the K differences, per metric and contrast |
+| Interval | 95 % bias-corrected and accelerated bootstrap over the K differences, 10,000 resamples, seed recorded |
+| Direction | Declared per metric (8.7.2), since half the metrics improve downward |
-A trim is a change that shortens the templates. A trim may claim a metric
-held only when the whole interval of its change lies inside the margin
-below. "No improvement shown" does not mean "no worse".
-
-| Metric | Unit | Margin: largest tolerated loss | Smallest change that matters |
-|---|---|---|---|
-| Hidden-test pass rate | percentage points | 2 | 5 |
-| Adherence checklist | percentage points | 5 | 10 |
-| Primary judge scores, 1–5 | scale points | 0.3 | 0.5 |
-| Static-analysis counts per 1,000 lines | relative % | 10 | 25 |
-| Change-task churn, files and lines | relative % | 15 | 30 |
-| Security probe pass rate (from round 3) | percentage points | 2 | 9 |
-| Data-protection probe pass rate (from round 3) | percentage points | 10 | 30 |
-| App code, lines and files (from round 5) | relative % | 20 | 40 |
-
-- An adherence gain counts only if pass rate held. Following rules while
- breaking the app is not an improvement.
-- A trim is free only if every metric held.
-- The report shows every metric. Its summary score decides nothing.
-- Round 5 holds adherence within 8 pp, one checklist item of 13, as [its
- registration](../rounds/round-5.md) states.
+The verdict depends only on where the interval sits against zero:
-This is a non-inferiority test, as used in drug trials to show a new
-treatment is no worse than the standard one by more than a set margin. Below
-K = 6 it describes the result; it does not prove it.
+```text
+ worse side 0 improving side
+ |
+ Better | [=======] wholly on the improving side
+ Worse [=======] | wholly on the worse side
+ No improvement [====|====] contains zero
+ shown
+```
-### 8.1.3 Few trials, and the one escalation
+"No improvement shown" does not mean "equal". Claiming that needs 8.1.2.
-**Three trials are a description, not proof.**
+### 8.1.2 Rules for claiming "nothing got worse"
-- Three differences give the bootstrap only 27 distinct resamples.
-- No arrangement of three trials reaches conventional significance.
-- The report says so beside every interval, not in a footnote.
+A trim shortens the templates. It may claim a metric **held** only when the
+whole interval of the change lies inside the margin: the largest loss the
+round tolerates.
-**One escalation to K = 5 is allowed, once, under fixed conditions.**
+```text
+ -margin 0
+ | |
+ Held | [=======] | whole interval above -margin
+ Not shown held [=|=====] | reaches past the margin
+```
-- It is owed where a primary dimension's interval contains zero while its
- mean difference exceeds the smallest change that matters (section 8.1.2).
-- Any contrast can trigger it, and the effect counts in either direction.
-- Two further blocks run. The report prints the K = 3 and K = 5 results side
- by side.
-- K never exceeds 5. A second inconclusive result is reported as
- inconclusive.
-- The report computes whether the escalation is owed.
+| Metric | Unit | Margin | Smallest change that matters | Since |
+|---|---|---|---|---|
+| Hidden-test pass rate | pp | 2 | 5 | round 1 |
+| Adherence checklist | pp | 5 | 10 | round 1 |
+| Primary judge scores, 1–5 | points | 0.3 | 0.5 | round 1 |
+| Static-analysis counts per 1,000 lines | relative % | 10 | 25 | round 1 |
+| Change-task churn, files and lines | relative % | 15 | 30 | round 1 |
+| Security probe pass rate | pp | 2 | 9 | round 3 |
+| Data-protection probe pass rate | pp | 10 | 30 | round 3 |
+| App code, lines and files | relative % | 20 | 40 | round 5 |
+
+- An adherence gain counts only if the pass rate held. Following rules while
+ breaking the app is no improvement.
+- A trim is free only if every metric held.
+- The report shows every metric. Its summary score decides nothing.
+- Round 5 holds adherence within 8 pp, one checklist item of 13, as
+ [its registration](../rounds/round-5.md) states.
-Why: sampling until an interval clears zero is the failure this bound
-prevents.
+This is a non-inferiority test, the kind drug trials use to show a new
+treatment is no worse than the standard by more than a set margin. Below
+K = 6 it describes the result and proves nothing.
-**Or a round registers a larger K, with no escalation.**
+### 8.1.3 Few trials, and the one escalation
-- K is sized before the first trial, from the per-trial noise of earlier
- rounds.
-- No block is added once the results are seen. A run short of K is part-run,
- and none of its verdicts is the round's.
-- Round 5 registers K = 15 ([its registration](../rounds/round-5.md), 13.5).
+**Three trials describe; they do not prove.** Three differences give the
+bootstrap only 27 distinct resamples, and no arrangement of three reaches
+conventional significance. The report says so beside every interval.
+
+A round sizes K one of two ways:
+
+```mermaid
+flowchart TD
+ k3["Registered at K = 3"] --> owed{"Escalation owed?"}
+ owed -- no --> done3["Report at K = 3"]
+ owed -- yes --> esc["Run two more blocks, once"]
+ esc --> done5["Report K = 3 and K = 5 side by side"]
+ big["Registered at a larger K"] --> full{"All K blocks run?"}
+ full -- yes --> doneK["Report the round"]
+ full -- no --> part["Part-run: no verdict is the round's"]
+```
+
+- **Owed** where a primary's interval contains zero while its mean exceeds
+ the smallest change that matters (8.1.2).
+- A result still unsettled at K = 5 is reported as inconclusive.
+- Any contrast can owe it, for an effect in either direction. The report
+ computes whether it is owed.
+- A larger K is sized before the first trial, from earlier rounds' noise.
+- K never exceeds 5 under escalation. Sampling until an interval clears zero
+ is the failure this bound prevents.
+- A round with a larger K adds no block once results are seen. Round 5
+ registers K = 15 ([its registration](../rounds/round-5.md), 13.5).
### 8.1.4 Failed and lost trials
-**A failed trial is scored as it stands and never re-run.**
-
-- A trial that produced no installable workspace scores zero on task
- success.
-- Its quality metrics are recorded as missing, never filled in.
-
-Why: re-running one arm's failures quietly improves that arm.
-
-**A lost trial is re-run once, in its own place in the order.**
+A **failed** trial is the agent's doing. A **lost** trial is the provider's.
-- A trial is lost when the CLI ends it with any error other than the budget
- cap: a usage limit, a rate limit, a crash, or no result at all.
-- Its partial workspace is kept under the run's `void/` directory and never
- scored.
-- A second loss of the same trial stops the run.
-- A trial ended by the budget cap or the timeout is not lost. Both are
- bounds [ch. 6.1](06-runtime-view.md) sets, and the trial is scored as it stands.
+| How the trial ended | Kind | What happens |
+|---|---|---|
+| Completed | — | Scored |
+| Budget cap or timeout | Bound (ch. [6.1](06-runtime-view.md)) | Scored as it stands |
+| No installable workspace | Failed | Task success 0, quality metrics missing, never re-run |
+| Usage limit, rate limit, crash, or no result | Lost | Re-run once, in its own place in the order |
+| Lost a second time | Lost | The run stops |
-Why: the provider cut it, not the agent.
+- Re-running one arm's failures would quietly improve that arm.
+- A lost trial's partial workspace is kept under the run's `void/` directory
+ and never scored.
## 8.2 Isolation in layers
-No single fence stops every route out of a workspace, so the harness
-stacks them and records what each caught.
+No single fence stops every route out of a workspace. The harness stacks
+several and records what each caught.
| Layer | Stops | Cannot stop |
-| ----- | ----- | ----------- |
-| Scratch home and minimal settings | The owner's global `CLAUDE.md`, hooks, memory and MCP | |
+|---|---|---|
+| Scratch home, minimal settings | The owner's global `CLAUDE.md`, hooks, memory and MCP | |
| Cleaned environment | The launching session's variables, interpreter and keys | |
-| Deny rules on the file tools | Read and Edit outside the trial's own workspace | The shell, whose paths a prefix rule cannot see |
+| Deny rules on file tools | Read and Edit outside the trial's workspace | The shell, whose paths a prefix rule cannot see |
| Web tools disallowed | Fetching a page | `curl` or `git clone` in the shell |
| Git credential helpers cleared | An authenticated clone of the hidden suite | |
| Process-stop commands denied | Stopping the harness by name | Stopping by PID or port |
-| Transcript scan | Any tool call that names a forbidden path or repository, after the fact | A call the transcript does not record |
+| Transcript scan | Any tool call naming a forbidden path or repository | A call the transcript does not record |
-The scan is the backstop: a hit voids the trial and re-runs it once, and
-the report scans again under the current rule.
+The transcript scan is the backstop. A hit voids the trial and re-runs it
+once, and the report scans again under the current rule.
## 8.3 Missing is not zero
-A tool that scanned nothing, failed or timed out records its metric as
-missing, with the reason. A grader's skipped check is not a passed one. A
-probe the trial keeps from running is lost. A probe the harness could not
-run leaves the rate missing. Each script's self test plants the case and
-fails if it reads as zero.
+A zero has to mean "measured, and none found". So:
+
+| Case | Recorded as |
+|---|---|
+| A tool scanned nothing, failed or timed out | Missing, with the reason |
+| A grader skipped a check | Not passed |
+| The trial keeps a probe from running | Lost: the probe fails |
+| The harness could not run a probe | The rate is missing |
+
+Each script's self-test plants these cases and fails if one reads as zero.
## 8.4 One ruler
-The first trial scored resolves `scoring-requirements.txt` and freezes it
-to `tool-lock.txt`. Every later trial installs from that lock. The lock
-leaves out anything local, editable or named like the package under score,
-so one trial's code never installs over another's. `toolconfig/` holds the
-only configuration the tools run under.
+Every trial is measured with the same tool versions.
+
+```mermaid
+flowchart LR
+ req["scoring-requirements.txt"] -- "first trial scored" --> lock["tool-lock.txt"]
+ lock -- "every later trial" --> env["Scoring environment"]
+ cfg["toolconfig/"] --> env
+```
+
+- The lock leaves out anything local, editable, or named like the package
+ under score, so one trial's code never installs over another's.
+- `toolconfig/` is the only configuration the tools run under.
+- Every build is scored on the spec's Python. The report refuses a round
+ whose scores ran on two.
## 8.5 Blindness
-The judge reads a bundle with the context file, the vendored templates,
-condition markers and scoring's own output removed, in an order shuffled
-at a recorded seed. The unblinding map is written where the judge cannot
-reach it. A leak scan reads every file in the bundle, and a bundle that
-still names its arm is refused.
+The judge must not know which arm wrote a tree.
+
+```mermaid
+flowchart LR
+ strip["Strip context file,
templates, markers,
scoring output"]
+ tree["Trial tree"] --> strip
+ strip --> scan{"Leak scan:
names its arm?"}
+ scan -- yes --> refuse["Refused"]
+ scan -- no --> order["Shuffle, at a recorded seed"]
+ order --> judge["Judge"]
+ order -. "unblinding map" .-> map[("Kept out of
the judge's reach")]
+```
## 8.6 Scoring
-Each frozen trial goes through the same pipeline:
+Each frozen trial goes through the same pipeline. The deterministic stages
+run on every trial; the judge comes last.
-### 8.6.1 Task success and the backbone
+```mermaid
+flowchart LR
+ t["Frozen trial"] --> s["Task success
and backbone
8.6.1"]
+ s --> q["Code quality
8.6.2"]
+ q --> d["Design structure
8.6.3"]
+ d --> c["Change task
8.6.4"]
+ c --> p["Security probes
8.6.8"]
+ p --> j["Judge
8.6.5-8.6.7"]
+```
-These run on every trial, deterministically.
+### 8.6.1 Task success and the backbone
**Task success** is the hidden suite's pass rate. The suite lives in a
-private repository and is cloned only at scoring time, never into a
+private repository. It is cloned only at scoring time, never into a
workspace. It covers:
- the Python API: rule precedence, stacking, tier boundaries, rounding to
@@ -182,264 +244,223 @@ workspace. It covers:
The rest of the backbone:
-- **Install:** `pip install .` in a clean virtualenv, `import tariff`, and
- the app boots and serves `/`.
-- **Web quality:**
- - accessibility: axe-core WCAG 2.1 AA violations
- - HTML validity, less errors on HTMX's `hx-*` attributes, which the spec
- requires and the HTML standard lacks
- - an XSS probe and a CSRF probe
- - the invoice builder's response size and request count
-- **Adherence:** the share of a fixed checklist of 13 items passed.
- - Tools: `ruff` clean, `ruff format` clean, `mypy --strict` clean,
- coverage ≥ 80 %, cognitive complexity ≤ 15.
- - Structure: a `src/` layout, one error hierarchy, a `NullHandler`.
- - Hygiene: no `print` in library code, no citations.
- - Packaging: complete metadata, a README with install and usage,
- discoverable tests.
-- **Cost:** tokens, turns, wall time, API-equivalent dollars.
-- **Scope:** files and lines, and artifacts nobody asked for (ADR, journal,
- CHANGELOG, PLAYBOOK).
-- **Consistency:** the spread of every metric across an arm's trials.
-
-Adherence runs on every arm. It is a quality checklist, not a template
-checklist, so the bare arm can score on it.
+| Measure | What it reads |
+|---|---|
+| Install | `pip install .` in a clean virtualenv, `import tariff`, and the app serves `/` |
+| Accessibility | axe-core WCAG 2.1 AA violations |
+| HTML validity | Errors, less those on HTMX's `hx-*` attributes, which the spec requires and HTML lacks |
+| XSS and CSRF | One probe each |
+| Invoice builder | Response size and request count |
+| Adherence | Share of a fixed checklist of 13 items passed |
+| Cost | Tokens, turns, wall time, API-equivalent dollars |
+| Scope | Files and lines, and artifacts nobody asked for: ADR, journal, CHANGELOG, PLAYBOOK |
+| Consistency | Each metric's spread across an arm's trials |
+
+The adherence checklist:
+
+- **Tools:** `ruff` clean, `ruff format` clean, `mypy --strict` clean,
+ coverage ≥ 80 %, cognitive complexity ≤ 15.
+- **Structure:** a `src/` layout, one error hierarchy, a `NullHandler`.
+- **Hygiene:** no `print` in library code, no citations.
+- **Packaging:** complete metadata, a README with install and usage,
+ discoverable tests.
+
+It checks quality, not the templates, so the bare arm can score on it too.
### 8.6.2 Code quality
-**One ruler for every arm.** The tools run at the harness's pinned versions
-and configuration, never the configuration the agent wrote. Counts are
-reported absolute and per 1,000 lines.
+The tools run at the harness's pinned versions and configuration, never the
+configuration the agent wrote. Counts are reported absolute and per 1,000
+lines.
-**Finding the code.** Each arm picks its own layout, so the tools never
-assume `src/`.
+| Tool | Measures |
+|---|---|
+| `ruff check --select ALL` | Violations, by category |
+| `ruff format --check` | Files needing reformatting |
+| `mypy --strict` | Type errors |
+| `bandit` | Security findings, high and medium |
+| `complexipy` | Cognitive complexity: max, mean, functions over 15 |
+| `radon` | Cyclomatic complexity, maintainability index |
+| `interrogate` | Docstring coverage |
+| `vulture` | Unused code |
+| `pytest --cov` | Line and branch coverage of the agent's own tests |
+
+Not measured: mutation score, class cohesion, pylint's refactoring checks.
-- The harness imports the installed package and takes its directory.
-- It adds every top-level package directory in the workspace.
-- It passes those paths to every tool explicitly.
+**Finding the code.** Each arm picks its own layout, so the tools never
+assume `src/`. A tool pointed at an empty `src/` would report zero findings,
+and zero must never mean "nothing scanned". The harness:
-Why: a tool pointed at an empty `src/` reports zero findings, and "zero
-findings" must never mean "nothing scanned".
+1. imports the installed package and takes its directory
+2. adds every top-level package directory in the workspace
+3. passes those paths to every tool explicitly
-**A tool that scanned nothing records the metric as missing, never zero.**
-The same holds for a tool that failed or timed out. The report shows how
-many files and lines each tool saw. A clean arm can then be told from an
-unmeasured one.
+The report shows how many files and lines each tool saw, so a clean arm can
+be told from an unmeasured one.
-| Tool | Measures |
-|---|---|
-| `ruff check --select ALL` | violations, by category |
-| `ruff format --check` | files needing reformatting |
-| `mypy --strict` | type errors |
-| `bandit` | security findings, high and medium |
-| `complexipy` | cognitive complexity: max, mean, functions over 15 |
-| `radon` | cyclomatic complexity and maintainability index |
-| `interrogate` | docstring coverage |
-| `vulture` | unused code |
-| `pytest --cov` | line and branch coverage of the agent's own tests |
-
-Not measured: mutation score, class cohesion, and pylint's refactoring
-checks.
-
-The coverage run first installs what the trial declares for its tests —
-every extra and every dependency group in its `pyproject.toml` — constrained
-to the tool lock. The clean install leaves them out, and a suite that fails
-on an import would record a trial that packaged its test dependencies
-correctly as unmeasured. A declared dependency that conflicts with the lock
-records coverage as missing, with the conflict as the reason.
+**Coverage installs the test dependencies.** The clean install leaves out a
+trial's extras and dependency groups. Without them a suite fails on an
+import, and a trial that packaged its tests correctly would read as
+unmeasured. So the coverage run first installs every extra and dependency
+group in `pyproject.toml`, within the tool lock. One that conflicts with the
+lock records coverage as missing, with the conflict as the reason.
### 8.6.3 Design structure
-The harness probes each tree's structure directly:
-
-- **Layering:** the domain imports neither Flask nor the persistence
- module, and routes do no `Decimal` arithmetic.
-- **Import graph:** mutual imports, and the mean instability of domain
- modules (Martin), through `grimp`.
-- **Extension points:** can a new discount kind, jurisdiction or export
- format be added without editing existing code? Present or absent, per
- axis.
-- **Kind ladders:** conditionals that dispatch on a rule's kind.
-- **Boolean parameters:** a branch the caller cannot name.
-- **Public surface:** names exported against names the spec requires.
-- **IO isolation:** pricing takes values, not database rows or a
- connection.
-- **Hygiene:** `print` calls, exception bases, citations, logging set up
- with a `NullHandler`.
+The harness probes each tree's structure directly.
-### 8.6.4 The change task: the open-closed measure
-
-**The task must lie outside what the spec already allows.** Otherwise it
-measures data entry, not design. It adds two things:
+| Probe | Asks |
+|---|---|
+| Layering | Does the domain import neither Flask nor persistence? Do routes do no `Decimal` arithmetic? |
+| Import graph | Mutual imports, and the domain modules' mean instability (Martin), through `grimp` |
+| Extension points | Can a discount kind, a jurisdiction or an export format be added without editing existing code? Per axis |
+| Kind ladders | Conditionals that dispatch on a rule's kind |
+| Boolean parameters | Branches the caller cannot name |
+| Public surface | Names exported against names the spec requires |
+| IO isolation | Does pricing take values, not rows or a connection? |
+| Hygiene | `print` calls, exception bases, citations, a `NullHandler` |
-- a **spend-threshold discount**: 5 % off once the subtotal reaches 200.00,
- applied before coupons
-- a **capped reduced rate**: one tax category taxed at the reduced rate on
- the first 50.00 of a line and at the standard rate above it
+### 8.6.4 The change task: the open-closed measure
-Neither is reachable by configuration:
+The change task measures how well a build takes a change it was not built
+for. It must lie outside what the spec allows, or it measures data entry,
+not design. It adds two things no configuration reaches:
-- The threshold rule is the first invoice rule that depends on a condition
- over the invoice. Every existing kind is unconditional or gated only by a
- coupon code.
-- The capped rate is the first tax that is not one rate times one amount,
- so it changes the shape of the tax step, not its inputs.
+| Addition | Why configuration cannot reach it |
+|---|---|
+| Spend-threshold discount: 5 % off once the subtotal reaches 200.00, before coupons | The first rule gated by a condition over the invoice. Every other kind is unconditional or gated by a coupon |
+| Capped reduced rate: one category taxed at the reduced rate on a line's first 50.00, the standard rate above | The first tax that is not one rate times one amount. It changes the tax step's shape, not its inputs |
-**Measured:**
+Measured:
- files touched and lines changed
- whether the build suite is still green
- whether the change-task acceptance modules pass, through the API
-- from round 3, whether the new rule and cap work through the forms and
- the invoice preview
+- from round 3, whether the new rule and cap work through the forms and the
+ invoice preview
A new rule class plus a registry entry scores low churn. Editing the
pricing function, the tax step, three routes and two templates scores high.
+Churn means something only beside a pass: an arm that touched four lines and
+broke the extension has not scored well.
-**The prompt states everything the grader drives.** It names the new
-class, the cap's keyword, the form fields and the rules the acceptance
-modules check.
-
-Why: round 1's grader constructed the new behaviours through names the
-prompt never gave, so it graded which trials guessed them, and its pass
-rate was withdrawn (section 8.7.5).
-
-**The acceptance modules are written before any change-task run.** They
-test the two new behaviours against worked figures.
+Two rules keep the grading fair:
-Why: churn means something only beside a pass. An arm that touched four
-lines and broke the extension has not scored well.
+- **The prompt states everything the grader drives:** the new class, the
+ cap's keyword, the form fields, the rules the acceptance modules check.
+ Round 1's grader used names the prompt never gave, so it graded guessing,
+ and its pass rate was withdrawn (8.7.5).
+- **The acceptance modules are written before any change-task run.** They
+ test the two behaviours against worked figures.
### 8.6.5 Pattern use
-For each design pattern found, the judge records where it is, what it
+For each design pattern it finds, the judge records where it is, what it
removes or opens, and whether it has more than one implementation.
-- **Invited by the app:** Strategy for the discount kinds, a registry or
- Factory to resolve a rule or jurisdiction by name, Composite or a
- precedence chain for stacking, Adapter for the exports, Builder for an
- invoice.
-- **Scored on the property, not the name:** a design that reaches the same
- extension points another way scores the same.
-- **Over-engineering:** a pattern with one implementation that removes
- nothing, per `oop.md`.
-- **Missed:** a conditional ladder over rule kinds where a Strategy was
- warranted.
+| Kind | What counts |
+|---|---|
+| Warranted | Patterns the app invites: Strategy for discount kinds, a registry or Factory to resolve a rule or jurisdiction by name, Composite or a precedence chain for stacking, Adapter for exports, Builder for an invoice |
+| Missed | A conditional ladder over rule kinds where a Strategy was warranted |
+| Over-engineered | A pattern with one implementation that removes nothing, per `oop.md` |
-Reported as warranted, missed and over-engineered counts.
+It scores the property, not the name. A design that reaches the same
+extension points another way scores the same.
### 8.6.6 The model judge
-**The rubric.** Each row is scored 1–5 with a quoted evidence line: SRP,
-OCP, LSP, ISP, DIP, naming and abstraction level, error design,
-readability, maintainability, and test quality.
+**The rubric.** Each row is scored 1–5 with a quoted evidence line:
+
+- SOLID: SRP, OCP, LSP, ISP, DIP
+- naming and abstraction level, error design
+- readability, maintainability, test quality
+- security, data protection
-**Primary dimensions:** design (SOLID and pattern use), readability and
-maintainability. The report leads with them; task success and cost follow.
-Security and data protection join them from round 3 (section 8.6.8).
+**Primary dimensions** lead the report, before task success and cost:
+design (SOLID and pattern use), readability, maintainability, and from
+round 3 security and data protection (8.6.8).
**How it judges:**
-- **Anchored:** each primary describes its 1, 3 and 5 in terms of this
- domain. A scale saying only "1 is poor, 5 is excellent" put 3 on ordinary
- work every time.
-- **Three times:** each tree is judged three times and the scores are
- averaged. One judging is not reproducible.
-- **Blind:** the context file and any condition marker are stripped, the
- order is shuffled at a recorded seed, and a bundle that still names its
- arm is not judged.
-- **Claude, cross-checked by another vendor:** `claude-opus-5-5` through
- the `claude` CLI at effort `high`, with the model id and effort recorded.
- It shares a vendor with the generator, so a judge that favours its own
- family could favour every arm. Every arm is written by the same generator,
- so a contrast between arms cancels most of that; what it would not cancel
- is a preference for the templates' own style, which were largely written
- with Claude. `gpt-6-astra` through `codex exec` therefore judges a sample
- of each round, and the report states how often the two agree. The two are
- never averaged.
-
-From round 5, `gpt-6-astra` judges every trial and no cross-check runs
+| Rule | Why |
+|---|---|
+| Anchored: each primary describes its 1, 3 and 5 in this domain's terms | A scale saying only "1 is poor, 5 is excellent" put 3 on ordinary work every time |
+| Three judgings per tree, averaged | One judging is not reproducible |
+| Blind (8.5) | The judge must not favour an arm it can name |
+| Model and effort recorded with every judging | A reading is tied to the judge that made it |
+| Read-only: it may read the bundle and do nothing else | A judge that edits or runs the code changes what it scores |
+
+**Which judge.** From round 5, `gpt-6-astra` through `codex exec` at effort
+`high` judges every trial, and no cross-check runs
([round 5's registration, 13.1](../rounds/round-5.md)).
-**The cross-check's rule**, registered before the first round it covers:
-
-- **Sample:** whole blocks, so every contrast it reads is paired. It reads
- every build trial once where the plan's weekly limit allows, which a round
- of five arms does up to K = 5 (25 judgings of about 30). Where it does not,
- blocks are drawn in a shuffled order at the round's recorded seed until the
- limit is reached.
-- **Agreement:** per judge row, over the trials both judges read, the mean
- difference (the other judge's score minus the rounds' judge's mean) and the
- share of trials whose two scores lie within one point, which is half the
- distance between two anchors.
-- **Direction:** a judge-row contrast the rounds' judge calls better or worse
- loses its verdict when the other judge's mean paired difference on the
- same pairs has the opposite sign. A contrast the other judge reads as zero,
- or did not read, keeps its verdict.
-- **Reading:** the other judge's scores never replace or join the rounds'
- judge's, and its own intervals decide nothing.
+Earlier rounds used `claude-opus-5-5` through the `claude` CLI at effort
+`high`. It shares a vendor with the generator. Every arm has the same
+generator, so a contrast cancels most of that bias, but not a preference for
+the templates' style, which was largely written with Claude. So `gpt-6-astra`
+cross-checked a sample of each round, under a rule registered before the
+first round it covered:
+
+- **Sample:** whole blocks, so every contrast it reads is paired. Every
+ build trial once where the plan's weekly limit allows; otherwise blocks
+ drawn in a shuffled order at the round's seed until the limit.
+- **Agreement:** per row, the mean difference between the two judges, and
+ the share of trials whose scores lie within one point.
+- **Direction:** a better or worse verdict loses it when the other judge's
+ mean paired difference has the opposite sign. Zero or unread keeps it.
+- **Never mixed:** the other judge's scores never replace or join the main
+ judge's, and its intervals decide nothing.
### 8.6.7 How the judge is checked
-No person scores the judge. Two automated checks do:
-
-- **The evidence check:** every line the judge quotes is looked up in the
- bundle it was quoted from, and the report prints the share found per
- trial. A judge that never opened the code still returns plausible
- numbers; this is what tells the two apart.
-- **The control fixture:** twelve trees built from two pinned applications
- (`tests/efficacy/control/`). Every tree passes the same tests as its
- application, so only what was changed separates them. Some are damaged,
- some improved. A primary dimension counts only if it falls on the damaged
- trees and rises on the improved ones.
-
-**Where the control's application comes from.** A row can only fall or
-rise on code that has what it measures. The first pinned application is a
-round-1 tree with no sign-in and no customers, so the security and
-data-protection rows can be neither damaged nor improved on it. Those rows
-get a second pinned application: the output of one calibration trial, an
-ordinary build of the extended specification by the rounds' generator. The
-trial is uncounted, so no report reads it; it exists only to be the base
-the new rows' trees are built from.
-
-The reference implementation cannot serve instead. It is a worked answer to
-the hidden suite and stays private, and a trial keeps the base
-agent-written, like everything else the judge scores.
-
-The control fixture is read by both judges, each in a root of its own, and
-a primary counts only if it falls and rises under the rounds' judge.
+No person scores the judge. Two automated checks do.
-#### The control's trees
+**The evidence check.** Every line the judge quotes is looked up in the
+bundle it came from. The report prints the share found per trial. A judge
+that never opened the code still returns plausible numbers; this check tells
+the two apart.
-The control lives in `tests/efficacy/control/`. Its builder prints one line per
-entity it claims to change, read back off the trees, and refuses when any
-mutation did not land: a mutation that silently did nothing would read as the
-judge holding when it was never exercised. Every built tree passes its
-application's tests.
+**The control fixture.** Trees built from two pinned applications, in
+`tests/efficacy/control/`. Each tree changes one thing and passes the same
+tests as its application. A primary counts only if it falls on the tree that
+damages it and rises on the one that improves it, under the rounds' judge.
-| Tree | What it is |
+| Reading | What it means |
|---|---|
-| `base-1` | the application as one trial generated it, unaltered |
-| `degraded-1` | the domain merged into one module, `from flask import current_app` used inside `price`, and the package's exceptions reparented off `TariffError` |
-| `obscured-1` | the pricing algorithm inlined into one long function with abbreviated names, and nothing else: the module boundaries, the error hierarchy and the dispatch are the base's |
-| `clarified-1` | the mirror of `obscured-1`: the pricing module rewritten into short functions of one step each, with names that carry the intent, and nothing else changed |
-| `improved-1` | a rule contract and self-registering kind registry, dispatch on concrete type removed from pricing and persistence, the hardcoded kinds tuple replaced by the registry, a `__class__.__name__` ladder removed from a template, and two stray error classes folded into the package hierarchy |
-| `improved-2` | `improved-1`, and the store maps a rule's own terms onto its columns with a codec per column, so no module dispatches on a kind |
-| `improved-3` | `improved-2`, and each kind declares the fields it asks a form for, so the form-building code and the template are derived from the registry and no layer names a kind |
+| Falls on its damaged tree, rises on its improved one | The row works |
+| Does not fall | It cannot detect damage |
+| Does not rise | It cannot detect improvement, so no arm can win on it |
+| Moves on neither | It carries no information |
-The second application's trees:
+#### The control's trees
-| Tree | What it is |
-|---|---|
-| `base-2` | the calibration trial's application, unaltered: one guard before every route but sign-in, a CSRF token on every form, a salted password hash, `next` followed only to a local path, a secret key generated into a file; erasure clears the customer's fields, and nothing is logged |
-| `insecure-1` | the secret key a literal, the password stored and compared as typed, the user lookup built from a string, and `next` followed wherever it points |
-| `secured-1` | the secret key read from the environment first, the session cookie marked `HttpOnly` and `SameSite`, three security headers on every answer, and the check on `next` a named function that also refuses a backslash |
-| `leaky-1` | the customer's name, email and address written to the log on creation and erasure, and erasure only raising the flag, leaving every field in the database |
-| `protected-1` | one tuple names the personal fields, which erasure clears and the export returns; one lookup answers None for an erased customer, so no view or template reads the flag for itself; SQLite overwrites what it deletes |
+The first application is a round-1 tree with no sign-in and no customers, so
+it cannot move the security or data-protection rows. The second is one
+uncounted calibration trial: an ordinary build of the extended spec by the
+rounds' generator. The reference implementation cannot serve instead: it is
+a worked answer to the hidden suite and stays private.
+
+Each tree is built to move one row. Read a row against its own tree; the
+others check that it is not moving on noise.
+
+| Tree | Built to move | What it changes |
+|---|---|---|
+| `base-1` | — | The first application, unaltered |
+| `degraded-1` | design ↓, maintainability ↓ | Domain merged into one module, `from flask import current_app` inside `price`, the exceptions reparented off `TariffError` |
+| `obscured-1` | readability ↓ | Pricing inlined into one long function with abbreviated names; nothing else |
+| `clarified-1` | readability ↑ | Pricing rewritten into short one-step functions with names that carry the intent; nothing else |
+| `improved-1` | design ↑, maintainability ↑ | A rule contract and self-registering kind registry; type dispatch removed from pricing, persistence and a template; stray errors folded into the hierarchy |
+| `improved-2` | design ↑, maintainability ↑ | `improved-1`, and the store maps a rule's terms onto columns with a codec per column, so no module dispatches on a kind |
+| `improved-3` | design ↑, maintainability ↑ | `improved-2`, and each kind declares its form fields, so forms and template derive from the registry |
+| `base-2` | — | The calibration trial, unaltered: guarded routes, CSRF tokens, a salted hash, local-only `next`, a generated secret key; erasure clears the fields; nothing logged |
+| `insecure-1` | security ↓ | Literal secret key, plaintext password, a lookup built from a string, `next` followed anywhere |
+| `secured-1` | security ↑ | Secret key from the environment, `HttpOnly` and `SameSite` cookies, three security headers, `next` checked by a named function that also refuses a backslash |
+| `leaky-1` | data protection ↓ | Name, email and address logged on creation and erasure; erasure only raises a flag |
+| `protected-1` | data protection ↑ | One tuple names the personal fields for erasure and export; one lookup hides an erased customer; SQLite overwrites what it deletes |
The damage in `insecure-1` and `leaky-1` sits where the hidden suite does not
-look: it states that password storage, cookie flags and an off-site `next` are
-not graded, and it reads erasure through the pages.
+look: it does not grade password storage, cookie flags or an off-site
+`next`, and it reads erasure through the pages.
Each tree's hidden-suite result is identical, test by test, to `base-2`'s,
@@ -451,221 +472,181 @@ alike. That comparison therefore covers the 293 that pass, the pricing and API
checks among them.
-#### Reading a control result
-
-A row is doing its job when it falls on the tree that damages what it
-measures and rises on the tree that improves it. Anything else is a finding
-about the instrument:
+**The builder proves its own changes.** It prints one line per entity it
+claims to change, read back off the built trees, and refuses when a mutation
+did not land. A mutation that silently did nothing would read as the judge
+holding when it was never tested.
-- a row that does not fall cannot detect damage
-- a row that does not rise cannot detect improvement, so no arm can ever win
- on it
-- a row that moves on neither is carrying no information at all
+**When to re-run it.** Whenever the judge model, its effort, or the rubric
+prompt changes. Each change silently invalidates every earlier reading. The
+measured results are in [ch. 10.7](10-quality-requirements.md).
-Which tree tests which row matters. `degraded-1` damages structure and leaves
-every function body alone, so a flat `readability` there says nothing about
-the row — that is what `obscured-1` and `clarified-1` are for. Read each row against the tree
-built to move it, and treat the others as a check that it is not moving on
-noise.
+#### Why the bases are pinned archives
-Re-run the control whenever the judge model, its effort, or the rubric prompt
-changes. Each of those silently invalidates every reading below.
+`base.zip` and `base-2.zip` each hold one trial's output. They are inputs to
+the control, not artifacts of it: a regenerated base would compare a later
+run against a different application. `base-2.zip` is `git archive` of the
+calibration trial's commit `f74c0cc`, which reproduces it byte for byte.
-The measured results of every control run are in
-[ch. 10.7](10-quality-requirements.md).
+Two guards hold them still:
-#### Why the bases are pinned archives
+- The builder refuses an archive whose sha256 is not the one in `control.py`.
+- Every edit is an exact-text swap that refuses when its target is absent, so
+ a drifted base stops the control instead of mutating less than it claims.
-`base.zip` and `base-2.zip` each hold one trial's output: the application its
-trees are built from. `base-2.zip` is `git archive` of the calibration trial's
-commit `f74c0cc`, which reproduces it byte for byte. Each is an input to this
-control, not an artifact of it: regenerating one would compare a later run
-against a different application, and every number above would silently stop
-meaning what it says.
-
-Two things hold them still. The builder refuses any archive whose sha256 is not
-the one recorded in `control.py`, so a changed base stops the control instead
-of quietly shifting what it measures. And every edit the builder makes is an
-exact-text swap that refuses when its target is absent, so a base that drifts
-stops the control rather than mutating less than it claims.
-
-It is an archive rather than a directory of files because this repository's
-own checks read committed Python as source to be brought into line — the
-comment-layout rule flags a trailing comment in the application's test suite.
-Reformatting the fixture would edit the thing the judge scores, which is the
-one change this control cannot survive.
+They are archives, not directories, because this repository's linters would
+read committed Python as source to fix. Reformatting the fixture would edit
+the very thing the judge scores.
### 8.6.8 Security and data protection
-**From round 3, security and data protection are primary dimensions.**
-Each is read two ways, and both readings are primary:
+From round 3, security and data protection are primary dimensions, each read
+two ways:
| Metric | What it is | Direction | Margin | Smallest change that matters |
|---|---|---|---|---|
-| `judge_security` | anchored judge row, 1–5 | up | 0.3 points | 0.5 points |
-| `judge_data_protection` | anchored judge row, 1–5 | up | 0.3 points | 0.5 points |
-| Security probe pass rate | share of the security probes a trial passes | up | 2 pp | 9 pp |
-| Data-protection probe pass rate | share of the data-protection probes a trial passes | up | 10 pp | 30 pp |
-
-**Security probes (11):**
-
-- a plaintext password at rest
-- sign-in failures that reveal which accounts exist
-- an open redirect after sign-in
-- no CSRF on sign-in
-- a hard-coded secret key
-- debug left on
-- SQL assembled from a value the module cannot trace to its constants
-- known vulnerabilities in the installed dependencies
-- missing session cookie flags
-- missing security headers
-- stack traces in answers to malformed requests
-
-**Data-protection probes (3):**
-
-- a sentinel customer email found in the logs
-- an erased customer's sentinel still in the database file
-- one customer's export carrying another customer's data
-
-**How a probe reads the application.** It seeds and signs in the way the
-hidden suite does: the administrator's password from the environment, then
-the sign-in form's own fields. Where a probe needs a judgement, it takes the
+| `judge_security` | Anchored judge row, 1–5 | up | 0.3 points | 0.5 points |
+| `judge_data_protection` | Anchored judge row, 1–5 | up | 0.3 points | 0.5 points |
+| Security probe pass rate | Share of 11 probes passed | up | 2 pp | 9 pp |
+| Data-protection probe pass rate | Share of 3 probes passed | up | 10 pp | 30 pp |
+
+**The probes.**
+
+| Security (11) | Data protection (3) |
+|---|---|
+| Plaintext password at rest | Sentinel customer email in the logs |
+| Sign-in failures that reveal which accounts exist | An erased customer's sentinel still in the database file |
+| Open redirect after sign-in | One customer's export carrying another's data |
+| No CSRF on sign-in | |
+| Hard-coded secret key | |
+| Debug left on | |
+| SQL assembled from a value not traceable to constants | |
+| Known vulnerabilities in installed dependencies | |
+| Missing session cookie flags | |
+| Missing security headers | |
+| Stack traces in answers to malformed requests | |
+
+**How a probe reads the app.** It seeds and signs in the way the hidden
+suite does: the administrator's password from the environment, then the
+sign-in form's own fields. Where a probe needs a judgement, it takes the
narrow one:
-- the cookie flags pass on `HttpOnly` and `SameSite`; `Secure` cannot be
- observed over plain HTTP, so it is not asked
-- the headers pass on `nosniff` and framing protection; a content security
- policy is not asked, because the specification requires HTMX
-- a sentinel in the logs counts at every level, since a call that logs
- personal data does so whatever the level is set to
-- an erased sentinel counts anywhere in the files beside the database,
- free pages included, since that is where erasure leaves it
-
-**A probe the trial keeps from running is lost.** An application that will
-not boot, install or sign in its administrator fails every probe that needs
-it, with the reason recorded. Counted as missing instead, those probes would
-drop out of the rate, and a trial would score higher for not reaching them.
-A probe the harness itself could not run leaves the rate missing.
-
-**How the probe margins are set.** Both follow one rule, so the figures
-change only if a probe count does:
-
-- The margin is less than one probe lost in one trial. With K = 3 that is
- under 3.0 pp for security (1 of 11) and under 11.1 pp for data
- protection (1 of 3). No probe may be lost.
-- The smallest change that matters is one probe lost in every trial: 9.1 pp
- and 33.3 pp, rounded down to 9 and 30.
-
-**Before round 3's first trial:**
-
-- Each judge row is anchored at 1, 3 and 5 in terms of this domain.
-- Each passes the control fixture: it falls on a tree that damages it and
- rises on one that improves it, both built from the calibration trial's
- application (section 8.6.7).
-
-The last seven security probes are `tests/efficacy/security.py`'s checks.
-They were declared after round 1, so they described that round and decided
-nothing (section 8.7.4). Fixed here before round 3, they decide it.
+| Probe | Reads | Why so narrow |
+|---|---|---|
+| Cookie flags | `HttpOnly` and `SameSite` | `Secure` cannot be observed over plain HTTP |
+| Headers | `nosniff` and framing protection | No content security policy: the spec requires HTMX |
+| Sentinel in logs | Counts at any level | A call that logs personal data does so whatever the level |
+| Erased sentinel | Counts anywhere beside the database, free pages included | That is where erasure leaves it |
+
+**A probe the trial keeps from running is lost.** An app that will not boot,
+install or sign in its administrator fails every probe that needs it, with
+the reason. Counted as missing, those probes would drop out of the rate, and
+a trial would score higher for not reaching them. A probe the harness itself
+could not run leaves the rate missing.
+
+**How the probe margins are set.** Both follow one rule, so they change only
+when a probe count does:
+
+| | Security (11) | Data protection (3) |
+|---|---|---|
+| Margin: under one probe lost in one trial at K = 3 | under 3.0 pp → 2 | under 11.1 pp → 10 |
+| Smallest change: one probe lost in every trial | 9.1 pp → 9 | 33.3 pp → 30 |
+
+Before round 3's first trial, each row was anchored at 1, 3 and 5, and each
+passed the control fixture (8.6.7). The last seven security probes were
+declared after round 1, so they described that round and decided nothing
+(8.7.4). Fixed before round 3, they decide it.
## 8.7 The report
### 8.7.1 Contrasts
-Each metric is reported per arm and for the paired contrasts a round
-registers. Round 5's:
+Each metric is reported per arm and for the contrasts a round registers.
+Round 5's:
| Contrast | Asks |
|---|---|
-| `inline − none` | does every rule, copied in, help |
-| `hybrid − none` | does the hybrid model help |
-| `reference − none` | does naming the templates help |
-| `skills − none` | do a root file and task skills help |
-| `skills − hybrid` | H1: do skills deliver what hybrid does |
-| `reference − hybrid` | H3: does naming the templates alone deliver less |
-| `skills − inline` | the same rules, with and without the split into skills |
-
-A round that measures a template change registers one contrast,
-`candidate − baseline`, with both arms run in that round
-([ch. 4.2](04-solution-strategy.md)).
-
-Earlier rounds' contrasts stay declared in `report.py`, so an earlier round
-re-reads as it was reported.
-
-**A contrast pairing trials from different rounds gets no verdict.** It keeps
-its mean and interval and counts as neither a win nor a fail.
+| `inline − none` | Does every rule, copied in, help? |
+| `hybrid − none` | Does the hybrid model help? |
+| `reference − none` | Does naming the templates help? |
+| `skills − none` | Do a root file and task skills help? |
+| `skills − hybrid` | H1: do skills deliver what hybrid does? |
+| `reference − hybrid` | H3: does naming the templates alone deliver less? |
+| `skills − inline` | The same rules, with and without the split into skills |
+
+- A round that measures a template change registers one contrast,
+ `candidate − baseline`, with both arms run in that round
+ ([ch. 4.2](04-solution-strategy.md)).
+- **Pairing trials from different rounds gives no verdict.** The contrast
+ keeps its mean and interval, and counts as neither a win nor a fail.
+- A round may instead register a contrast with an earlier round's arm as
+ **unpaired**, read with an unpaired interval, as round 5d does.
+- Earlier rounds' contrasts stay declared in `report.py`, so an old round
+ re-reads as it was reported.
### 8.7.2 Metric directions
-- **Better upward:** task success, adherence, coverage, docstring coverage,
- extension points present, every judge score, the security and
- data-protection probe pass rates.
-- **Better downward:** every static-analysis count, cognitive and cyclomatic
- complexity, tokens, turns, wall time, cost, files, lines, artifacts nobody
- asked for, change-task churn, axe violations, HTML errors.
-- **Better downward, against a band:** from round 5, app code's lines and
- files. A rise whose whole interval stays inside the margin of section 8.1.2
- reads as held; only one wholly past it reads as worse.
-- **Neutral, reported without a verdict:** maintainability index,
- instability, test code's lines, from round 5 the source lines and files
- that app code replaces, and before round 5 app code's rows, so an earlier
- round rescored reads as it was reported.
+| Direction | Metrics |
+|---|---|
+| Better up | Task success, adherence, coverage, docstring coverage, extension points present, every judge score, the probe pass rates |
+| Better down | Every static-analysis count, cognitive and cyclomatic complexity, tokens, turns, wall time, cost, files, lines, artifacts nobody asked for, change-task churn, axe violations, HTML errors |
+| Down, against a band | From round 5, app code's lines and files. A rise wholly inside the margin (8.1.2) reads as held; only one wholly past it reads as worse |
+| Neutral, no verdict | Maintainability index, instability, test code's lines; from round 5, the source lines and files app code replaces; before round 5, app code's rows |
### 8.7.3 What the report prints
-A round writes three documents beside each other in `docs/audits/`, each for
-a different reader, plus the radar's two images.
-
-- **`YYYY-MM-DD-efficacy.md`, the report**, for anyone deciding: the
- radars, each approach in plain words, the round's questions answered, and
- how sure the answers are.
-- **`YYYY-MM-DD-efficacy-appendix.md`**, for a reader checking a claim:
- what produced the results, the radar's axes row by row, and the verdict
- vector.
-- **`YYYY-MM-DD-efficacy-record.md`**, for an auditor: everything else.
- Every metric's table, the change task, raw numbers per trial, lost and
- re-run trials, reaches, and the judge's evidence check.
-
-**The radar.** One per file arm against `none`. Its axes cluster the
-verdict vector's rows, in a fixed order: reliability, security, data
-protection, design, maintainability, tests and economy. An axis is the share
-of its rows better than `none` minus the share worse, from −1 to +1; a row
-whose verdict is withheld or not computed counts neither way. `none` is the
-ring at 0. It is two SVG files, light and dark, and GitHub shows the one
-matching the reader's theme.
-
-**Each approach, in plain words.** What it did better and worse than `none`,
-by radar axis; for reliability, how many runs fell short and how many would
-not start; for cost, the dollars per run. Then its verdict, naming the
-deciding measures that made it: the hidden tests, the security and
-data-protection probes, and the judge's five primary scores. Yes where one
-is better and none worse; Worse where any is worse; No where none moved.
+A round writes three documents to `docs/audits/`, one per reader, plus the
+radar's two images:
+
+| File | Reader | Holds |
+|---|---|---|
+| `YYYY-MM-DD-efficacy.md` | Anyone deciding | The radars, each approach in plain words, the round's questions answered, how sure the answers are |
+| `YYYY-MM-DD-efficacy-appendix.md` | Someone checking a claim | What produced the results, the radar's axes row by row, the verdict vector |
+| `YYYY-MM-DD-efficacy-record.md` | An auditor | Every metric's table, the change task, raw numbers per trial, lost and re-run trials, reaches, the evidence check |
+
+**The radar.** One per file arm, against `none` as the ring at 0. Its axes
+group the verdict vector's rows, in a fixed order: reliability, security,
+data protection, design, maintainability, tests, economy. An axis is the
+share of its rows better than `none` minus the share worse, from −1 to +1. A
+withheld or uncomputed verdict counts neither way. It comes as two SVGs,
+light and dark, and GitHub shows the one matching the reader's theme. Round
+5d registers a radar sized by how far each row moved instead.
+
+**Each approach, in plain words.**
+
+- What it did better and worse than `none`, by radar axis.
+- Reliability: how many runs fell short, and how many would not start.
+- Cost: dollars per run.
+- Its verdict, from the deciding measures: the hidden tests, both probe
+ sets, and the judge's five primaries.
+ - **Yes:** one is better and none worse.
+ - **Worse:** any is worse.
+ - **No:** none moved.
The radar and the words describe the verdicts and decide nothing. Every
claim rests on a row of the appendix or the record.
### 8.7.4 Checks declared after a run
-**A check chosen after the results were seen can describe a run but never
-decide it.**
+A check chosen after the results were seen can describe a run, never decide
+it. Otherwise the bar moves with the results.
- It is declared in writing, with its direction, before any trial is read
for it.
- The report prints it in its own section, with means and intervals and no
verdict.
-- It never enters the verdict vector, a "nothing got worse" claim or the
+- It never enters the verdict vector, a "nothing got worse" claim, or the
escalation.
-- A check worth deciding on is fixed before the next run instead.
-
-Why: otherwise the bar moves with the results.
+- A check worth deciding on is fixed before the next run.
### 8.7.5 Withdrawn measurements
-**A metric whose grader turns out to measure something else is withdrawn,
-not reported.**
+A metric whose grader turns out to measure something else is withdrawn, not
+reported.
-- The withdrawal is recorded in `tests/efficacy/withdrawn.json` against the
+- The withdrawal goes in `tests/efficacy/withdrawn.json`, against the
grader's revision.
-- Every run that revision graded loses the metric; a run graded by a
+- Every run that revision graded loses the metric. A run graded by a
corrected revision keeps it.
- The report names the metric and the reason, with no number, interval or
verdict.
@@ -674,16 +655,29 @@ not reported.**
## 8.8 Records
-Every stage writes what it did beside what it made: the run record per
-invocation, `generation.json` per generated file, each score with the
-revisions it was graded under, each judging with its model, effort and
-seed. `archive.py` carries all of it to the private archive with a hash per
-file, and a report refuses to write once any reading changed since the
-archive was verified.
+Every stage writes what it did beside what it made.
+
+| Stage | Records |
+|---|---|
+| Harness | The run record, per invocation |
+| Arm generator | `generation.json`, per generated file |
+| Scoring | Each score with the revisions it was graded under |
+| Judging | Each judging with its model, effort and seed |
+| Archive | All of the above, carried to the private archive with a hash per file |
+
+The report refuses to write once any reading changed since the archive was
+verified.
## 8.9 One run at a time
`score.py`, `judge.py` and `security.py` each clear a trial's directory
-before rebuilding it. A run writes `.running` naming its process. A
-second run that finds a live claim is refused. A claim naming a process
-that has ended is taken over, and the run says so.
+before rebuilding it, so two runs on one root would destroy each other's
+work.
+
+```mermaid
+flowchart LR
+ start["A run starts"] --> claim{"A .running claim
on the root?"}
+ claim -- no --> write["Write the claim,
naming its process"]
+ claim -- "yes, process alive" --> refuse["Refused"]
+ claim -- "yes, process ended" --> take["Take it over,
and say so"]
+```
diff --git a/docs/architecture/10-quality-requirements.md b/docs/architecture/10-quality-requirements.md
index e27352e..613ed73 100644
--- a/docs/architecture/10-quality-requirements.md
+++ b/docs/architecture/10-quality-requirements.md
@@ -1,56 +1,56 @@
# 10. Quality requirements
The quality goals of chapter 1, each made testable by scenarios. A
-scenario names a stimulus, the response the benchmark must give, and what
-checks it.
+scenario names a stimulus, the response the benchmark must give, and the
+[requirements](../requirements.md) it rests on, whose rows name the checks.
## 10.1 Q1, fairness
-| # | Stimulus | Response | Checked by |
+| # | Stimulus | Response | Rests on |
| - | -------- | -------- | ---------- |
-| Q1-1 | The model's behaviour drifts during a round | The drift lands across every arm of a block, not on one arm | Interleaved blocks, `harness.py` |
-| Q1-2 | An agent writes its own `ruff.toml` | Every arm is still measured under `toolconfig/` | `score.py` |
-| Q1-3 | A trial packages its tests in an extra | Coverage still runs, from the trial's declared groups within the lock | `score.py` |
-| Q1-4 | The spec requires HTMX, whose attributes HTML lacks | HTML validity sets aside `hx-*` errors and records how many | `score.py` |
-| Q1-5 | The model drifts within one block | No arm always runs first or last: each block starts one arm later | `harness.py --self-test` |
+| Q1-1 | The model's behaviour drifts during a round | The drift lands across every arm of a block, not on one arm | FR-02-01 |
+| Q1-2 | An agent writes its own `ruff.toml` | Every arm is still measured under `toolconfig/` | FR-07-03 |
+| Q1-3 | A trial packages its tests in an extra | Coverage still runs, from the trial's declared groups within the lock | FR-07-06 |
+| Q1-4 | The spec requires HTMX, whose attributes HTML lacks | HTML validity sets aside `hx-*` errors and records how many | FR-09-03 |
+| Q1-5 | The model drifts within one block | No arm always runs first or last: each block starts one arm later | FR-02-01 |
## 10.2 Q2, pre-registration
-| # | Stimulus | Response | Checked by |
+| # | Stimulus | Response | Rests on |
| - | -------- | -------- | ---------- |
-| Q2-1 | In a round registered at K = 3, a primary's interval contains zero while its mean exceeds the smallest change that matters | The report names the rows that owe K = 5 and the command that settles it | `report.py --self-test` |
-| Q2-2 | Someone asks for more blocks than the round allows | The harness refuses past 5, or past 15 for a round-5 run, and the report refuses a run past them | `harness.py`, `report.py` |
-| Q2-3 | A check is added after the results were seen | It prints in its own section with no verdict | `report.py` |
-| Q2-4 | A grader is found to measure something else | Every run that revision graded loses the metric, named with its reason | `withdrawn.json`, `report.py --self-test` |
-| Q2-5 | A round-5 run holds fewer than its 15 blocks | The report calls it part-run and names the blocks still owed | `report.py --self-test` |
+| Q2-1 | In a round registered at K = 3, a primary's interval contains zero while its mean exceeds the smallest change that matters | The report names the rows that owe K = 5 and the command that settles it | FR-03-01 |
+| Q2-2 | Someone asks for more blocks than the round allows | The harness refuses past 5, or past 15 for a round-5 run, and the report refuses a run past them | FR-03-02, FR-03-04 |
+| Q2-3 | A check is added after the results were seen | It prints in its own section with no verdict | FR-12-08 |
+| Q2-4 | A grader is found to measure something else | Every run that revision graded loses the metric, named with its reason | FR-12-09 |
+| Q2-5 | A round-5 run holds fewer than its 15 blocks | The report calls it part-run and names the blocks still owed | FR-03-05 |
## 10.3 Q3, isolation
-| # | Stimulus | Response | Checked by |
+| # | Stimulus | Response | Rests on |
| - | -------- | -------- | ---------- |
-| Q3-1 | The owner has a global `CLAUDE.md` | The bare arm never sees it, and the harness refuses a root a context file above it would reach | `harness.py` |
-| Q3-2 | A trial runs `git clone` of the hidden suite in its shell | The clone has no credentials, the transcript scan flags it, and the trial is voided and re-run once | `harness.py --self-test` |
-| Q3-3 | An agent stops its dev server by process name | The command is denied. One that ran voids the trial | Deny rules, transcript scan |
-| Q3-4 | A background server outlives the CLI | Every process from the trial's directories is stopped before the freeze | `harness.py --self-test` |
+| Q3-1 | The owner has a global `CLAUDE.md` | The bare arm never sees it, and the harness refuses a root a context file above it would reach | FR-05-01 |
+| Q3-2 | A trial runs `git clone` of the hidden suite in its shell | The clone has no credentials, the transcript scan flags it, and the trial is voided and re-run once | FR-05-05, FR-05-07 |
+| Q3-3 | An agent stops its dev server by process name | The command is denied. One that ran voids the trial | FR-05-06, FR-05-07 |
+| Q3-4 | A background server outlives the CLI | Every process from the trial's directories is stopped before the freeze | FR-05-09 |
## 10.4 Q4, honest measurement
-| # | Stimulus | Response | Checked by |
+| # | Stimulus | Response | Rests on |
| - | -------- | -------- | ---------- |
-| Q4-1 | A tool is pointed at an empty `src/` | The metric is missing, not zero, and the report shows the files and lines each tool saw | `score.py --self-test` |
-| Q4-2 | The judge returns scores without reading the code | The evidence check finds its quotes missing from the bundle | `judge.py`, the report's evidence line |
-| Q4-3 | A judge row cannot move | The control fixture shows it fail to fall on a damaged tree or rise on an improved one | `control/control.py`, `judge.py` |
-| Q4-4 | An app will not sign in its administrator | Every probe that needs it fails with the reason, so the rate cannot rise by not reaching it | `security.py` |
+| Q4-1 | A tool is pointed at an empty `src/` | The metric is missing, not zero, and the report shows the files and lines each tool saw | FR-06-01, FR-07-05 |
+| Q4-2 | The judge returns scores without reading the code | The evidence check finds its quotes missing from the bundle | FR-10-06 |
+| Q4-3 | A judge row cannot move | The control fixture shows it fail to fall on a damaged tree or rise on an improved one | FR-10-07, FR-10-09 |
+| Q4-4 | An app will not sign in its administrator | Every probe that needs it fails with the reason, so the rate cannot rise by not reaching it | FR-06-03 |
## 10.5 Q5, reproducibility
-| # | Stimulus | Response | Checked by |
+| # | Stimulus | Response | Rests on |
| - | -------- | -------- | ---------- |
-| Q5-1 | The run root is deleted after a round | The archive restores it, and scoring and judging run on the restored root | `archive.py --restore` |
-| Q5-2 | A reading changes after the archive was verified | The report refuses to write under `docs/audits/` | `archive.py`, `report.py` |
-| Q5-3 | A run stops part way | The run record holds every trial it finished, and `--from` resumes at the next | `harness.py` |
-| Q5-4 | A later template revision is to be measured | The same harness runs it as a candidate against the baseline, both in one round | Design [ch. 4.2](04-solution-strategy.md) |
-| Q5-5 | A report is aimed at any `docs/audits/` before the round is archived | Refused, in the templates source as anywhere else | `report.py --self-test` |
+| Q5-1 | The run root is deleted after a round | The archive restores it, and scoring and judging run on the restored root | FR-13-05 |
+| Q5-2 | A reading changes after the archive was verified | The report refuses to write under `docs/audits/` | FR-13-04 |
+| Q5-3 | A run stops part way | The run record holds every trial it finished, and `--from` resumes at the next | FR-04-08 |
+| Q5-4 | A later template revision is to be measured | The same harness runs it as a candidate against the baseline, both in one round | Design, [ch. 4.2](04-solution-strategy.md) |
+| Q5-5 | A report is aimed at any `docs/audits/` before the round is archived | Refused, in the templates source as anywhere else | FR-13-04 |
## 10.6 The numbers behind the rules
diff --git a/docs/requirements.md b/docs/requirements.md
new file mode 100644
index 0000000..d2bb778
--- /dev/null
+++ b/docs/requirements.md
@@ -0,0 +1,182 @@
+# Requirements
+
+What the benchmark must do, one rule per row, each with the self-test checks
+that prove it.
+
+- **IDs:** `FR--`. Cite a rule by its ID. A new rule takes the next
+ free number in its topic; a removed ID is never reused.
+- **Why:** each topic names the
+ [chapter 8](architecture/08-crosscutting-concepts.md) section that explains
+ its rules. The quality scenarios in
+ [chapter 10](architecture/10-quality-requirements.md) name the rules they
+ rest on.
+- **Checked by:** the module whose `--self-test` proves the rule, and the
+ label it prints for that check. `trace.py` fails when a label no self-test
+ prints is named here.
+- **Untestable:** a rule no script can see, with the reason.
+- **Gap:** a rule a script follows that no self-test plants yet, with the
+ issue that tracks it.
+
+## 01 Registration (ch. 8.1.1)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-01-01 | From round 5, the report shall refuse a round whose registration landed on `main` after its first trial started, read on `main`'s first-parent line so a merge counts at the merge. | `report.py` "one landed after the first trial is refused"
`report.py` "one merged after the first trial is read at the merge"
`report.py` "a registration landed before the first trial passes, across zones" |
+| FR-01-02 | The report shall refuse a registration that differs from `main`'s copy or has changes not committed. | `report.py` "one changed and not committed is refused"
`report.py` "an amendment on a branch of its own is refused" |
+| FR-01-03 | The report shall refuse a trial built from a spec or prompt other than the ones its round registers, by content. | `report.py` "a trial on another spec is refused"
`report.py` "a trial on another prompt is refused"
`report.py` "every trial on the registered spec passes"
`report.py` "every trial on the one prompt passes" |
+| FR-01-04 | The report shall refuse a trial with something to score that records no spec or no prompt. | `report.py` "a scorable trial recording no spec is refused"
`report.py` "a scorable trial recording no prompt is refused" |
+| FR-01-05 | The harness shall check the spec before every trial, so an edit made mid-run refuses the trials after it unbuilt. | `harness.py` "a spec edited mid-run refuses the next trial unbuilt"
`harness.py` "a spec changed as it is copied refuses the trial and frees its slot"
`harness.py` "a round-5 run on other content is refused"
`harness.py` "round 5's registered digest is SPEC.md's content" |
+| FR-01-06 | A trial shall record its start with its UTC offset, and the report shall refuse a start with none. | `report.py` "a trial start with no UTC offset is refused" |
+| FR-01-07 | A registration shall land through a pull request's squash or rebase merge. | Untestable: how a commit reached `main` is the owner's practice, and no script sees it. |
+
+## 02 Reading a result (ch. 8.1.1, 8.1.2)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-02-01 | The arms of a block shall run interleaved, each block starting one arm later, so drift lands on every arm. | `harness.py` "each block starts one arm later"
`harness.py` "over five blocks every arm runs in every place" |
+| FR-02-02 | A contrast shall read better when its 95 % bootstrap interval lies wholly on the improving side of zero, worse when wholly on the other, and no improvement shown when it contains zero, by the metric's direction. | `report.py` "every pairing improves by the same amount -> better"
`report.py` "every pairing improves, unstably -> better"
`report.py` "three identical differences -> better"
`report.py` "the differences change sign -> no improvement shown"
`report.py` "a downward metric that fell -> better"
`report.py` "a downward metric that rose -> worse" |
+| FR-02-03 | A metric shall read held only when the whole interval lies inside its registered margin, relative margins taken on the baseline arm's mean. | `report.py` "10 more lines on 100 is preserved"
`report.py` "20 more lines on 100 is not"
`report.py` "1.5 more per KLOC on 20 is preserved"
`report.py` "3 more per KLOC on 20 is not"
`report.py` "no baseline makes no relative claim" |
+| FR-02-04 | Every primary and every per-KLOC row shall carry its registered margin. | `report.py` "every per-KLOC row carries the static margin"
`report.py` "every primary the judge asks for is led with, worded and given its margins" |
+| FR-02-05 | Round 5 shall hold adherence within 8 pp, one checklist item of 13. | `report.py` "round 5 holds adherence within one item, 8 pp" |
+| FR-02-06 | From round 5, app code's lines and files shall read held on a rise wholly inside the band, and worse only on one wholly past it. | `report.py` "a rise inside the band is held"
`report.py` "a rise wholly past the band is worse"
`report.py` "one that straddles the band is undecided"
`report.py` "a band that holds zero is held"
`report.py` "round 5 reads a 10 % rise in app code as held" |
+| FR-02-07 | An adherence gain shall count only where the hidden-test pass rate held. | Gap: #109 |
+| FR-02-08 | A trim shall be called free only where every metric held. | Gap: #109 |
+| FR-02-09 | Below K = 6, the report shall call every interval descriptive. | `report.py` "from six blocks no interval is called descriptive"
`report.py` "a round too small to decide says so in the report and the appendix" |
+
+## 03 Trial count and escalation (ch. 8.1.3)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-03-01 | The report shall owe an escalation to K = 5 where a primary's interval contains zero while its mean difference exceeds the smallest change that matters, in any contrast and either direction. | `report.py` "a crossing interval with an effect of 0.67 owes it"
`report.py` "an effect of 0.67 the other way owes it"
`report.py` "the same row on C-A owes it"
`report.py` "an effect of exactly 0.5 does not"
`report.py` "an interval clear of zero does not"
`report.py` "an interval not computed does not"
`report.py` "a row outside the primary dimensions does not" |
+| FR-03-02 | An escalation shall run two more blocks, once, and K shall never pass 5 under it. | `harness.py` "a K past the escalation's ceiling refuses"
`harness.py` "the escalation runs its blocks from none-4"
`report.py` "an owed escalation's command names a trial the harness takes" |
+| FR-03-03 | An escalated report shall print the K = 3 and K = 5 results side by side, and a row still open at K = 5 as inconclusive. | `report.py` "an escalated report prints both vectors"
`report.py` "the report carries the escalation section"
`report.py` "a K = 5 run is judged on its first three blocks"
`report.py` "a K = 3 run is assessed on its own vector"
`report.py` "an open row leaves both inconclusive" |
+| FR-03-04 | A round registered at a larger K shall take no block past it. | `harness.py` "a round-5 run takes K = 15 and refuses more"
`harness.py` "a round-5d run of hand and short takes K = 15 too" |
+| FR-03-05 | A run short of its registered K shall be part-run, and none of its verdicts the round's. | `report.py` "one trial of the last block leaves the round part-run"
`report.py` "a round 5 run short of its last block says it is provisional"
`report.py` "a round-5 run owes no escalation and names the blocks still owed" |
+
+## 04 Failed and lost trials (ch. 8.1.4)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-04-01 | A trial that completed, or was ended by the budget cap or the timeout, shall be scored as it stands. | `harness.py` "a clean finish is completed"
`harness.py` "the budget cap is budget"
`harness.py` "one that never answers is ended at the timeout"
`score.py` "only completed, budget and timeout endings are offered, under the arms' words" |
+| FR-04-02 | A build that did not install shall go unjudged, with its judge rows missing. | `judge.py` "only a build that did not install goes unjudged"
`report.py` "a build that did not install has its judge rows missing" |
+| FR-04-03 | A failed trial shall never be re-run. | Untestable: the harness has no path that re-runs a trial ended by the agent; FR-04-04 proves only a lost one re-runs. |
+| FR-04-04 | A trial the CLI ends with any error but the budget cap shall be lost: a usage limit, a rate limit, a crash, or no result. | `harness.py` "a usage limit, by its wording is blocked"
`harness.py` "a rate limit, by its status is blocked"
`harness.py` "an error behind a zero status is blocked"
`harness.py` "an error subtype nobody listed is blocked"
`harness.py` "no JSON at all is blocked" |
+| FR-04-05 | A lost trial shall be re-run once, in its own place in the order, and its re-run read in its stead. | `harness.py` "a blocked trial re-runs in its place"
`harness.py` "the re-run names the trial it substitutes"
`score.py` "a blocked trial yields to its re-run" |
+| FR-04-06 | A lost trial's workspace shall be kept under the run's `void/` directory and never scored. | `harness.py` "a voided workspace is kept under void/"
`harness.py` "a voided trial takes its whole pen and its tarball" |
+| FR-04-07 | A second loss of the same trial shall stop the run. | `harness.py` "a second block stops the run" |
+| FR-04-08 | A run that stopped part way shall resume with `--from` at the trial named, keeping the order. | `harness.py` "--from short-2 starts there and keeps the order"
`harness.py` "--from an unknown trial refuses"
`harness.py` "no trial stays recorded as running" |
+
+## 05 Isolation (ch. 8.2)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-05-01 | A trial shall run under a scratch home and minimal settings, so the owner's global `CLAUDE.md`, hooks, memory and MCP never reach it. | `harness.py` "the scratch home is the home"
`harness.py` "the settings file carries the rules and the isolation"
`harness.py` "a trial reads the workspace's project settings and no other source" |
+| FR-05-02 | A trial shall run in a cleaned environment, without the launching session's variables, interpreter or keys. | `harness.py` "ANTHROPIC_API_KEY is removed"
`harness.py` "CLAUDECODE is removed"
`harness.py` "VIRTUAL_ENV is removed"
`harness.py` "the interpreter leaves PATH" |
+| FR-05-03 | The file tools shall be denied every path outside the trial's own workspace. | `harness.py` "other trials, their change tasks, home and void are denied"
`harness.py` "this repository and the scoring area are denied"
`harness.py` "tarballs and run records are denied"
`harness.py` "the templates source is denied whenever one is set"
`harness.py` "the trial's own workspace is not denied" |
+| FR-05-04 | The web tools shall be disallowed. | Gap: #109 |
+| FR-05-05 | Git credential helpers shall answer nothing inside a trial. | `harness.py` "a planted Git helper answers outside a trial"
`harness.py` "it does not answer inside one" |
+| FR-05-06 | Commands that stop a process by name shall be denied. | `harness.py` "every kill by name meets a deny rule" |
+| FR-05-07 | The transcript scan shall flag every tool call naming a forbidden path or repository; a hit voids the trial and re-runs it once. | `harness.py` "every call reaching past the trial is flagged"
`harness.py` "the root, another pen and a climb out of the pen are flagged"
`harness.py` "a fetch of the templates is flagged, and only that"
`harness.py` "a kill by name that ran, or never answered, is a hit"
`harness.py` "a scorable trial with a reach becomes reached"
`harness.py` "the trial's own paths are not flagged, a pip extra included" |
+| FR-05-08 | The report shall scan every transcript again under the current rule. | `report.py` "its record's clean scan is read again and flagged"
`report.py` "a trial whose scan hit is named"
`report.py` "a reached build trial is left out whole" |
+| FR-05-09 | Every process started from a trial's directories shall be stopped before the trial is frozen, and the record list them. | `harness.py` "the one running from the trial is stopped"
`harness.py` "two planted processes run and are listed"
`harness.py` "the record lists what was stopped" |
+
+## 06 Missing is not zero (ch. 8.3)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-06-01 | A tool that scanned nothing, failed or timed out shall record its metric as missing, with the reason. | `score.py` "empty tree: ruff is missing, not zero"
`score.py` "empty tree: mypy is missing, not zero"
`score.py` "empty tree: coverage is missing, not zero"
`score.py` "tools absent: ruff is missing, not zero"
`score.py` "tools absent: bandit is missing, not zero"
`score.py` "an empty tree reports nothing seen"
`score.py` "a failed listing is missing, never an empty list" |
+| FR-06-02 | A grader's skipped check shall not count as passed. | `score.py` "a skipped check is recorded beside the rate"
`score.py` "a partial suite is flagged"
`score.py` "a suite that skipped nothing is not partial" |
+| FR-06-03 | A probe the trial keeps from running shall be lost, and count against the rate. | `security.py` "an application that will not boot loses every runtime probe"
`security.py` "an administrator that cannot sign in loses what needs one"
`security.py` "the lost probes count against the rate" |
+| FR-06-04 | A probe the harness could not run shall leave the rate missing. | `security.py` "no report from the probe is missing, not lost"
`security.py` "an audit of nothing is missing, not zero"
`security.py` "a report that is not JSON is missing"
`security.py` "no roots is missing, not zero" |
+| FR-06-05 | The report shall show an unmeasured value as not measured. | `report.py` "an unmeasured column reads not measured"
`report.py` "an unmeasured run answers Not measured in every cell" |
+
+## 07 One ruler (ch. 8.4, 8.6.2)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-07-01 | The first trial scored shall freeze the tools to a lock, and every later trial install from it. | `score.py` "the battery installs from a lock it resolved" |
+| FR-07-02 | The lock shall hold only the tools, never a trial's own packages. | `score.py` "only the tools reach the lock"
`score.py` "the lock carries none of the trial's dependencies" |
+| FR-07-03 | The tools shall run under `toolconfig/` only, never the configuration the agent wrote. | Gap: #109 |
+| FR-07-04 | Every build shall be scored on the spec's Python, and the report refuse a round scored on two. | `score.py` "a scoring environment runs the spec's Python"
`score.py` "no Python at the spec's version refuses to score"
`score.py` "a score on another Python refuses the root"
`report.py` "scores on two Pythons are refused" |
+| FR-07-05 | The tools shall be pointed at the installed package and every top-level package, never an assumed `src/`. | `score.py` "the planted package is discovered"
`score.py` "an empty tree yields no roots" |
+| FR-07-06 | The coverage run shall first install every extra and dependency group the trial declares, within the lock. | `score.py` "every extra and every group requirement is installed" |
+| FR-07-07 | A declared test dependency that conflicts with the lock shall record coverage as missing, with the conflict. | Gap: #109 |
+
+## 08 Blindness (ch. 8.5)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-08-01 | The judge's bundle shall hold the trial's code without the context file, the vendored templates, the skills, or scoring's output. | `judge.py` "the trial's code reaches the bundle"
`judge.py` "scoring's output and the environment's stay out of the bundle"
`judge.py` "the skills arm's skills stay out of the bundle" |
+| FR-08-02 | The bundles shall be judged in an order shuffled at a recorded seed, with the unblinding map out of the judge's reach. | Gap: #109 |
+| FR-08-03 | A bundle that still names its arm shall be refused. | `judge.py` "a path naming the trial is a leak"
`judge.py` "an escaped path naming the trial is a leak"
`judge.py` "a leak in a directory the copy skips is found"
`judge.py` "a bundle holding neither has no leak"
`generate_arm.py` "the leak scan reports a planted token and passes clean text" |
+
+## 09 Scoring (ch. 8.6.1 to 8.6.4)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-09-01 | The hidden suite shall live outside every workspace, in a scoring area the trial is denied. | `harness.py` "the scoring area lies outside the run root"
`harness.py` "this repository and the scoring area are denied" |
+| FR-09-02 | A build shall install in a clean virtualenv and boot under scoring as the hidden suite boots it. | `score.py` "an application that seeds on start, and has no default secret, boots under scoring"
`score.py` "a build capped below Python 3.13 installs" |
+| FR-09-03 | HTML validity shall set aside the errors on HTMX's `hx-*` attributes, and count the rest. | `score.py` "an hx-* error is set aside and another counts" |
+| FR-09-04 | Scope shall count app code apart from tests, docs and configuration, and name artifacts nobody asked for. | `score.py` "app code is the app's Python and templates, not its tests"
`score.py` "test code is a tests directory or a pytest name, anywhere"
`score.py` "docs and configuration count toward no size"
`score.py` "committed bytecode and a database are artifacts nobody asked for" |
+| FR-09-05 | The adherence checklist's 13 items shall be read on every arm, the bare arm included. | Gap: #109 |
+| FR-09-06 | The design-structure probes shall read layering, the import graph, extension points, kind ladders, boolean parameters, the public surface, IO isolation and hygiene. | Gap: #109 |
+| FR-09-07 | Change-task churn shall count every edited and new file, and nothing in an environment. | `score.py` "churn counts an edit and a new file, not an environment"
`score.py` "the churn plant landed" |
+| FR-09-08 | The change prompt shall state everything the grader drives. | `harness.py` "the change prompt names the API and fields the grader drives"
`harness.py` "the change prompt is read whole from its file" |
+| FR-09-09 | The change-task acceptance modules shall be written before any change-task run. | Untestable: an order of work; the round's registration fixes it. |
+
+## 10 The judge (ch. 8.6.5 to 8.6.7)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-10-01 | Each tree shall be judged three times, and its scores averaged. | `judge.py` "each tree is read three times by default"
`report.py` "a trial's repeats are meaned, and one judging means itself" |
+| FR-10-02 | From round 5, the judge shall be `gpt-6-astra` through `codex exec` at effort `high`, with model and effort recorded. | `judge.py` "the default judge is gpt-6-astra through codex"
`judge.py` "the default effort is high"
`judge.py` "the codex command carries the model and the effort"
`judge.py` "the recorded effort is the one passed" |
+| FR-10-03 | The judge may read the bundle and do nothing else. | `judge.py` "it may read and nothing else"
`judge.py` "the claude backend is not in plan mode" |
+| FR-10-04 | A cross-check's agreement shall be counted per row over the trials both judges read. | `report.py` "agreement is counted per row over the trials both read" |
+| FR-10-05 | A verdict shall lose its direction when the other judge's mean paired difference has the opposite sign, and keep it otherwise. | `report.py` "a direction the other judge reverses loses its verdict"
`report.py` "a direction both judges read keeps its verdict"
`report.py` "a contrast the other judge did not read keeps its verdict"
`report.py` "the rounds' own judge is caught posing as the other" |
+| FR-10-06 | The report shall print the share of the judge's quotes found in its bundle. | `report.py` "the judge is checked by its evidence, not a person" |
+| FR-10-07 | The control builder shall refuse when a mutation did not land, and print each change it read back. | `control/control.py` "the domain imports flask"
`control/control.py` "ValidationError derives from TariffError"
`control/control.py` "the secret key is a literal"
`control/control.py` "customer data is written to the log" |
+| FR-10-08 | The control builder shall refuse a base archive whose sha256 is not the one recorded. | Gap: #109 |
+| FR-10-09 | A primary shall count only if it falls on the control tree that damages it and rises on the one that improves it. | Untestable: a judged control root is read by hand, and ch. 10.7 records each reading. |
+
+## 11 Security and data protection (ch. 8.6.8)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-11-01 | The 11 security and 3 data-protection probes shall fail an app built to fail them and pass one built to pass them. | `security.py` "exposed fails every probe"
`security.py` "hardened passes every probe"
`security.py` "exposed rates are zero"
`security.py` "hardened rates are whole" |
+| FR-11-02 | A probe shall sign in the way the hidden suite does. | `security.py` "exposed signs in"
`security.py` "hardened signs in" |
+| FR-11-03 | The source probes shall count every planted secret, debug and assembled-SQL form, and no safe one. | `security.py` "every planted secret form is counted"
`security.py` "every planted debug form is counted"
`security.py` "every planted assembled statement is counted"
`security.py` "parameters, plain f-strings and constant names are not assembled SQL"
`security.py` "hardened source finds no secret" |
+| FR-11-04 | The dependency probe shall count every vulnerability of every installed package. | `security.py` "every vulnerability of every package is counted" |
+| FR-11-05 | The CSRF probe shall fail a sign-in that accepts a forgery, and pass one that refuses it. | `security.py` "public pages with a forgeable sign-in fail only its CSRF probe"
`security.py` "public pages with a token-checked sign-in pass every probe"
`security.py` "a refused forgery passes though a failed sign-in answers as a real one" |
+| FR-11-06 | The report shall read each probe rate as `security.py` files it. | `report.py` "every probe rate reads the rate security.py files" |
+
+## 12 The report (ch. 8.7)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-12-01 | A paired contrast crossing rounds shall get no verdict and count nowhere. | `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 | A contrast a round registers against an earlier round's arm shall be read unpaired, with a verdict. | `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-03 | The report shall print every declared contrast its arms ran, and no other. | `report.py` "it prints every declared contrast its arms ran"
`report.py` "a three-arm run prints only its own contrasts"
`report.py` "an earlier round computes no round-5d contrast" |
+| FR-12-04 | A neutral row shall print without a verdict. | `report.py` "an earlier round rescored prints app code without a verdict"
`report.py` "round 5 reports the files it supersedes without a verdict" |
+| FR-12-05 | A round shall write a report, an appendix and a record, each linking the next. | `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" |
+| FR-12-06 | The radar shall draw one panel per file arm against `none`, in both themes, each axis better minus worse over its rows with a verdict. | `report.py` "the radar draws a panel per arm, with the bare ring, in both themes"
`report.py` "an axis is better minus worse over its rows with a verdict, None without one"
`report.py` "the summary is the radar, one image per theme" |
+| FR-12-07 | Each approach's verdict shall be Yes where a deciding measure is better and none worse, Worse where any is worse, and No where none moved. | `report.py` "the report names each approach and its verdict in plain words"
`report.py` "a better primary and no worse answers Yes"
`report.py` "a worse primary answers Worse"
`report.py` "nothing separated answers No" |
+| FR-12-08 | A check declared after a run shall print in its own section, with no verdict, outside the verdict vector. | `report.py` "the report prints the section"
`report.py` "its row carries no verdict"
`report.py` "its row is not in the verdict vector"
`report.py` "no after-the-results check is a verdict metric" |
+| FR-12-09 | A withdrawn metric shall lose every value on the runs its grader's revision graded, and keep them on the others. | `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 | A corrected grader shall never re-grade the trials its earlier revision graded. | Untestable: a working rule; a re-grade and a first grade leave the same record. |
+
+## 13 Records (ch. 8.8)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-13-01 | The harness shall write the run record as every trial starts and ends, with the CLI's version. | `harness.py` "the record is written as every trial starts and ends"
`harness.py` "every trial records the CLI's version, read as it starts" |
+| FR-13-02 | The arm generator shall write `generation.json` beside every file it generates. | Gap: #109 |
+| FR-13-03 | The archive shall carry every reading, judging, map and lock, with a hash per file, and fail its verify on a changed one. | `archive.py` "readings, judgings, map and lock come; bundles do not"
`archive.py` "the original tarball's hash is recorded"
`archive.py` "the revisions are recorded"
`archive.py` "a reading changed in the archive fails the verify" |
+| FR-13-04 | The report shall refuse to write under `docs/audits/` once a reading changed since the archive was verified. | `archive.py` "a reading changed after the stamp is a problem"
`archive.py` "the report refuses docs/audits/ without a current stamp"
`report.py` "a report into a templates source's docs/audits needs the stamp" |
+| FR-13-05 | A restored archive shall read as the original root does, its records pointing at the restored files. | `archive.py` "the restored root reads as the original does"
`archive.py` "a restored record points at the restored tarball and void"
`archive.py` "a restored transcript keeps its time" |
+
+## 14 One run at a time (ch. 8.9)
+
+| ID | Requirement | Checked by |
+|---|---|---|
+| FR-14-01 | A second `score.py`, `judge.py` or `security.py` run that finds a live claim on the root shall be refused. | `score.py` "a live score.py run refuses a second"
`judge.py` "a live judge.py run refuses a second"
`security.py` "a live security.py run refuses a second" |
+| FR-14-02 | A claim naming a process that has ended shall be taken over, and the run say so. | `harness.py` "an ended run is taken over"
`harness.py` "a live pid that is not the tool is taken over" |
diff --git a/tests/efficacy/trace.py b/tests/efficacy/trace.py
new file mode 100644
index 0000000..a694109
--- /dev/null
+++ b/tests/efficacy/trace.py
@@ -0,0 +1,289 @@
+"""Trace every requirement to the self-test checks that prove it.
+
+Each row of `docs/requirements.md` names, in its last cell, either the
+self-test labels that prove the rule, why no script can test it, or the issue
+that tracks its missing check. This reads every self-test's output and fails
+on a rule that names none of the three, or on a label no self-test prints.
+
+ py tests/efficacy/trace.py
+ py tests/efficacy/trace.py --outputs
+ py tests/efficacy/trace.py --self-test
+"""
+
+import argparse
+import io
+import os
+import re
+import subprocess
+import sys
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+ROOT = os.path.dirname(os.path.dirname(HERE))
+sys.path.insert(0, os.path.dirname(HERE))
+
+import lib # noqa: E402
+
+REQUIREMENTS = os.path.join(ROOT, "docs", "requirements.md")
+
+# Every module with a self-test, by its path under tests/efficacy/. A label
+# is looked up only in the output of the module its row names.
+MODULES = ("harness.py", "generate_arm.py", "score.py", "judge.py",
+ "report.py", "archive.py", "reuse.py", "progress.py",
+ "security.py", "control/control.py")
+
+ROW = re.compile(r"^\| (FR-(\d{2})-(\d{2})) \| (.+?) \| (.+?) \|$")
+TOPIC = re.compile(r"^## (\d{2}) ")
+CITED = re.compile(r'^`([\w/]+\.py)` "(.+)"$')
+GAP = re.compile(r"^Gap: #\d+$")
+UNTESTABLE = re.compile(r"^Untestable: \S")
+
+
+def saved_name(module):
+ """The file a module's saved self-test output is read from."""
+ return os.path.basename(module)[:-len(".py")] + ".txt"
+
+
+def printed(lines, label):
+ """True when `label` is the whole label of one of the check lines.
+
+ A check line is the label alone, or the label padded before `ok`, or
+ `ok` before the label and the trees' columns after it. A label that is
+ only the start of a longer one does not count.
+ """
+ for line in lines:
+ text = line.strip()
+ if text.startswith("ok "):
+ text = text[len("ok "):].lstrip()
+ if not text.startswith(label):
+ continue
+ rest = text[len(label):]
+ if rest == "" or re.match(r"^\s+ok$", rest) or rest.startswith(" "):
+ return True
+
+ # The control pads a label to a fixed width, so a long one meets its
+ # first tree's column after a single space.
+ if re.match(r"^ [\w-]+=", rest):
+ return True
+ return False
+
+
+def trace(text, outputs):
+ """The problems with a requirements document against the self-tests'
+ output, and the count of rows of each kind.
+
+ `outputs` maps each module to the lines its self-test printed.
+ """
+ problems = []
+ counts = {"checked": 0, "untestable": 0, "gap": 0}
+ seen = set()
+ topic = None
+ last = None
+ for number, line in enumerate(text.splitlines(), 1):
+ heading = TOPIC.match(line)
+ if heading:
+ topic = heading.group(1)
+ continue
+ # Markdown allows a table row a few spaces either side.
+ line = line.strip()
+
+ # A rule's row that fails to parse, such as one with an empty last
+ # cell, would otherwise drop out of the trace and pass unchecked.
+ row = ROW.match(line)
+ if not row:
+ if re.match(r"^\|\s*FR-", line):
+ problems.append("line %d: a requirement row that does not "
+ "parse: %s" % (number, line))
+ continue
+ rule, rule_topic, index, _, cell = row.groups()
+ where = "line %d, %s" % (number, rule)
+
+ # An ID is cited from other documents, so it must be unique, sit
+ # under its own topic, and keep the order a reader looks it up by.
+ if rule in seen:
+ problems.append("%s: the ID is used twice" % where)
+ seen.add(rule)
+ if rule_topic != topic:
+ problems.append("%s: listed under topic %s" % (where, topic))
+ if last and (rule_topic, index) <= last:
+ problems.append("%s: out of order" % where)
+ last = (rule_topic, index)
+
+ if UNTESTABLE.match(cell):
+ counts["untestable"] += 1
+ continue
+ if GAP.match(cell):
+ counts["gap"] += 1
+ continue
+ if cell.startswith(("Gap", "Untestable")):
+ problems.append("%s: a gap names no issue, or an untestable rule "
+ "no reason" % where)
+ continue
+ good = True
+ for item in cell.split("
"):
+ cited = CITED.match(item.strip())
+ if not cited:
+ problems.append("%s: not a cited check: %s" % (where, item))
+ good = False
+ continue
+ module, label = cited.groups()
+ if module not in outputs:
+ problems.append("%s: no self-test named %s" % (where, module))
+ good = False
+ elif not printed(outputs[module], label):
+ problems.append('%s: %s prints no check "%s"'
+ % (where, module, label))
+ good = False
+ if good:
+ counts["checked"] += 1
+ if not seen:
+ problems.append("no requirement found")
+ return problems, counts
+
+
+def run_self_tests():
+ """Each module's self-test output, by module, running each in turn."""
+ outputs = {}
+
+ # A label is matched as text, so every child writes the encoding this
+ # reads, whatever the console's code page.
+ environment = dict(os.environ, PYTHONIOENCODING="utf-8")
+ for module in MODULES:
+ finished = subprocess.run(
+ [sys.executable, os.path.join(HERE, module), "--self-test"],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ env=environment, encoding="utf-8", errors="replace")
+ if finished.returncode != 0:
+ raise SystemExit("%s --self-test failed:\n%s"
+ % (module, finished.stdout))
+ outputs[module] = finished.stdout.splitlines()
+ return outputs
+
+
+def saved_outputs(directory):
+ """Each module's self-test output, read from files saved beforehand."""
+ outputs = {}
+ for module in MODULES:
+ path = os.path.join(directory, saved_name(module))
+ if os.path.exists(path):
+ with io.open(path, encoding="utf-8", errors="replace") as handle:
+ outputs[module] = handle.read().splitlines()
+ return outputs
+
+
+def self_test():
+ """Prove the trace passes a document whose every rule is accounted for,
+ and fails each way a rule can go unaccounted for."""
+ outputs = {
+ "a.py": [" a planted check ok",
+ " a planted check, longer ok",
+ "a label alone on its line"],
+ "b/b.py": [" ok a mutation landed base-1=no improved-1=yes",
+ " ok a mutation past the padding base-1=yes base-2=no"],
+ }
+
+ def document(*rows):
+ return "\n".join(("## 01 Topic", "", "| ID | Rule | Checked by |",
+ "|---|---|---|") + rows) + "\n"
+
+ def problems_of(*rows):
+ return trace(document(*rows), outputs)[0]
+
+ good = (
+ '| FR-01-01 | A rule. | `a.py` "a planted check"
'
+ '`b/b.py` "a mutation landed" |',
+ '| FR-01-02 | A rule. | `a.py` "a label alone on its line" |',
+ "| FR-01-04 | A rule. | Untestable: no script sees it. |",
+ "| FR-01-05 | A rule. | Gap: #12 |",
+ )
+ found, counts = trace(document(*good), outputs)
+ checks = [
+ ("every rule accounted for passes", found == [], found),
+ ("each kind of row is counted",
+ counts == {"checked": 2, "untestable": 1, "gap": 1}, counts),
+ ("a label no self-test prints fails",
+ len(problems_of('| FR-01-01 | A rule. | `a.py` "an absent check" |'))
+ == 1, None),
+ ("the start of a longer label is not a label",
+ len(problems_of('| FR-01-01 | A rule. | `a.py` "a planted" |')) == 1,
+ None),
+ ("a label is looked up only in its own module",
+ len(problems_of('| FR-01-01 | A rule. | `b/b.py` "a planted check" |'))
+ == 1, None),
+ ("a module with no self-test fails",
+ len(problems_of('| FR-01-01 | A rule. | `c.py` "a planted check" |'))
+ == 1, None),
+ ("a long label meets the trees' columns after one space",
+ problems_of('| FR-01-01 | A rule. | '
+ '`b/b.py` "a mutation past the padding" |') == [], None),
+ ("an indented row is still traced",
+ problems_of(good[0],
+ ' | FR-01-02 | A rule. | `a.py` "an absent check" |')
+ == ['line 6, FR-01-02: a.py prints no check "an absent check"'],
+ None),
+ ("a rule naming nothing fails",
+ len(problems_of("| FR-01-01 | A rule. | - |")) == 1, None),
+ ("a rule with an empty last cell fails",
+ len(problems_of(good[0], "| FR-01-02 | A rule. | |")) == 1, None),
+ ("a row with trailing spaces is still traced",
+ problems_of(good[0],
+ '| FR-01-02 | A rule. | `a.py` "an absent check" | ')
+ == ['line 6, FR-01-02: a.py prints no check "an absent check"'],
+ None),
+ ("a gap that names no issue fails",
+ len(problems_of("| FR-01-01 | A rule. | Gap: later |")) == 1, None),
+ ("an untestable rule with no reason fails",
+ len(problems_of("| FR-01-01 | A rule. | Untestable: |")) == 1, None),
+ ("an ID used twice fails",
+ len(problems_of(good[0], good[0])) == 2, None),
+ ("an ID out of order fails",
+ len(problems_of(good[1], good[0])) == 1, None),
+ ("an ID under another topic fails",
+ len(problems_of(good[0].replace("FR-01-01", "FR-02-01"))) == 1,
+ None),
+ ("a document with no requirement fails",
+ trace("# Requirements\n", outputs)[0] == ["no requirement found"],
+ None),
+ ]
+ for label, ok, got in checks:
+ print(" %-52s %s" % (label, "ok" if ok else "FAILED: %r" % (got,)))
+ passed = sum(1 for _, ok, _ in checks if ok)
+ lib.print_verdict(passed == len(checks),
+ "%d/%d self-test checks passed" % (passed, len(checks)))
+ return 0 if passed == len(checks) else 1
+
+
+def parse_args(argv):
+ parser = argparse.ArgumentParser(
+ description="Trace every requirement to the self-test checks that "
+ "prove it.")
+ parser.add_argument("--outputs",
+ help="a directory holding each self-test's output as "
+ ".txt; without it, every self-test runs")
+ parser.add_argument("--requirements", default=REQUIREMENTS,
+ help="the requirements document to trace")
+ parser.add_argument("--self-test", action="store_true",
+ help="prove the trace on planted documents; run no "
+ "self-test of another module")
+ return parser.parse_args(argv)
+
+
+def main(argv):
+ options = parse_args(argv)
+ if options.self_test:
+ return self_test()
+ outputs = (saved_outputs(options.outputs) if options.outputs
+ else run_self_tests())
+ with io.open(options.requirements, encoding="utf-8") as handle:
+ problems, counts = trace(handle.read(), outputs)
+ for problem in problems:
+ print(" " + problem)
+ lib.print_verdict(
+ not problems,
+ "%d rule(s) checked, %d untestable, %d gap(s), %d problem(s)"
+ % (counts["checked"], counts["untestable"], counts["gap"],
+ len(problems)))
+ return 0 if not problems else 1
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))