refactor(examples): replace sector-specific example material with generic, fictitious examples
The context sets, the packaged knowledge bases and the example bundles are replaced by one fictitious example set about IT operations in an invented organisation: three context sets (serverrom-2027, driftsavtale-2027 and the two-base drift-og-avtale-2027), two synthetic knowledge bases under src/portfolio_optimiser/data/kunnskapsbaser and two example bundles under src/portfolio_optimiser/data/bundles. Numbers, codes and structural values in tests and fixtures are kept; names, ids and wording change. Dated measurement documents that only recorded runs on the replaced material are deleted. Gate figures measured on the new set are not comparable with earlier ones. The exclusion gate from the previous commit is green: 0 tracked files hit outside the shared/ subtree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
058dd25570
commit
37547fe292
1147 changed files with 24138 additions and 9503 deletions
|
|
@ -1,17 +1,18 @@
|
|||
"""P13b: a BLOCK sequence of mappings is provenance po can read, not provenance po cannot.
|
||||
|
||||
RED-FIRST, measured 2026-09-12 with the full denominator: every concept file in all four delivered
|
||||
knowledge bases writes ``sources`` as a BLOCK sequence — n100 446/446, n200 1133/1133, n500 270/270,
|
||||
r761 2756/2756, **4605 of 4605, and 0 in flow form**. ``read_provenance`` answered
|
||||
``UnreadableProvenance(reason="block-sequence")`` for every one of them, so ``evidence_for`` reported
|
||||
``state="unreadable"`` on 4605 of 4605 documents: the falsification layer had no address for any
|
||||
document in any base po is about to be stress-tested against.
|
||||
RED-FIRST, measured 2026-09-12 with the full denominator: every concept file in all four
|
||||
knowledge bases delivered at the time wrote ``sources`` as a BLOCK sequence — **4605 of 4605, and 0
|
||||
in flow form**. ``read_provenance`` answered ``UnreadableProvenance(reason="block-sequence")`` for
|
||||
every one of them, so ``evidence_for`` reported ``state="unreadable"`` on 4605 of 4605 documents:
|
||||
the falsification layer had no address for any document in any base po was about to be
|
||||
stress-tested against. The package's two example bases write the same form (``sources`` read as
|
||||
entries in 306 of 306 and 301 of 301 concept files, re-measured below rather than quoted).
|
||||
|
||||
**This widens the READER and nothing else.** The producer still EMITS flow (measured: okf's
|
||||
``materialize._render_sources`` is unchanged in 0.8.5), so no bundle bytes move, and
|
||||
``write_concept_file``/``verified_field`` still refuse what the flow decoder refuses — the writer
|
||||
keeps refusing exactly what the reader could not read, which is the property the round-trip gate
|
||||
exists for. What changes is that a form the producer's own SPEC §5.1 documents, and that four
|
||||
exists for. What changes is that a form the producer's own SPEC §5.1 documents, and that the
|
||||
delivered bases actually use, stops being reported as unreadable.
|
||||
|
||||
**Two refusals are KEPT, and they are this file's discriminators.** ``block-mapping`` (an indented
|
||||
|
|
@ -32,14 +33,16 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from portfolio_optimiser import okf
|
||||
from portfolio_optimiser import frozen_bundles, okf
|
||||
|
||||
_FIXTURES = Path(__file__).resolve().parent / "fixtures" / "p13b-block-sources"
|
||||
|
||||
#: A byte-identical copy of a REAL delivered concept file (n100-2023, `krav/N100/
|
||||
#: id-2b69893f-…md`, sha1 8c2952d1…). Read from the producer's tree, never written there. A
|
||||
#: hand-written approximation would prove the reader handles what I imagined the form to be.
|
||||
_REAL = _FIXTURES / "n100-krav-4-2-5-1-3.md"
|
||||
#: A byte-identical copy of a REAL concept file of the example base (driftskrav-2027,
|
||||
#: ``krav/D100/id-7aed3659-…md``, sha1 0242b9f9…) — pinned byte-for-byte by the arm below, so it
|
||||
#: cannot drift from what the base ships. A hand-written approximation would prove the reader
|
||||
#: handles what I imagined the form to be.
|
||||
_REAL = _FIXTURES / "driftskrav-krav-4-2-5-1-3.md"
|
||||
_REAL_IN_BASE = "krav/D100/id-7aed3659-dbbe-5eb5-9b96-e6a693ff0c3c.md"
|
||||
|
||||
|
||||
def _write(tmp_path: Path, frontmatter: str) -> Path:
|
||||
|
|
@ -54,12 +57,27 @@ def test_the_real_delivered_concept_file_yields_its_address() -> None:
|
|||
assert isinstance(entries, tuple), f"still unreadable: {entries!r}"
|
||||
assert entries == (
|
||||
{
|
||||
"resource": "https://viewers.vegnorm.vegvesen.no/api/nisosts/859984?languageCode=nb",
|
||||
"title": "N100:2023",
|
||||
"resource": "https://example.invalid/eksempelvirksomheten/driftskrav/d100",
|
||||
"title": "D100:2027",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_the_fixture_is_the_base_file_byte_for_byte_and_every_base_file_reads() -> None:
|
||||
"""The fixture is only evidence while it IS the delivered file: pinned against the base the
|
||||
package ships. And the one file stands for the whole population — every concept file of both
|
||||
example bases yields its ``sources`` as entries, with the denominator named."""
|
||||
base = frozen_bundles.bundle_dir("driftskrav-2027")
|
||||
assert _REAL.read_bytes() == (base / _REAL_IN_BASE).read_bytes()
|
||||
counts = {}
|
||||
for name in ("driftskrav-2027", "prosesskatalog-2027"):
|
||||
root = frozen_bundles.bundle_dir(name)
|
||||
files = okf.navigate_bundle(str(root)).context_files
|
||||
read = sum(isinstance(okf.read_provenance(root / f.name, "sources"), tuple) for f in files)
|
||||
counts[name] = (read, len(files))
|
||||
assert counts == {"driftskrav-2027": (306, 306), "prosesskatalog-2027": (301, 301)}, counts
|
||||
|
||||
|
||||
def test_evidence_for_reports_present_on_the_real_file() -> None:
|
||||
"""The three-state answer a falsification verdict acts on, end to end. ``tier`` stays ``None``
|
||||
because ``sources`` is not the key SPEC §5.3 tiers — the B4 rule, unchanged by this widening."""
|
||||
|
|
@ -99,23 +117,23 @@ def test_the_key_after_a_block_sequence_is_still_read(tmp_path: Path) -> None:
|
|||
|
||||
|
||||
def test_a_value_carrying_a_colon_survives_whole(tmp_path: Path) -> None:
|
||||
"""``title: N100:2023`` is one pair and the value keeps its own colon, as does a URL's ``://``.
|
||||
"""``title: D100:2027`` is one pair and the value keeps its own colon, as does a URL's ``://``.
|
||||
|
||||
**This arm is a REGRESSION GUARD, not a discriminator, and the distinction was measured rather
|
||||
than assumed.** It was written claiming to prove the colon-SPACE rule, and mutation M5 (separator
|
||||
changed to the FIRST colon) left it GREEN: the first colon in ``resource: https://…`` and in
|
||||
``title: N100:2023`` is the same one colon-SPACE finds, so the two rules agree on every value
|
||||
``title: D100:2027`` is the same one colon-SPACE finds, so the two rules agree on every value
|
||||
shaped like a delivered one. The arm that actually tells them apart is
|
||||
``test_an_item_with_no_pair_separator_is_refused`` — under first-colon, ``- https://a.example/d``
|
||||
decodes to ``{'https': '//a.example/d'}``, a key invented out of a URL scheme. Kept because it
|
||||
pins the values four delivered bases actually carry; labelled honestly because a test that
|
||||
pins the values the delivered bases actually carry; labelled honestly because a test that
|
||||
cannot separate two implementations proves nothing about them."""
|
||||
path = _write(
|
||||
tmp_path,
|
||||
"type: concept\nsources:\n - resource: https://x.example/a\n title: N100:2023\n",
|
||||
"type: concept\nsources:\n - resource: https://x.example/a\n title: D100:2027\n",
|
||||
)
|
||||
assert okf.read_provenance(path, "sources") == (
|
||||
{"resource": "https://x.example/a", "title": "N100:2023"},
|
||||
{"resource": "https://x.example/a", "title": "D100:2027"},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue