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,45 +1,50 @@
|
|||
"""P20 DEL B — a clause number is not a price, and the base's own vocabulary is what says so.
|
||||
|
||||
**What was measured.** Three paid rounds and one multi-base pass carried FOUR ``validated``
|
||||
proposals whose cost code was a chapter number of a standard. Two survive in the recorded outboxes
|
||||
and are this arm's known positives:
|
||||
proposals whose cost code was a chapter number of a standard. Two survived in the recorded
|
||||
outboxes and were this arm's known positives:
|
||||
|
||||
* ``10.4`` — tunnel-hauglia round 3, base ``vegnormal-n500-2024``, ``validated``;
|
||||
* ``1.10.4`` — lindaas P17b, base ``vegnormal-r761-2025``, ``validated``.
|
||||
* ``10.4`` — a stress round on a requirements base, ``validated``;
|
||||
* ``1.10.4`` — the multi-base pass, on the process catalogue, ``validated``.
|
||||
|
||||
Both are GROUNDED in P7's sense (they occur verbatim in the input) and neither is INERT in
|
||||
Both were GROUNDED in P7's sense (they occur verbatim in the input) and neither was INERT in
|
||||
P18/B1's sense (``10.4`` in 12 of 274 documents, ``1.10.4`` in 1 of 2 756). Stage 0 never ran:
|
||||
no vegnormal base ships a cost baseline. Nothing in the gate could say what they are.
|
||||
no requirements base ships a cost baseline. Nothing in the gate could say what they are.
|
||||
|
||||
**THE ORDER'S OWN RULE WAS FELLED BY MEASUREMENT BEFORE ANYTHING WAS BUILT ON IT.** B1 reads: a
|
||||
code is a requirement when it has form 2 or 3 AND "står som ``req_number``/``prosessnr`` i
|
||||
toppnivå-frontmatter i minst ett av grunnlagets dokumenter" — refuse that. Measured 15.09:
|
||||
|
||||
* n500 declares ``seksjon: 10.4.1`` … ``10.4.4`` and ``req_number: Krav 10.4.3—2``. The bare
|
||||
``10.4`` is declared NOWHERE — it is a section PREFIX;
|
||||
* r761 declares 2 727 ``prosessnr`` and 2 753 ``seksjon``. ``1.10.4`` is NONE of them: it occurs
|
||||
once, as prose, in "Krav til materialer skal være iht. vegnormal N200 Vegbygging kap. 1.10.4".
|
||||
* the requirements base declared ``seksjon: 10.4.1`` … ``10.4.4`` and ``req_number: Krav
|
||||
10.4.3—2``. The bare ``10.4`` was declared NOWHERE — it is a section PREFIX;
|
||||
* the process catalogue declared 2 727 ``prosessnr`` and 2 753 ``seksjon``. ``1.10.4`` was NONE of
|
||||
them: it occurred once, as prose, a chapter reference into ANOTHER standard.
|
||||
|
||||
The ordered rule therefore fires on NEITHER of its own known positives. The COMPLEMENT fires on
|
||||
BOTH, and it closes a hole ``_ground_against_input`` already admits in writing — "it fails OPEN …
|
||||
on a coincidental match". For one shape, a clause number, the base hands us the vocabulary needed
|
||||
to tell a real reference from a coincidence, and that is the rule built here.
|
||||
|
||||
The complement is also what SPARES the one context set built on real process codes: all five of
|
||||
``contexts/kontrakt-sorasen-2027``'s codes are declared ``prosessnr`` and pass. Under the ordered
|
||||
rule every one of them would have been refused on an unanchored r761 run, and the set's positive
|
||||
arms would have become unmeasurable — the R761 risk the order names, arriving through the door it
|
||||
was pointed away from.
|
||||
The complement is also what SPARES the context set built on the catalogue's own process codes:
|
||||
all five of ``contexts/driftsavtale-2027``'s codes are declared ``prosessnr`` and pass. Under the
|
||||
ordered rule every one of them would have been refused on an unanchored run on the catalogue, and
|
||||
the set's positive arms would have become unmeasurable — the risk the order names (a process
|
||||
number is both a clause and a settlement post), arriving through the door it was pointed away from.
|
||||
|
||||
Measured over EVERY code of round 3 and P17b (24 codes, 10 runs): exactly two are
|
||||
requirement-shaped, they are the two known positives, and the replay flips exactly those two.
|
||||
Measured over EVERY code of that round and the multi-base pass (24 codes, 10 runs): exactly two
|
||||
were requirement-shaped, they were the two known positives, and the replay flipped exactly those
|
||||
two. Those recordings were made against corpora this repository no longer carries, so (a) and (b)
|
||||
are now CONSTRUCTED in the same two shapes against the package's example bases: ``4.2.5`` — a
|
||||
section PREFIX in ``driftskrav-2027`` (it declares ``seksjon: 4.2.5.1`` and ``Krav 4.2.5.1—1`` …
|
||||
``—3``; the bare ``4.2.5`` stands in 3 of 306 documents and is no document's own number) — and
|
||||
``1.10.4`` — a clause of another document quoted once, as prose, in ``prosesskatalog-2027``.
|
||||
|
||||
What each arm pins:
|
||||
|
||||
(a) known positive — the ``10.4`` proposal, replayed against the base it actually ran on, is
|
||||
(a) known positive — the section prefix ``4.2.5``, unanchored against the requirements base, is
|
||||
``rejected``, and the reason names the denominator;
|
||||
(b) known positive — ditto ``1.10.4`` on r761;
|
||||
(c) known negative — a code the base DOES declare (sorasen's real ``12.1``) still validates;
|
||||
(b) known positive — ditto ``1.10.4`` on the process catalogue;
|
||||
(c) known negative — a code the base DOES declare (driftsavtale's ``12.1``) still validates;
|
||||
(d) known negative — the gate is OFF when the run is anchored, even for a clause-shaped code;
|
||||
(e) the generality guard — an input that declares no reference numbers at all cannot trip the rule,
|
||||
which is what leaves every pre-P20 fixture untouched rather than exempted;
|
||||
|
|
@ -74,15 +79,12 @@ from portfolio_optimiser.validator import (
|
|||
validate_proposal,
|
||||
)
|
||||
|
||||
_ROUND3 = Path("scratchpad/p19-stress/tunnel-hauglia-2027")
|
||||
_P17B = Path("scratchpad/p17b-multibase/lindaas")
|
||||
|
||||
|
||||
def _base(name: str) -> Path:
|
||||
"""The FROZEN copy this repository pins, resolved at call time.
|
||||
|
||||
Absence SKIPS (MAJOR-3's ceiling: no corpus is mounted in the handover archive), drift is
|
||||
allowed to propagate and FAIL — a measurement of the wrong corpus is not a missing one.
|
||||
Absence SKIPS (a user's own store, named by ``PORTFOLIO_FROZEN_BUNDLES``, may not hold it),
|
||||
drift is allowed to propagate and FAIL — a measurement of the wrong corpus is not a missing one.
|
||||
"""
|
||||
try:
|
||||
return frozen_bundles.bundle_dir(name)
|
||||
|
|
@ -103,12 +105,6 @@ def _grounding_over(name: str) -> Grounding:
|
|||
)
|
||||
|
||||
|
||||
def _recorded(path: Path) -> SavingsProposal:
|
||||
if not path.is_file():
|
||||
pytest.skip(f"the recorded artefact {path} is not present in this checkout")
|
||||
return SavingsProposal.model_validate(json.loads(path.read_text(encoding="utf-8"))["proposal"])
|
||||
|
||||
|
||||
def _proposal(code: str, *, saving: float = 1000.0) -> SavingsProposal:
|
||||
return SavingsProposal(
|
||||
project_id="p",
|
||||
|
|
@ -121,23 +117,27 @@ def _proposal(code: str, *, saving: float = 1000.0) -> SavingsProposal:
|
|||
# ---------------------------------------------------------------------------------- known positives
|
||||
|
||||
|
||||
def test_the_section_number_that_reached_validated_on_n500_is_refused() -> None:
|
||||
"""(a) tunnel-04's ``10.4``, replayed against the base that run actually opened."""
|
||||
proposal = _recorded(_ROUND3 / "tunnel-hauglia-2027-04-a4-enhetspris-ventilator-proposal.json")
|
||||
assert [i.code for i in proposal.affected_items] == ["10.4"]
|
||||
outcome = validate_proposal(proposal, baseline=None, grounding=_grounding_over("n500-2024"))
|
||||
def test_a_section_prefix_of_the_requirements_base_is_refused() -> None:
|
||||
"""(a) The ``10.4`` shape: a section PREFIX that stands in the base, is not inert, and is no
|
||||
document's own number. The CONTROL is what makes the refusal this rule's and not another
|
||||
stage's: the prefix IS in the text, in too few documents to be inert, and not declared."""
|
||||
grounding = _grounding_over("driftskrav-2027")
|
||||
assert "4.2.5" in grounding.text and "4.2.5" not in grounding.reference_vocabulary
|
||||
assert grounding.document_frequency("4.2.5") == 3
|
||||
outcome = validate_proposal(_proposal("4.2.5"), baseline=None, grounding=grounding)
|
||||
assert isinstance(outcome, Rejection)
|
||||
assert "'10.4'" in outcome.reason
|
||||
assert "not one of the 365 this knowledge base declares" in outcome.reason
|
||||
assert "'4.2.5'" in outcome.reason
|
||||
assert "not one of the 279 this knowledge base declares" in outcome.reason
|
||||
|
||||
|
||||
def test_the_process_number_that_reached_validated_on_r761_is_refused() -> None:
|
||||
"""(b) lindaas a4's ``1.10.4`` — a chapter of ANOTHER standard, quoted in one r761 document."""
|
||||
proposal = _recorded(_P17B / "lindaas-01-vegnormal-r761-2025-a4-indeksregulering-proposal.json")
|
||||
assert [i.code for i in proposal.affected_items] == ["1.10.4"]
|
||||
outcome = validate_proposal(proposal, baseline=None, grounding=_grounding_over("r761-2025"))
|
||||
def test_a_clause_of_another_document_quoted_in_the_catalogue_is_refused() -> None:
|
||||
"""(b) The ``1.10.4`` shape: a clause of ANOTHER document, quoted once in the catalogue."""
|
||||
grounding = _grounding_over("prosesskatalog-2027")
|
||||
assert grounding.document_frequency("1.10.4") == 1
|
||||
assert "1.10.4" not in grounding.reference_vocabulary
|
||||
outcome = validate_proposal(_proposal("1.10.4"), baseline=None, grounding=grounding)
|
||||
assert isinstance(outcome, Rejection)
|
||||
assert "not one of the 2765 this knowledge base declares" in outcome.reason
|
||||
assert "not one of the 306 this knowledge base declares" in outcome.reason
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------- known negatives
|
||||
|
|
@ -146,25 +146,25 @@ def test_the_process_number_that_reached_validated_on_r761_is_refused() -> None:
|
|||
def test_a_process_code_the_base_declares_still_validates() -> None:
|
||||
"""(c) The arm that keeps this a rule about the corpus and not about shapes.
|
||||
|
||||
``12.1`` is ``contexts/kontrakt-sorasen-2027``'s own first code and a REAL declared
|
||||
``prosessnr`` of R761. Under the ordered rule it would have been refused; it must not be.
|
||||
``12.1`` is ``contexts/driftsavtale-2027``'s own first code and a declared ``prosessnr`` of
|
||||
the catalogue. Under the ordered rule it would have been refused; it must not be.
|
||||
"""
|
||||
grounding = _grounding_over("r761-2025")
|
||||
grounding = _grounding_over("prosesskatalog-2027")
|
||||
assert "12.1" in grounding.reference_vocabulary
|
||||
outcome = validate_proposal(_proposal("12.1"), baseline=None, grounding=grounding)
|
||||
assert isinstance(outcome, ValidatedProposal), getattr(outcome, "reason", "")
|
||||
|
||||
|
||||
def test_every_sorasen_code_is_in_the_bases_vocabulary() -> None:
|
||||
def test_every_driftsavtale_code_is_in_the_bases_vocabulary() -> None:
|
||||
"""(c) The whole context set, not one sample: five real codes, five declared numbers."""
|
||||
codes = [
|
||||
code
|
||||
for approach in json.loads(
|
||||
Path("contexts/kontrakt-sorasen-2027/mandate.json").read_text(encoding="utf-8")
|
||||
Path("contexts/driftsavtale-2027/mandate.json").read_text(encoding="utf-8")
|
||||
)["approaches"]
|
||||
for code in approach.get("affected_codes", [])
|
||||
]
|
||||
vocabulary = _grounding_over("r761-2025").reference_vocabulary
|
||||
vocabulary = _grounding_over("prosesskatalog-2027").reference_vocabulary
|
||||
shaped = [c for c in codes if has_requirement_form(c)]
|
||||
assert len(shaped) == 5, shaped
|
||||
assert [c for c in shaped if c not in vocabulary] == []
|
||||
|
|
@ -172,11 +172,9 @@ def test_every_sorasen_code_is_in_the_bases_vocabulary() -> None:
|
|||
|
||||
def test_the_fasit_references_are_classified_requirement() -> None:
|
||||
"""(g) known negative (c) of the order: a fasit reference IS a requirement, and says so."""
|
||||
fasit = json.loads(
|
||||
Path("contexts/kontrakt-sorasen-2027/fasit.json").read_text(encoding="utf-8")
|
||||
)
|
||||
fasit = json.loads(Path("contexts/driftsavtale-2027/fasit.json").read_text(encoding="utf-8"))
|
||||
refs = sorted({c["ref"] for entry in fasit["must_cite"] for c in entry["concepts"]})
|
||||
forms = classify_codes(refs, _grounding_over("r761-2025"))
|
||||
forms = classify_codes(refs, _grounding_over("prosesskatalog-2027"))
|
||||
assert set(forms.values()) == {"requirement"}, forms
|
||||
|
||||
|
||||
|
|
@ -203,16 +201,16 @@ def test_a_cost_line_identifier_is_not_requirement_shaped() -> None:
|
|||
"""(f) K2's 50 identifiers and this repo's own code: shape, measured."""
|
||||
assert not has_requirement_form("SHA-01")
|
||||
assert not has_requirement_form("ENERGI-TOTAL-EL")
|
||||
assert not has_requirement_form("65 ASFALTDEKKER")
|
||||
assert not has_requirement_form("65 LAGRINGSSYSTEMER")
|
||||
assert has_requirement_form("10.4") and has_requirement_form("Krav 4.1.2—1")
|
||||
|
||||
|
||||
def test_classify_codes_without_a_grounding_is_the_pre_p20_answer() -> None:
|
||||
"""(g) ``stress.py`` re-derives for runs written before the field existed."""
|
||||
assert classify_codes(["12.1", "SHA-01", "impulsventilator"]) == {
|
||||
assert classify_codes(["12.1", "SHA-01", "nødstrømsaggregat"]) == {
|
||||
"12.1": "identifier",
|
||||
"SHA-01": "identifier",
|
||||
"impulsventilator": "prose",
|
||||
"nødstrømsaggregat": "prose",
|
||||
}
|
||||
grounding = Grounding(documents=("x",), declared_references=("12.1",))
|
||||
assert classify_codes(["12.1"], grounding) == {"12.1": "requirement"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue