feat(fase1): dimension filter on bundle_context, default unchanged (F1)

This commit is contained in:
Kjell Tore Guttormsen 2026-07-07 07:44:33 +02:00
commit 525ff0dda1
2 changed files with 54 additions and 2 deletions

View file

@ -75,6 +75,49 @@ def test_bundle_context_excludes_verdict_layer() -> None:
assert "progressiv disclosure" in context.lower() # the index summary is the entry point
def _dimension_bundle(tmp_path) -> str:
(tmp_path / "index.md").write_text(
"---\ntype: index\n---\n\n# Bundle\n\n"
"- [energi](energi-method.md)\n"
"- [asfalt](asfalt-method.md)\n"
"- [shared](shared-note.md)\n"
"- [verdict](verdict-x.md)\n",
encoding="utf-8",
)
(tmp_path / "energi-method.md").write_text(
"---\ntype: methodology\ndimension: energi\n---\n\nENERGI-SENTINEL body\n", encoding="utf-8"
)
(tmp_path / "asfalt-method.md").write_text(
"---\ntype: methodology\ndimension: asfalt\n---\n\nASFALT-SENTINEL body\n", encoding="utf-8"
)
(tmp_path / "shared-note.md").write_text(
"---\ntype: reference\n---\n\nSHARED-SENTINEL body\n", encoding="utf-8"
)
(tmp_path / "verdict-x.md").write_text(
"---\ntype: verdict\ndimension: energi\n---\n\nVERDICT-SENTINEL body\n", encoding="utf-8"
)
return str(tmp_path)
def test_bundle_context_dimension_filter(tmp_path) -> None:
"""SC7 forutsetning: with ``dimension="energi"`` only energi-marked + unmarked concept files
render; an asfalt-marked file is omitted. ``dimension=None`` is byte-identical to the no-arg
call (backward compat protects the verdict-exclusion + step7/8 load-bearing tests).
``type: verdict`` stays excluded in every case."""
bundle = okf.navigate_bundle(_dimension_bundle(tmp_path))
scoped = okf.bundle_context(bundle, dimension="energi")
assert "ENERGI-SENTINEL" in scoped # energi-marked concept file rendered
assert "SHARED-SENTINEL" in scoped # unmarked knowledge is never dropped
assert "ASFALT-SENTINEL" not in scoped # other-dimension file filtered out
assert "VERDICT-SENTINEL" not in scoped # verdict layer still excluded
default = okf.bundle_context(bundle)
assert okf.bundle_context(bundle, dimension=None) == default # None == today, byte-identical
assert "ASFALT-SENTINEL" in default # no filter -> asfalt present
assert "VERDICT-SENTINEL" not in default # verdict still excluded
def test_navigate_tolerates_broken_links(tmp_path) -> None:
"""OKF SPEC §4: a consumer MUST tolerate broken links. An index linking a missing file
navigates without raising, simply omitting the absent target."""