test_tool_tree_refusal.py

tests/test_tool_tree_refusal.py

A grid refuses to measure a clew tree it cannot name.

test_a_clean_clew_tree_passes

None test_tool_tree_refusal.test_a_clean_clew_tree_passes()

A clean clew tree at a known commit passes.

tests/test_tool_tree_refusal.py:58

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012inferredtest_a_clean_clew_tree_passes → check_tool_tree → tool_identity → _substrate → compiled_languages
Source · 7 lines
def test_a_clean_clew_tree_passes() -> None:
    """@brief Clean passes.
    @version 1
    """
    runner.check_tool_tree({"clew_commit": _SHA, "clew_dirty": False})

Activity · 1 steps
lines 62–62runner.check_tool_tree({"clew_commit": _SHA, "clew_dirty": False})

test_a_dirty_clew_tree_is_refused

None test_tool_tree_refusal.test_a_dirty_clew_tree_is_refused()

A modified clew tree is refused, and the refusal names the remedy.

tests/test_tool_tree_refusal.py:35

Checks

  • assert _SHA in str(raised.value), "the refusal does not name the commit it was measuring"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012inferredtest_a_dirty_clew_tree_is_refused → check_tool_tree → tool_identity → _substrate → compiled_languages
Source · 9 lines
def test_a_dirty_clew_tree_is_refused() -> None:
    """@brief Dirty refuses.
    @version 1
    """
    with pytest.raises(ValueError, match="(?i)modified") as raised:
        runner.check_tool_tree({"clew_commit": _SHA, "clew_dirty": True})
    assert _SHA in str(raised.value), "the refusal does not name the commit it was measuring"

Activity · 3 steps
lines 39–39with pytest.raises(ValueError, match="(?i)modified") as raisedlines 40–40runner.check_tool_tree({"clew_commit": _SHA, "clew_dirty": True})lines 41–41assert _SHA in str(raised.value), "the refusal does not name the commit it was measuring"

test_an_unknown_clew_tree_is_refused

None test_tool_tree_refusal.test_an_unknown_clew_tree_is_refused()

A clew tree git could not describe is refused.

tests/test_tool_tree_refusal.py:47

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012inferredtest_an_unknown_clew_tree_is_refused → check_tool_tree → tool_identity → _substrate → compiled_languages
Source · 8 lines
def test_an_unknown_clew_tree_is_refused() -> None:
    """@brief Unknown refuses — absence is not cleanliness.
    @version 1
    """
    with pytest.raises(ValueError, match="(?i)cannot"):
        runner.check_tool_tree({"clew_build_version": "9"})

Activity · 2 steps
lines 51–51with pytest.raises(ValueError, match="(?i)cannot")lines 52–52runner.check_tool_tree({"clew_build_version": "9"})

test_generate_refuses_a_dirty_clew_tree

None test_tool_tree_refusal.test_generate_refuses_a_dirty_clew_tree(Path tmp_path, monkeypatch, capsys)

generate refuses before spending a cell when the clew tree is dirty.

tests/test_tool_tree_refusal.py:71

Show on the map →

Called by none

Calls cmd_generate

Checks

  • assert cli.cmd_generate(args) == 1
  • assert not spent, f"{len(spent)} cell(s) were generated against a modified clew tree"
  • assert "REFUSED" in capsys.readouterr().err

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012inferredtest_generate_refuses_a_dirty_clew_tree → cmd_generate → tool_identity → _substrate → compiled_languages
Source · 28 lines
def test_generate_refuses_a_dirty_clew_tree(tmp_path: Path, monkeypatch, capsys) -> None:
    """THE TARGET CHECK IS STUBBED so the only reason left to refuse is the clew tree; without
    that, a missing target checkout would return 1 and this test would pass for the wrong reason.

    @brief generate refuses.
    @version 1
    """
    spent: list[str] = []
    monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)
    monkeypatch.setattr(cli, "run_cell", lambda cell, *_a, **_k: spent.append(cell.stem()))
    monkeypatch.setattr(runner, "tool_identity", lambda: {"clew_commit": _SHA, "clew_dirty": True})
    args = cli.argparse.Namespace(
        rubric=_MBEDTLS,
        models=["claude-haiku-5-5"],
        replicates=1,
        seed=7,
        repo=tmp_path / "repo",
        out=tmp_path / "answers",
        mcp_config=None,
        timeout=60,
        resume=False,
    )

    assert cli.cmd_generate(args) == 1
    assert not spent, f"{len(spent)} cell(s) were generated against a modified clew tree"
    assert "REFUSED" in capsys.readouterr().err

Activity · 8 steps
lines 78–78spent: list[str] = []lines 79–79monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)lines 80–80monkeypatch.setattr(cli, "run_cell", lambda cell, *_a, **_k: spent.append(cell.stem()))lines 81–81monkeypatch.setattr(runner, "tool_identity", lambda: {"clew_commit": _SHA, "clew_dirty": True})lines 82–92args = cli.argparse.Namespace( rubric=_MBEDTLS, models=["claude-haiku-5-5"], replicates=1, seed=7, repo=tmp_path / "repo", out=tmp_path / "answers", mcp_config=None, timeout=60, resume=False, )lines 94–94assert cli.cmd_generate(args) == 1lines 95–95assert not spent, f"{len(spent)} cell(s) were generated against a modified clew tree"lines 96–96assert "REFUSED" in capsys.readouterr().err

test_provision_refuses_a_dirty_clew_tree

None test_tool_tree_refusal.test_provision_refuses_a_dirty_clew_tree(Path tmp_path, monkeypatch)

provision refuses before fetching when the clew tree is dirty.

tests/test_tool_tree_refusal.py:104

Show on the map →

Called by none

Calls provision

Checks

  • assert not fetched, "the target was fetched for a clew tree that was going to be refused"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012inferredtest_provision_refuses_a_dirty_clew_tree → provision → write_provision_record → tool_identity → _substrate → compiled_languages
Source · 14 lines
def test_provision_refuses_a_dirty_clew_tree(tmp_path: Path, monkeypatch) -> None:
    """BEFORE THE FETCH, because the fetch and the index build are the expensive steps and a
    dirty tree makes both worthless.

    @brief provision refuses.
    @version 1
    """
    fetched: list[Path] = []
    monkeypatch.setattr(provision, "fetch_pinned", lambda _r, repo: fetched.append(repo))
    monkeypatch.setattr(runner, "tool_identity", lambda: {"clew_commit": _SHA, "clew_dirty": True})

    with pytest.raises(provision.ProvisionError, match="(?i)modified"):
        provision.provision(load(_MBEDTLS), tmp_path / "mbedtls")
    assert not fetched, "the target was fetched for a clew tree that was going to be refused"

1 more lines, not shown

Activity · 6 steps
lines 111–111fetched: list[Path] = []lines 112–112monkeypatch.setattr(provision, "fetch_pinned", lambda _r, repo: fetched.append(repo))lines 113–113monkeypatch.setattr(runner, "tool_identity", lambda: {"clew_commit": _SHA, "clew_dirty": True})lines 115–115with pytest.raises(provision.ProvisionError, match="(?i)modified")lines 116–116provision.provision(load(_MBEDTLS), tmp_path / "mbedtls")lines 117–117assert not fetched, "the target was fetched for a clew tree that was going to be refused"