fix(tools): nothing to propose writes no artifact and is not a failure
Measured on the K2 corpus 2026-09-03: 11 of 39 documents proposed zero segments -- overwhelmingly PDFs with no declared structure, which Topic 1b had already measured at 23 of 33. The proposer wrote an artifact for each of them and exited 0. An empty plan cannot be replayed. `process_inbox` refuses one by design, because a plan naming no entry would persist nothing for a document that was dropped, so the only thing a zero-entry file can do is fail a run later -- and it did: the first segmented corpus run stopped on `segmentation_plan_invalid` before writing a single concept. Exit 1 with no artifact, distinct from 2, so a driver can tell "this document lands as one flat concept" from "stop". The orphan check's test now observes the same property through the status. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
a5e129d413
commit
bca722fa85
2 changed files with 61 additions and 2 deletions
|
|
@ -127,8 +127,13 @@ def test_a_heading_of_only_stop_words_is_not_a_boundary(tmp_path: Path) -> None:
|
|||
|
||||
|
||||
def test_a_heading_with_no_body_proposes_nothing(tmp_path: Path) -> None:
|
||||
payload = propose(tmp_path, source=write(tmp_path, "# Tom\n\n## Ogsaa tom\n"))
|
||||
assert payload["entries"] == []
|
||||
"""The orphan check, observed through the status now that a zero-entry plan
|
||||
is no longer written: proposing nothing and writing nothing are the same
|
||||
outcome, and it is distinct from failing."""
|
||||
out = tmp_path / "orphans.json"
|
||||
source = write(tmp_path, "# Tom\n\n## Ogsaa tom\n")
|
||||
assert okf_propose_segments.main([str(source), "--out", str(out)]) == 1
|
||||
assert not out.exists()
|
||||
|
||||
|
||||
def test_the_spans_it_proposes_are_slices_of_the_text_it_read(tmp_path: Path) -> None:
|
||||
|
|
@ -281,3 +286,42 @@ def test_a_prefix_that_reduces_to_nothing_is_refused(tmp_path: Path) -> None:
|
|||
)
|
||||
assert code == 2
|
||||
assert not (tmp_path / "p.json").exists()
|
||||
|
||||
|
||||
# --- nothing to propose is an outcome, and it is not an artifact -----------
|
||||
|
||||
|
||||
def test_a_document_with_no_proposable_structure_writes_no_artifact(tmp_path: Path) -> None:
|
||||
"""Measured on the K2 corpus 2026-09-03: 11 of 39 documents proposed zero
|
||||
segments -- overwhelmingly PDFs with no declared structure, which Topic 1b
|
||||
already measured at 23 of 33.
|
||||
|
||||
An empty artifact is not a plan a run can replay: `process_inbox` refuses
|
||||
one by design, because an empty plan would persist nothing for a document
|
||||
that was dropped. So the only use a zero-entry file has is to fail a run
|
||||
later, and writing it converts "this document proposes no split" into "this
|
||||
corpus cannot be built". It gets its own exit status instead: distinct from
|
||||
2, which means the tool could not do its job at all.
|
||||
"""
|
||||
flat = write(tmp_path, "Loepende tekst uten overskrifter i det hele tatt.\n", name="flat.md")
|
||||
out = tmp_path / "flat.json"
|
||||
assert okf_propose_segments.main([str(flat), "--out", str(out)]) == 1
|
||||
assert not out.exists()
|
||||
|
||||
|
||||
def test_nothing_to_propose_is_not_reported_as_a_failure(
|
||||
tmp_path: Path, capsys: pytest.CaptureFixture[str]
|
||||
) -> None:
|
||||
"""The two outcomes must be distinguishable by a driver reading the status:
|
||||
one means "this document lands as one flat concept", the other means "stop"."""
|
||||
flat = write(tmp_path, "Loepende tekst uten overskrifter i det hele tatt.\n", name="flat.md")
|
||||
assert okf_propose_segments.main([str(flat), "--out", str(tmp_path / "f.json")]) == 1
|
||||
nothing = capsys.readouterr().err
|
||||
assert "FAILED" not in nothing
|
||||
assert "nothing to propose" in nothing.lower()
|
||||
|
||||
assert (
|
||||
okf_propose_segments.main([str(tmp_path / "absent.md"), "--out", str(tmp_path / "a.json")])
|
||||
== 2
|
||||
)
|
||||
assert "FAILED" in capsys.readouterr().err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue