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
|
|
@ -3,31 +3,33 @@
|
|||
P7 made stage 0b ``item.code in grounding``: plain containment over ONE concatenated string. P16
|
||||
then ran it against a delivered corpus and measured what containment cannot tell apart. The
|
||||
falsification arm ``a4-indeksregulering`` proposed a 250 000 NOK saving on a single cost line whose
|
||||
code was ``R761`` — the knowledge base's OWN NAME, which every one of its 2 756 concept documents
|
||||
carries — and the whole gate said ``validated``: stage 0 was skipped (un-anchored run), stage 0b
|
||||
was satisfied by the letterhead, and the checker approved.
|
||||
code was the knowledge base's OWN NAME — the catalogue designation every one of its 2 756 concept
|
||||
documents carries — and the whole gate said ``validated``: stage 0 was skipped (un-anchored run),
|
||||
stage 0b was satisfied by the letterhead, and the checker approved.
|
||||
|
||||
The rule this file measures: a code grounds only if it is at least ``_GROUNDING_MIN_LENGTH``
|
||||
characters AND appears in fewer than ``_GROUNDING_MAX_DOCUMENT_SHARE`` of the grounding's
|
||||
DOCUMENTS — with an absolute floor, because a share over a handful of documents is not a
|
||||
measurement (one of three is 33 % and says nothing).
|
||||
|
||||
**N and A are MEASURED, not chosen** (14.09, the four mounted vegnormal bases):
|
||||
**N and A are MEASURED, not chosen** (14.09, over the four corpora delivered at the time):
|
||||
|
||||
* every ``must_cite`` reference and every mandate ``affected_code`` in the four context sets: the
|
||||
shortest real identifier is FOUR characters (``12.1``, ``52.1``), so ``N = 3`` sits one below the
|
||||
measurement and cannot refuse anything measured;
|
||||
* document frequency of every code-shaped token (``generate._IDENTIFIER_FORMS``) in each base:
|
||||
1 692 distinct tokens and NOT ONE reaches 5 % of its base's documents. Highest anywhere 6 of 446
|
||||
(1.35 %); highest that a fasit names 3 of 446 (0.67 %); ``R761`` 2 756 of 2 756 (100 %). ``A =
|
||||
(1.35 %); highest that a fasit names 3 of 446 (0.67 %); the base's own name 2 756 of 2 756
|
||||
(100 %). ``A =
|
||||
0.05`` therefore sits 3.7x above the highest real token and 20x below the defect.
|
||||
|
||||
**The denominator is NAMED in the refusal**, because Step 5 feeds that reason verbatim into the
|
||||
next attempt's prompt: a proposer told only "ungrounded" answers with another token of the same
|
||||
kind, while one told "it is in 2 756 of 2 756 documents" has been told what is wrong with it.
|
||||
|
||||
The arms that need the delivered bases SKIP with the root named; the rule's own algebra, the
|
||||
floor, and the composition seam run over synthetic input and are UNCONDITIONAL.
|
||||
The arms that need a knowledge base read the package's pinned example bases (and SKIP, with the
|
||||
store named, only when a user's own store lacks them); the rule's own algebra, the floor, and the
|
||||
composition seam run over synthetic input and are UNCONDITIONAL.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
|
@ -49,17 +51,12 @@ from portfolio_optimiser.validator import (
|
|||
validate_proposal,
|
||||
)
|
||||
|
||||
_A4 = Path(
|
||||
"scratchpad/p14-stress/kontrakt-sorasen-2027/"
|
||||
"kontrakt-sorasen-2027-01-a4-indeksregulering-proposal.json"
|
||||
)
|
||||
|
||||
|
||||
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)
|
||||
|
|
@ -98,22 +95,22 @@ def _corpus(*, documents: int, everywhere: str, once: str) -> Grounding:
|
|||
# --- the measured defect --------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_the_a4_proposal_p16_validated_is_now_refused() -> None:
|
||||
"""(a) THE KNOWN POSITIVE, and it is a recording rather than a construction: the proposal is
|
||||
the artefact P16's paid run wrote, replayed against the base that run was given, with
|
||||
``baseline=None`` — exactly the configuration under which it said ``validated``."""
|
||||
if not _A4.is_file():
|
||||
pytest.skip("P16's a4 artefact is not present in this checkout")
|
||||
proposal = SavingsProposal.model_validate(
|
||||
json.loads(_A4.read_text(encoding="utf-8"))["proposal"]
|
||||
)
|
||||
assert [i.code for i in proposal.affected_items] == ["R761"], "the artefact drifted"
|
||||
def test_the_catalogues_own_name_as_a_cost_code_is_refused() -> None:
|
||||
"""(a) THE KNOWN POSITIVE. P16's paid run proposed the catalogue's own designation as a cost
|
||||
code and the gate said ``validated``. That recording was made against a corpus this repository
|
||||
no longer carries, so the proposal is rebuilt in the same shape against the example catalogue,
|
||||
whose designation ``P900`` stands in every one of its concept documents — with
|
||||
``baseline=None``, exactly the configuration under which the original said ``validated``.
|
||||
CONTROL: the same base's own process number ``52.11`` still grounds (arm (b) covers every
|
||||
one)."""
|
||||
grounding = _grounding_over("prosesskatalog-2027")
|
||||
assert _inert_in(grounding, "52.11") is None, "control: a real process number must ground"
|
||||
|
||||
ruling = validate_proposal(proposal, baseline=None, grounding=_grounding_over("r761-2025"))
|
||||
ruling = validate_proposal(_proposal("P900"), baseline=None, grounding=grounding)
|
||||
|
||||
assert isinstance(ruling, Rejection)
|
||||
assert "'R761'" in ruling.reason
|
||||
assert "2756 of the 2756" in ruling.reason, (
|
||||
assert "'P900'" in ruling.reason
|
||||
assert "301 of the 301" in ruling.reason, (
|
||||
"the refusal must name the denominator: Step 5 feeds this reason verbatim into the next "
|
||||
f"attempt's prompt — got {ruling.reason!r}"
|
||||
)
|
||||
|
|
@ -123,10 +120,8 @@ def test_every_fasit_reference_still_grounds() -> None:
|
|||
"""(b) THE KNOWN NEGATIVE over the same corpora, with its denominator stated. A rule that made
|
||||
the defect inert by making real references inert too would pass (a) perfectly."""
|
||||
sets = {
|
||||
"gate-nordvik-2027": "n100-2023",
|
||||
"fv412-dekkefornyelse-2027": "n200-2024",
|
||||
"tunnel-hauglia-2027": "n500-2024",
|
||||
"kontrakt-sorasen-2027": "r761-2025",
|
||||
"serverrom-2027": "driftskrav-2027",
|
||||
"driftsavtale-2027": "prosesskatalog-2027",
|
||||
}
|
||||
checked = 0
|
||||
for context, base in sets.items():
|
||||
|
|
@ -138,7 +133,7 @@ def test_every_fasit_reference_still_grounds() -> None:
|
|||
f"{reference!r} is a real requirement of {base} and the rule made it inert"
|
||||
)
|
||||
checked += 1
|
||||
assert checked == 26, f"population moved: {checked} references, expected 26"
|
||||
assert checked == 12, f"population moved: {checked} references, expected 12"
|
||||
|
||||
|
||||
# --- the rule's own algebra, unconditional ---------------------------------------------------
|
||||
|
|
@ -159,7 +154,7 @@ def test_a_token_in_one_document_grounds_and_one_in_all_of_them_does_not() -> No
|
|||
|
||||
|
||||
def test_a_token_too_short_to_identify_anything_is_inert() -> None:
|
||||
"""(d) The length conjunct, which the SHARE does not cover: ``R761`` is four characters, so
|
||||
"""(d) The length conjunct, which the SHARE does not cover: ``P900`` is four characters, so
|
||||
length is not what made the measured defect inert. This is the coincidence class the
|
||||
measurement did not happen to contain — a one- or two-character token is in any prose."""
|
||||
grounding = Grounding(documents=("the line A is here", *("filler" for _ in range(50))))
|
||||
|
|
@ -181,8 +176,9 @@ def test_a_share_is_not_taken_over_a_handful_of_documents() -> None:
|
|||
|
||||
def test_a_caller_that_declares_no_boundaries_is_byte_for_byte_the_old_gate() -> None:
|
||||
"""(f) ``Grounding.of`` is the honest reading of a caller with nothing to declare, and it can
|
||||
never trip the share: one document cannot reach the floor. This is what keeps every road-path
|
||||
run and every pre-P18 test unchanged BY CONSTRUCTION rather than by exemption."""
|
||||
never trip the share: one document cannot reach the floor. This is what keeps every
|
||||
single-document run and every pre-P18 test unchanged BY CONSTRUCTION rather than by
|
||||
exemption."""
|
||||
text = "en tekst som nevner KODE-99 og ellers ingenting"
|
||||
single = Grounding.of(text)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue