test(okf): navigation stays tolerant while the decoder refuses, proven by bytes

Co-Authored-By: Claude <claude-opus-5>
This commit is contained in:
Kjell Tore Guttormsen 2026-09-02 20:37:46 +02:00
commit 60e51ab76c

View file

@ -39,13 +39,18 @@ def _block_form_golden() -> tuple[str, str]:
def test_block_form_bundle_renders_the_captured_bytes() -> None:
"""Navigation is TOLERANT of block-form provenance, and these are the bytes it produces.
Two claims in one arm, and both are load-bearing. First, ``navigate_bundle`` reaches every
file and skips nothing a block ``verified:`` sequence is ordinary frontmatter to a
line-oriented parser, so it must not break navigation, and ``skipped`` being empty is the
positive statement that no link was silently passed over. Second, the rendered read-context
is byte-identical to the committed fasit. The fasit was generated by the code that predates
any decoder work: if it were regenerated afterwards, the comparison would prove an
implementation identical to itself and nothing else.
THREE claims on ONE fixture in ONE test, and the coexistence is the property (S7). First,
``navigate_bundle`` reaches every file and skips nothing a block ``verified:`` sequence is
ordinary frontmatter to a line-oriented parser, so it must not break navigation, and ``skipped``
being empty is the positive statement that no link was silently passed over. Second, the
decoder REFUSES the same document's ``sources``. Third, the rendered read-context is
byte-identical to the committed fasit. The fasit was generated by the code that predates any
decoder work: if it were regenerated afterwards, the comparison would prove an implementation
identical to itself and nothing else.
Splitting the refusal and the byte identity into two tests would lose exactly what is being
asserted that a decoder strict enough to refuse this document did not make navigation any
less tolerant of it.
"""
bundle_dir, expected = _block_form_golden()
bundle = okf.navigate_bundle(bundle_dir)
@ -55,6 +60,17 @@ def test_block_form_bundle_renders_the_captured_bytes() -> None:
)
assert [f.name for f in bundle.files] == ["index.md", "attested.md", "multi-verified.md"]
# (2) The decoder REFUSES the same document's `sources`, on the very same fixture. A refusal
# that reached navigation would be a coupling a correct design never creates.
sources = okf.read_provenance(Path(bundle_dir) / "attested.md", "sources")
assert isinstance(sources, okf.UnreadableProvenance)
assert sources.reason == "block-sequence"
# (3) And the bytes have not moved. This clause is the one a no-op cannot fake: tolerant
# navigation was ALREADY today's behaviour, so clauses (1) and (2) alone are green on a tree
# with none of this work in it. The commons nav-goldens carry no block-form provenance
# anywhere, so every existing byte fasit could stay green while the decoder broke navigation
# for real corpus documents — this repo-owned fixture is the one that could not.
assert okf.bundle_context(bundle) == expected