"""SPEC section 8's star row is READ, and still never written. vegnormal-okf, 2026-09-08 (FUNN 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