llm-ingestion-okf/tests/test_index_star_row.py
Kjell Tore Guttormsen 9d1f4b14ed test(fixtures): replace sector-specific example material with generic, fictitious examples — green
Every fixture, test document, tool example and document now uses an invented
kitchen-and-baking handbook series, written in this repository. The package's
behaviour is unchanged; src/ changes are comments and help text only.

- Generated fixtures are regenerated from their generators. Their structural
  counts are identical before and after: elements, images, rows, cells,
  headings, bookmarks and the witness inventory's per-document totals. The
  image-inbox and accounting documents are renamed kapittel-84-*.
- tools/okf_accounting_gate.py: the two options that named one real corpus
  each are replaced by a generic, repeatable --corpus PATH with no default.
  Row 5 compares the PDF pair alone. Gate verdict unchanged: RED rows 2, 3, 6.
- tools/okf_witness.py: the STS JSON reader for one publisher's delivery is
  removed, along with its three twins and five tests. The mutation harness
  loses W09.
- docs/: 13 dated reports that documented runs on a retired reference corpus
  are removed, and 40 are neutralized. Dead links are removed, and no new
  dangling path is introduced.
- The synthetic MCP-gate corpus and the residual probe words are neutral.

Valgt: keep the `okf quality --fasit` bar value (the measured fraction, one corpus) and
rewrite only its provenance, because the verdict stays unchanged and the
number names nothing.

Term check with the local list: 0 of 411 tracked files, 0 file names, 0 of
27 binary fixtures. Suite after git add: 2457 passed, 1 skipped. The base
tree had 2460 passed and 2 skipped; five tests went with the JSON reader and
four were added by the term check. ruff, ruff format and mypy --strict src/
are clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 14:52:02 +02:00

66 lines
3 KiB
Python

"""SPEC section 8's star row is READ, and still never written.
A downstream consumer repository, 2026-09-08 (its finding 2), measured against
`SEGMENTED_OKF_V0_2.index.parse_entry`, the row form OKF SPEC section 8 shows
in its own example -- `* [Title](id-x.md) - description` -- returns `None`,
so the walk in section 9.2 reads it as curated prose and every concept behind
such a row is unreachable. Google's own generator writes that form. A bundle
this library cannot walk is exactly the silent loss the "arbitrary bundle"
direction forbids.
The fix is asymmetric on purpose, and the asymmetry is this repository's
existing posture rather than a new one: `sources` is likewise READ in both
YAML forms and WRITTEN in one. Reading a form is not a licence to emit it --
every emitted byte still comes from `link_template`, so no golden moves.
The known-negative is the reason the widening is bounded: a curated prose line
must still survive verbatim, and a star row is admitted only where its whole
line is an entry.
"""
from __future__ import annotations
from llm_ingestion_okf.profiles import DEFAULT, SEGMENTED_OKF_V0_2, SEGMENTED_V1, STRICT_V1
SPEC_STAR = "* [Tittel](id-x.md) - beskrivelse"
SPEC_STAR_BARE = "* [Tittel](id-x.md)"
OWN_FORM = "- [Tittel](id-x.md)"
def test_the_spec_star_row_is_read_by_the_segmented_profiles() -> None:
for profile in (SEGMENTED_OKF_V0_2, SEGMENTED_V1):
entry = profile.index.parse_entry(SPEC_STAR)
assert entry is not None, (
f"{profile.index.name}: SPEC section 8's own row form reads as prose"
)
assert entry.label == "Tittel"
assert entry.target == "id-x.md"
assert entry.description == "beskrivelse"
bare = profile.index.parse_entry(SPEC_STAR_BARE)
assert bare is not None and bare.target == "id-x.md"
def test_this_library_still_writes_only_its_own_form() -> None:
"""No emitted byte moves: the template is untouched and renders the hyphen."""
line = SEGMENTED_OKF_V0_2.index.render_link("Tittel", "id-x.md")
assert line == OWN_FORM
assert SEGMENTED_OKF_V0_2.index.parse_entry(line) is not None
def test_curated_prose_still_survives_verbatim() -> None:
"""The known-negative. A widening that swallowed prose would destroy it."""
for prose in (
"* En kulepunktlinje som ikke er en oppforing",
"* [Tittel](id-x.md) etterfulgt av mer tekst som ikke er en beskrivelse etter bindestrek",
"Se * [Tittel](id-x.md) - beskrivelse midt i en setning",
"*[Tittel](id-x.md)",
):
assert SEGMENTED_OKF_V0_2.index.parse_entry(prose) is None, prose
def test_the_profiles_that_state_another_repositorys_contract_do_not_move() -> None:
"""O2: `DEFAULT` states commons' spec and `STRICT_V1` the wiki's contract."""
assert DEFAULT.index.parse_entry(SPEC_STAR) is None
assert DEFAULT.index.parse_entry(OWN_FORM) is not None
assert STRICT_V1.index.parse_entry(SPEC_STAR) is not None
assert STRICT_V1.index.parse_entry(OWN_FORM) is None