test(accounting): a document refused whole is never clean (H1, red)

PM's checkpoint of ed8d9d7 measured it: an inbox holding one refused
document and one accepted one gave `clean = 4 of 4`, `refused_whole =
None` and `okf build` exit 0, while three elements of `avvist.html`
were gone unseen. `refused_whole` asks its question only when the
corpus persisted NOTHING, and a refused document's own unit balances
by construction -- every element booked as a coded rejection is u = 0
and d = 0.

Three tests, all red on the claim and not on an import:

- the unit of a document the build refused is not clean, and its note
  names the code;
- the same beside a PERSISTED neighbour, which is the ordinary case on
  a heterogeneous corpus, with row 3 RED and the source named in the
  detail line;
- `okf build`'s own report says how many of M documents it refused
  whole -- the exit code belongs to the whole run, so the count has to
  stand in the accounting and in `log.md` or the loss is silent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-09-19 05:44:54 +02:00
commit 5d1060d467
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
2 changed files with 64 additions and 2 deletions

View file

@ -281,6 +281,25 @@ def test_a_rejected_documents_elements_carry_its_code(tmp_path: Path) -> None:
]
def test_a_partly_refused_corpus_says_how_many_sources_it_lost(tmp_path: Path) -> None:
"""H1's other half. The gate judges the report; this pins what the report
SAYS. One refused source beside an accepted one exits 0 -- the exit code
belongs to the whole run and a corpus with an unreadable file in it is the
ordinary case -- so the count has to stand in the accounting and the log,
or the loss is silent."""
inbox = tmp_path / "inbox"
inbox.mkdir()
shutil.copy(REJECTED / "avvist.html", inbox / "avvist.html")
shutil.copy(CORPUS / "notat.md", inbox / "notat.md")
path = tmp_path / "a.json"
code, bundle, _ = _build(inbox, tmp_path, "--accounting", str(path))
data = json.loads(path.read_text(encoding="utf-8"))
log = (bundle / "log.md").read_text(encoding="utf-8")
assert code == 0, "the build persisted a document; the exit code is the run's"
assert data["refused"] == 1
assert "1 of 2 document(s) refused whole" in log
def test_a_lost_paragraph_is_found_and_fails_the_build(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None: