test_acceptance_identity.py¶
tests/test_acceptance_identity.py
What produced a number, recorded beside it.
test_a_dated_model_is_not_recorded_as_floating
None test_acceptance_identity.test_a_dated_model_is_not_recorded_as_floating(Path tmp_path, monkeypatch)
A dated model must not be recorded as floating.
tests/test_acceptance_identity.py:444
Checks
assert cli.cmd_generate(args) == 0assert "models_floating" not in window, f"a dated id was reported as floating: {window}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_a_dated_model_is_not_recorded_as_floating → cmd_generate → tool_identity → _substrate → compiled_languages |
Source · 42 lines
def test_a_dated_model_is_not_recorded_as_floating(tmp_path: Path, monkeypatch) -> None:
"""ABSENT RATHER THAN EMPTY. A run where nothing floated carries no `models_floating` key at
all, so "nothing floated" and "nobody checked" cannot read alike — and a reader who finds the
key knows it means something.
@brief Dated models are not flagged.
@return None.
@version 1
"""
import json
from acceptance import __main__ as cli
from acceptance import execute
FREERTOS = Path(__file__).resolve().parent.parent / "acceptance/targets/freertos/questions.yaml"
monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)
## FIXTURE, NOT BEHAVIOUR: `generate` now refuses a modified clew tree, and this test runs
## in a working checkout. The tree check is covered by tests/test_tool_tree_refusal.py.
monkeypatch.setattr(cli, "check_tool_tree", lambda *_a, **_k: None)
monkeypatch.setattr(
cli,
"run_cell",
lambda cell, *_a, **_k: execute.CellResult(cell.stem(), cell.arm, cell.model, ok=True),
)
out = tmp_path / "answers"
args = cli.argparse.Namespace(
rubric=FREERTOS,
models=["claude-sonnet-4-5-20250929"],
replicates=1,
seed=7,
repo=tmp_path / "repo",
out=out,
mcp_config=None,
timeout=60,
resume=False,
)
assert cli.cmd_generate(args) == 0
window = json.loads((out / "run.json").read_text())["windows"][-1]
assert "models_floating" not in window, f"a dated id was reported as floating: {window}"
Activity · 12 steps
test_a_field_that_could_not_be_read_is_dropped_rather_than_blanked
None test_acceptance_identity.test_a_field_that_could_not_be_read_is_dropped_rather_than_blanked()
An unreadable field is absent, never empty.
tests/test_acceptance_identity.py:60
Checks
assert "clew_commit" not in blank, "a sha that could not be read is not the empty sha"assert "clew_dirty" not in blank, "and nothing may claim the tree was clean"assert blank["clew_version"]assert blank["substrate_languages"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_a_field_that_could_not_be_read_is_dropped_rather_than_blanked → tool_identity → _substrate → compiled_languages |
Source · 18 lines
def test_a_field_that_could_not_be_read_is_dropped_rather_than_blanked() -> None:
""" "NOBODY MEASURED" AND "NOTHING THERE" MUST NOT READ ALIKE. An empty string or an empty
list in a published record reads as a finding; the key's absence reads as a gap. This is the
same rule `clew/mcp_server/emptiness.py` enforces on the served scope.
@brief Unreadable fields are omitted.
@return None.
@version 1
"""
blank = identity.tool_identity(repo=Path("/nonexistent-tree-for-this-test"))
assert "clew_commit" not in blank, "a sha that could not be read is not the empty sha"
assert "clew_dirty" not in blank, "and nothing may claim the tree was clean"
## The fields that do not come from git are still there — a missing checkout is not a
## missing install.
assert blank["clew_version"]
assert blank["substrate_languages"]
Activity · 5 steps
test_a_floating_model_is_accepted_and_recorded_as_floating
None test_acceptance_identity.test_a_floating_model_is_accepted_and_recorded_as_floating(Path tmp_path, monkeypatch)
A floating canonical model must be accepted and named in the window record.
tests/test_acceptance_identity.py:389
Checks
assert cli.cmd_generate(args) == 0, "a current-family model was refused; the harness is blocked"assert window["models_floating"] == ["claude-haiku-5-5"], (f"the run accepted a floating id without recording it: {window}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_a_floating_model_is_accepted_and_recorded_as_floating → cmd_generate → tool_identity → _substrate → compiled_languages |
Source · 49 lines
def test_a_floating_model_is_accepted_and_recorded_as_floating(tmp_path: Path, monkeypatch) -> None:
"""**ACCEPTANCE WITHOUT DISCLOSURE WOULD REPRODUCE THE ORIGINAL DEFECT.** 1.1.0 answered with
a floating id and recorded nothing about it. A date requirement then rejected every
current-family model and blocked the harness, so the ruling is that the grid tracks the models
and the run says which ids can move.
Both halves asserted together: the run must SUCCEED on `claude-haiku-5-5` and must NAME it as
floating. A change that accepted it silently passes the first assertion alone.
@brief Floating models are accepted and disclosed.
@return None.
@version 1
"""
import json
from acceptance import __main__ as cli
from acceptance import execute
FREERTOS = Path(__file__).resolve().parent.parent / "acceptance/targets/freertos/questions.yaml"
monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)
## FIXTURE, NOT BEHAVIOUR: `generate` now refuses a modified clew tree, and this test runs
## in a working checkout. The tree check is covered by tests/test_tool_tree_refusal.py.
monkeypatch.setattr(cli, "check_tool_tree", lambda *_a, **_k: None)
monkeypatch.setattr(
cli,
"run_cell",
lambda cell, *_a, **_k: execute.CellResult(cell.stem(), cell.arm, cell.model, ok=True),
)
out = tmp_path / "answers"
args = cli.argparse.Namespace(
rubric=FREERTOS,
models=["claude-haiku-5-5"],
replicates=1,
seed=7,
repo=tmp_path / "repo",
out=out,
mcp_config=None,
timeout=60,
resume=False,
)
assert cli.cmd_generate(args) == 0, "a current-family model was refused; the harness is blocked"
window = json.loads((out / "run.json").read_text())["windows"][-1]
assert window["models_floating"] == ["claude-haiku-5-5"], (
f"the run accepted a floating id without recording it: {window}"
)
Activity · 12 steps
test_a_stale_editable_install_does_not_silently_misstate_the_version
None test_acceptance_identity.test_a_stale_editable_install_does_not_silently_misstate_the_version(tmp_path, monkeypatch)
The recorded version is the checkout's, and a stale install is disclosed not hidden.
tests/test_acceptance_identity.py:491
Checks
assert out["clew_version"] == "9.9.9"assert out["clew_version_installed"] == "1.1.0"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_a_stale_editable_install_does_not_silently_misstate_the_version → tool_identity → _substrate → compiled_languages |
Source · 25 lines
def test_a_stale_editable_install_does_not_silently_misstate_the_version(
tmp_path, monkeypatch
) -> None:
"""FOUND ON A REAL PRE-FLIGHT, NOT IMAGINED. `pip install -e .` writes the version into
`.dist-info` ONCE; bumping `pyproject.toml` afterwards does not rewrite it. Three
`provision.json` files for the 1.2.0 grid therefore stamped `clew_version: 1.1.0` onto a
1.1.3 tree, and nothing said so — a wrong measurement presented as a fact, which is worse
than an absent one.
THE CHECKOUT WINS, because the pyproject in the tree describes the code that will run; the
installed metadata describes an install event that is over. The stale value is KEPT under
its own key rather than dropped, since "the operator's environment disagrees with the tree"
is itself evidence a reader of a published number wants.
@brief The checkout's version is recorded, and disagreement is disclosed.
@return None.
@version 1
"""
(tmp_path / "pyproject.toml").write_text('[project]\nname = "clew-trace"\nversion = "9.9.9"\n')
monkeypatch.setattr(identity, "_installed_version", lambda: "1.1.0")
out = identity.tool_identity(tmp_path)
assert out["clew_version"] == "9.9.9"
assert out["clew_version_installed"] == "1.1.0"
Activity · 5 steps
test_agreement_records_one_version_and_no_disagreement_key
None test_acceptance_identity.test_agreement_records_one_version_and_no_disagreement_key(tmp_path, monkeypatch)
When install and checkout agree, no disagreement key is invented.
tests/test_acceptance_identity.py:521
Checks
assert out["clew_version"] == "9.9.9"assert "clew_version_installed" not in out
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_agreement_records_one_version_and_no_disagreement_key → tool_identity → _substrate → compiled_languages |
Source · 13 lines
def test_agreement_records_one_version_and_no_disagreement_key(tmp_path, monkeypatch) -> None:
"""A FIELD THAT DOES NOT APPLY IS ABSENT. `clew_version_installed` present and equal would
read as a flag raised on every record, which is how a real flag stops being noticed.
@brief No spurious disagreement field.
@return None.
@version 1
"""
(tmp_path / "pyproject.toml").write_text('[project]\nname = "clew-trace"\nversion = "9.9.9"\n')
monkeypatch.setattr(identity, "_installed_version", lambda: "9.9.9")
out = identity.tool_identity(tmp_path)
assert out["clew_version"] == "9.9.9"
assert "clew_version_installed" not in out1 more lines, not shown
Activity · 5 steps
test_each_generate_appends_a_window_rather_than_overwriting
None test_acceptance_identity.test_each_generate_appends_a_window_rather_than_overwriting(Path tmp_path, monkeypatch)
Each generate must append a window record rather than overwrite the previous one.
tests/test_acceptance_identity.py:320
Checks
assert len(first) == 1, f"the first generate recorded {len(first)} window(s)"assert [w["ordinal"] for w in windows] == [1, 2], (f"windows did not accumulate in order; got {[w.get('ordinal') for w in windows]}" )assert windows[0] == first[0], "the first window's record was rewritten by the second"assert "clew_build_version" in windows[1], (f"a window carries no tool identity, so it cannot be attributed: {windows[1]}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_each_generate_appends_a_window_rather_than_overwriting → cmd_generate → tool_identity → _substrate → compiled_languages |
Source · 63 lines
def test_each_generate_appends_a_window_rather_than_overwriting(
tmp_path: Path, monkeypatch
) -> None:
"""**THE 1.1.0 GRID CANNOT SAY HOW MANY SITTINGS BUILT IT.** `resumed` recorded which stems
came from before — the right fact — but every `generate` REWROTE `run.json`, so after three
capacity windows the record described only the last one. A grid assembled over several windows
must not read as one pass.
TWO WINDOWS ARE RUN AND BOTH ARE ASSERTED PRESENT, in order, with the first one's identity
still intact. Asserting only `len(windows) == 2` would pass an implementation that appended a
fresh pair each time, and asserting only the last would pass the overwrite this fixes.
@brief Windows accumulate across generate invocations.
@return None.
@version 1
"""
import json
from acceptance import __main__ as cli
from acceptance import execute
FREERTOS = Path(__file__).resolve().parent.parent / "acceptance/targets/freertos/questions.yaml"
monkeypatch.setattr(
cli,
"run_cell",
lambda cell, *_a, **_k: execute.CellResult(cell.stem(), cell.arm, cell.model, True),
)
monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)
## FIXTURE, NOT BEHAVIOUR: `generate` now refuses a modified clew tree, and this test runs
## in a working checkout. The tree check is covered by tests/test_tool_tree_refusal.py.
monkeypatch.setattr(cli, "check_tool_tree", lambda *_a, **_k: None)
out = tmp_path / "answers"
def once(resume: bool) -> None:
cli.cmd_generate(
cli.argparse.Namespace(
rubric=FREERTOS,
models=["claude-sonnet-4-5-20250929"],
replicates=1,
seed=7,
repo=tmp_path / "repo",
out=out,
mcp_config=None,
timeout=60,
resume=resume,
)
)
once(resume=False)
first = json.loads((out / "run.json").read_text())["windows"]
once(resume=True)
windows = json.loads((out / "run.json").read_text())["windows"]
assert len(first) == 1, f"the first generate recorded {len(first)} window(s)"
assert [w["ordinal"] for w in windows] == [1, 2], (
f"windows did not accumulate in order; got {[w.get('ordinal') for w in windows]}"
)
assert windows[0] == first[0], "the first window's record was rewritten by the second"
assert "clew_build_version" in windows[1], (
f"a window carries no tool identity, so it cannot be attributed: {windows[1]}"
)
Activity · 17 steps
test_generate_refuses_a_shortcut_answering_model
None test_acceptance_identity.test_generate_refuses_a_shortcut_answering_model(Path tmp_path, monkeypatch)
generate must refuse an answering model that is a client-resolved shortcut.
tests/test_acceptance_identity.py:267
Checks
assert cli.cmd_generate(args) == 1, "a client-resolved shortcut was accepted"assert not spent, f"cells were spent before the refusal: {spent}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_generate_refuses_a_shortcut_answering_model → cmd_generate → tool_identity → _substrate → compiled_languages |
Source · 47 lines
def test_generate_refuses_a_shortcut_answering_model(tmp_path: Path, monkeypatch) -> None:
"""**THIS IS THE 1.1.0 GAP, NARROWED BY A LATER RULING.** The judge was checked from the first
release and the model being GRADED was never asked, so the published grid was judged by
`claude-sonnet-4-5-20250929` and answered by `claude-haiku-5-5` with nothing recording it.
v2: the fixture is `sonnet`, not `claude-haiku-5-5`. A first fix demanded a DATED id and
thereby rejected every current-family model, blocking the harness; the owner ruled that the
grid should move with the models and that the requirement is faithful recording, not
immutability. A client-resolved shortcut is still refused, because the client maps it through
configuration this harness never records.
It refuses BEFORE any cell runs: `run_cell` is replaced with something that records being
called, and the assertion is that it never was. A check that refused after spending the grid
would pass a test that only looked at the exit code.
@brief An alias answering model is refused before spending anything.
@return None.
@version 1
"""
import json # noqa: F401
from acceptance import __main__ as cli
FREERTOS = Path(__file__).resolve().parent.parent / "acceptance/targets/freertos/questions.yaml"
spent: list[str] = []
monkeypatch.setattr(cli, "run_cell", lambda cell, *_a, **_k: spent.append(cell.stem()))
monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)
## FIXTURE, NOT BEHAVIOUR: `generate` now refuses a modified clew tree, and this test runs
## in a working checkout. The tree check is covered by tests/test_tool_tree_refusal.py.
monkeypatch.setattr(cli, "check_tool_tree", lambda *_a, **_k: None)
out = tmp_path / "answers"
args = cli.argparse.Namespace(
rubric=FREERTOS,
models=["sonnet"],
replicates=1,
seed=7,
repo=tmp_path / "repo",
out=out,
mcp_config=None,
timeout=60,
resume=False,
)
assert cli.cmd_generate(args) == 1, "a client-resolved shortcut was accepted"
assert not spent, f"cells were spent before the refusal: {spent}"
Activity · 11 steps
test_identity_records_the_clew_and_substrate_under_test
None test_acceptance_identity.test_identity_records_the_clew_and_substrate_under_test()
The identity names the tool, not only what was asked of it.
tests/test_acceptance_identity.py:22
Checks
assert got["clew_version"]assert len(got["clew_commit"]) == 40, "a short sha is ambiguous across a fork"assert isinstance(got["clew_dirty"], bool), "a measurement, present even when False"assert got["clew_build_version"] == str(identity.CLEW_BUILD_VERSION)assert got["substrate_version"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_identity_records_the_clew_and_substrate_under_test → tool_identity → _substrate → compiled_languages |
Source · 17 lines
def test_identity_records_the_clew_and_substrate_under_test() -> None:
"""`run.json` recorded target, commit, rubric version and digest, seed, models and
replicates — every input except the one thing the grid is a measurement OF. A reader could
not tell a score produced by 1.1.0 from one produced by 1.0.39.
@brief The identity carries clew and substrate.
@return None.
@version 1
"""
got = identity.tool_identity()
assert got["clew_version"]
assert len(got["clew_commit"]) == 40, "a short sha is ambiguous across a fork"
assert isinstance(got["clew_dirty"], bool), "a measurement, present even when False"
assert got["clew_build_version"] == str(identity.CLEW_BUILD_VERSION)
assert got["substrate_version"]
Activity · 6 steps
test_provision_writes_a_record_naming_the_build
None test_acceptance_identity.test_provision_writes_a_record_naming_the_build(Path tmp_path)
A provisioned target leaves a record naming the build, not just the pin.
tests/test_acceptance_identity.py:81
Checks
assert got["commit"] == rubric.commitassert got["build_version"] == "8"assert "substrate_languages" in gotassert got["clew_build_version"] == str(identity.CLEW_BUILD_VERSION)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_provision_writes_a_record_naming_the_build → write_provision_record → tool_identity → _substrate → compiled_languages |
Source · 32 lines
def test_provision_writes_a_record_naming_the_build(tmp_path: Path) -> None:
"""`build_version` WAS READ AND ONLY PRINTED. It survived a run only if the operator
redirected stdout, and the database that carries it is gitignored on purpose. So the one
number describing the index under test reached no committed file.
@brief provision.json carries the build.
@return None.
@version 1
"""
import json
from acceptance import provision
from acceptance.grader.rubric import load
rubric = load(
Path(__file__).resolve().parent.parent / "acceptance/targets/mbedtls/questions.yaml"
)
out = tmp_path / "provision.json"
provision.write_provision_record(
rubric,
tmp_path / "clew.db",
{"build_version": "8", "tool.substrate_version": "0.11.2"},
out,
)
got = json.loads(out.read_text())
assert got["commit"] == rubric.commit
assert got["build_version"] == "8"
## THE FIELD A VERSION STRING CANNOT SUBSTITUTE FOR.
assert "substrate_languages" in got
assert got["clew_build_version"] == str(identity.CLEW_BUILD_VERSION)
Activity · 11 steps
test_run_json_carries_the_tool_identity
None test_acceptance_identity.test_run_json_carries_the_tool_identity(Path tmp_path, monkeypatch)
The run record names the tool as well as the inputs.
tests/test_acceptance_identity.py:116
Checks
assert cli.cmd_generate(args) == 0assert got["clew_build_version"] == str(identity.CLEW_BUILD_VERSION)assert "substrate_languages" in got
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_run_json_carries_the_tool_identity → cmd_generate → tool_identity → _substrate → compiled_languages |
Source · 47 lines
def test_run_json_carries_the_tool_identity(tmp_path: Path, monkeypatch) -> None:
"""A reader holding only `answers/` must still be able to attribute the numbers. Provisioning
records the same fields, but its file sits beside a gitignored database and a run assembled
over several windows may be re-provisioned between them.
@brief run.json carries clew.
@return None.
@version 1
"""
import json
from acceptance import __main__ as cli
from acceptance import execute
monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)
## FIXTURE, NOT BEHAVIOUR: `generate` now refuses a modified clew tree, and this test runs
## in a working checkout. The tree check is covered by tests/test_tool_tree_refusal.py.
monkeypatch.setattr(cli, "check_tool_tree", lambda *_a, **_k: None)
monkeypatch.setattr(
cli,
"run_cell",
lambda cell, *_a, **_k: execute.CellResult(
cell.stem(), cell.arm, cell.model, True, tool_calls=1
),
)
rubric = Path(__file__).resolve().parent.parent / "acceptance/targets/freertos/questions.yaml"
out = tmp_path / "answers"
args = cli.argparse.Namespace(
rubric=rubric,
## FIXTURE, NOT BEHAVIOUR. This said `m` (resp. `sonnet`) until `--models` began
## refusing an alias. What this test guards is unchanged; only the example string
## had to become a real pinned id to reach the code under test.
models=["claude-sonnet-4-5-20250929"],
replicates=1,
seed=7,
repo=tmp_path,
out=out,
mcp_config=None,
timeout=60,
resume=False,
)
assert cli.cmd_generate(args) == 0
got = json.loads((out / "run.json").read_text())
assert got["clew_build_version"] == str(identity.CLEW_BUILD_VERSION)
assert "substrate_languages" in got
Activity · 13 steps
test_the_substrate_language_set_is_recorded_not_just_its_version
None test_acceptance_identity.test_the_substrate_language_set_is_recorded_not_just_its_version()
The language set is what distinguishes the fork, so it is recorded as a set.
tests/test_acceptance_identity.py:42
Checks
assert langs == sorted(langs), "recorded sorted, so two runs diff rather than reorder"assert "c" in langs and "python" in langs
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_the_substrate_language_set_is_recorded_not_just_its_version → tool_identity → _substrate → compiled_languages |
Source · 15 lines
def test_the_substrate_language_set_is_recorded_not_just_its_version() -> None:
"""THE VERSION STRING CANNOT SETTLE THIS. The fork carrying 1.1.0's five grammars reports
`0.11.2`, byte-identical to the published wheel, because the pull request carries no bump —
which is the whole reason `clew.substrate` exists. A run record holding only the version
cannot say which wheel answered, so it holds the compiled-in keys.
@brief Languages are recorded.
@return None.
@version 1
"""
langs = identity.tool_identity()["substrate_languages"]
assert langs == sorted(langs), "recorded sorted, so two runs diff rather than reorder"
assert "c" in langs and "python" in langs