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,12 +3,12 @@
|
|||
P4 pkt. 0 anchored the demo against a repo-local reserve whose ``cost-baseline.json`` was DERIVED in
|
||||
code from the scripted register (``baseline_from_scripted_candidate``): the reserve's numbers are
|
||||
synthetic, so the script was the only ground truth there was. On GO day the direction **reverses** —
|
||||
a domain team delivered ``shared/examples/veglys-fv-soer/`` (commons ``002f000``) with its own
|
||||
``cost-baseline.json``, so the register is written FROM that file and the derivation helper is not
|
||||
used on this path.
|
||||
the delivered bundle (today the packaged, fictional ``data/bundles/klientpark-energi/``) ships its
|
||||
own ``cost-baseline.json``, so the register is written FROM that file and the derivation helper is
|
||||
not used on this path.
|
||||
|
||||
That reversal is what these tests guard. The risk it models is drift: two copies of the same numbers
|
||||
— one in commons' delivered file, one in our register — that stop agreeing without anyone noticing.
|
||||
— one in the delivered file, one in our register — that stop agreeing without anyone noticing.
|
||||
A drifted register does not crash; it makes the deterministic gate reject the demo's own hypothesis
|
||||
at stage 0 instead of at the P90 stage, which on screen is the SAME ``REJECTED`` line telling a
|
||||
different story. So the agreement is asserted directly (below), and the 10 % test proves the gate
|
||||
|
|
@ -22,13 +22,14 @@ mechanism could be perfect while the delivered file and the register disagree.
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from portfolio_optimiser import okf
|
||||
from portfolio_optimiser.ir import CostBaseline, CostBaselineLine
|
||||
from portfolio_optimiser.simulation import (
|
||||
_CANDIDATES,
|
||||
_INBOX_MARKER,
|
||||
_VEGLYS_PROJECT_ID,
|
||||
_KLIENTPARK_PROJECT_ID,
|
||||
ScriptedCandidate,
|
||||
_delivered_bundle_dir,
|
||||
materialize_anchored_bundle,
|
||||
|
|
@ -38,10 +39,10 @@ from portfolio_optimiser.persona import load_persona_example
|
|||
from portfolio_optimiser.validator import Rejection, ValidatedProposal
|
||||
|
||||
|
||||
def _veglys() -> ScriptedCandidate:
|
||||
def _klientpark() -> ScriptedCandidate:
|
||||
"""The registry entry for the delivered project — selected by id, never by index (the registry
|
||||
is a set of DATA entries whose order carries no meaning)."""
|
||||
(candidate,) = [c for c in _CANDIDATES if c.project_id == _VEGLYS_PROJECT_ID]
|
||||
(candidate,) = [c for c in _CANDIDATES if c.project_id == _KLIENTPARK_PROJECT_ID]
|
||||
return candidate
|
||||
|
||||
|
||||
|
|
@ -53,12 +54,12 @@ def _delivered_baseline() -> CostBaseline:
|
|||
|
||||
def test_the_delivered_bundle_ships_its_own_baseline() -> None:
|
||||
"""The delivered bundle is anchored WITHOUT ``materialize_anchored_bundle`` — which is exactly
|
||||
what let GO day be a call-site change rather than a new seam. RED if commons ever drops the
|
||||
what let GO day be a call-site change rather than a new seam. RED if the bundle ever drops the
|
||||
file: the demo would then run un-anchored while every other line stayed byte-identical."""
|
||||
baseline = _delivered_baseline()
|
||||
|
||||
assert baseline.project_id == _VEGLYS_PROJECT_ID
|
||||
assert set(baseline.items) == {"ENERGI-VEGLYS-EL"}
|
||||
assert baseline.project_id == _KLIENTPARK_PROJECT_ID
|
||||
assert set(baseline.items) == {"ENERGI-KLIENTPARK-EL"}
|
||||
|
||||
|
||||
def test_the_register_states_the_delivered_numbers_verbatim() -> None:
|
||||
|
|
@ -66,13 +67,13 @@ def test_the_register_states_the_delivered_numbers_verbatim() -> None:
|
|||
written FROM the delivered ``cost-baseline.json``, so they must equal it exactly — in BOTH
|
||||
scripted replies.
|
||||
|
||||
RED when the two drift: if commons re-states the baseline (or someone re-types it here), the
|
||||
RED when the two drift: if the bundle re-states the baseline (or someone re-types it here), the
|
||||
demo's own hypothesis starts being felled by stage 0's reconciliation instead of by the P90
|
||||
stage it narrates. Same ``REJECTED`` line on screen, different mechanism behind it.
|
||||
|
||||
Both replies are checked, not just the corrected one: the overclaimed hypothesis must differ
|
||||
from it in the CLAIM alone, never in the cost lines."""
|
||||
candidate = _veglys()
|
||||
candidate = _klientpark()
|
||||
delivered = _delivered_baseline().items
|
||||
|
||||
for reply in (candidate.overclaimed, candidate.corrected):
|
||||
|
|
@ -103,7 +104,7 @@ def test_the_overclaim_and_the_markers_are_absent_from_the_delivered_bundle() ->
|
|||
each appear to work while carrying nothing.
|
||||
|
||||
This is a CONTENT check, and delivered content is the reason it exists: the register's figure was
|
||||
chosen against commons' number inventory, and this is what keeps that choice honest if either
|
||||
chosen against the bundle's number inventory, and this is what keeps that choice honest if either
|
||||
side changes."""
|
||||
text = "\n".join(
|
||||
path.read_text(encoding="utf-8")
|
||||
|
|
@ -111,7 +112,7 @@ def test_the_overclaim_and_the_markers_are_absent_from_the_delivered_bundle() ->
|
|||
if path.is_file()
|
||||
)
|
||||
|
||||
for token in (_veglys().flip_key, load_persona_example().marker, _INBOX_MARKER):
|
||||
for token in (_klientpark().flip_key, load_persona_example().marker, _INBOX_MARKER):
|
||||
assert token not in text, (
|
||||
f"{token!r} already occurs in the delivered bundle — the walkthrough would trace a "
|
||||
"token the content supplied, not one the loop carried"
|
||||
|
|
@ -126,7 +127,7 @@ async def test_the_delivered_bundle_runs_the_whole_demo(tmp_path) -> None:
|
|||
meaning. It also pins WHICH stage rejects #1 — were stage 0 to start rejecting it, the screen
|
||||
would still show a REJECTED and a VALIDATED line while demonstrating a different mechanism."""
|
||||
result = await simulate_learning_loop(
|
||||
str(_delivered_bundle_dir()), str(tmp_path), project_id=_VEGLYS_PROJECT_ID
|
||||
str(_delivered_bundle_dir()), str(tmp_path), project_id=_KLIENTPARK_PROJECT_ID
|
||||
)
|
||||
|
||||
assert isinstance(result.run_a.outcome, ValidatedProposal)
|
||||
|
|
@ -149,8 +150,8 @@ async def test_a_deviating_delivered_baseline_forkaster_the_run_before_the_solve
|
|||
agreement is only worth something if a DISagreement would be caught. The script is byte-identical
|
||||
to the control above; only the declared baseline moves.
|
||||
|
||||
The deviated copy is materialized outside ``shared/`` — the delivered bundle is a pull-only
|
||||
subtree and criterion 8 requires it byte-unchanged."""
|
||||
The deviated copy is materialized in ``tmp_path`` — criterion 8 requires the delivered bundle
|
||||
byte-unchanged."""
|
||||
delivered = _delivered_baseline()
|
||||
deviated = CostBaseline(
|
||||
project_id=delivered.project_id,
|
||||
|
|
@ -162,7 +163,9 @@ async def test_a_deviating_delivered_baseline_forkaster_the_run_before_the_solve
|
|||
bundle = materialize_anchored_bundle(
|
||||
tmp_path / "avvikende", source=_delivered_bundle_dir(), baseline=deviated
|
||||
)
|
||||
result = await simulate_learning_loop(str(bundle), str(tmp_path), project_id=_VEGLYS_PROJECT_ID)
|
||||
result = await simulate_learning_loop(
|
||||
str(bundle), str(tmp_path), project_id=_KLIENTPARK_PROJECT_ID
|
||||
)
|
||||
|
||||
outcome = result.run_a.outcome
|
||||
assert isinstance(outcome, Rejection), (
|
||||
|
|
@ -170,24 +173,34 @@ async def test_a_deviating_delivered_baseline_forkaster_the_run_before_the_solve
|
|||
"deterministic gate is not anchored to the delivered baseline"
|
||||
)
|
||||
assert "outside the 5.0% tolerance" in outcome.reason
|
||||
assert "ENERGI-VEGLYS-EL" in outcome.reason
|
||||
assert "ENERGI-KLIENTPARK-EL" in outcome.reason
|
||||
assert "P90" not in outcome.reason, (
|
||||
"rejected by the solver stage, not by the reconciliation stage 0 that must run BEFORE it"
|
||||
)
|
||||
|
||||
|
||||
def test_the_delivered_bundle_is_never_mutated_by_a_run() -> None:
|
||||
"""Criterion 8's day-to-day half: the demo copies the bundle, so the commons-owned files under
|
||||
``shared/`` are byte-unchanged after everything above has run."""
|
||||
import subprocess
|
||||
def _snapshot(bundle: Path) -> dict[str, bytes]:
|
||||
return {
|
||||
path.relative_to(bundle).as_posix(): path.read_bytes()
|
||||
for path in sorted(bundle.rglob("*"))
|
||||
if path.is_file()
|
||||
}
|
||||
|
||||
proc = subprocess.run(
|
||||
["git", "status", "--porcelain", "--", "shared/examples/veglys-fv-soer"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
assert proc.stdout == "", f"the delivered bundle was modified in place: {proc.stdout!r}"
|
||||
|
||||
async def test_the_delivered_bundle_is_never_mutated_by_a_run(tmp_path) -> None:
|
||||
"""Criterion 8's day-to-day half: the demo copies the bundle, so the delivered files are
|
||||
byte-unchanged after a whole two-run walkthrough over them.
|
||||
|
||||
Measured around a run of its own rather than read off the version-control status: the bundle's
|
||||
bytes before and after are compared directly, so the check holds whether or not the bundle is
|
||||
committed yet, and it does not depend on which other tests happened to run first."""
|
||||
bundle = _delivered_bundle_dir()
|
||||
before = _snapshot(bundle)
|
||||
assert before, "the delivered bundle has no files -- the comparison below would be vacuous"
|
||||
|
||||
await simulate_learning_loop(str(bundle), str(tmp_path), project_id=_KLIENTPARK_PROJECT_ID)
|
||||
|
||||
assert _snapshot(bundle) == before, "the delivered bundle was modified in place by a run"
|
||||
|
||||
|
||||
def test_the_reserve_entry_and_the_delivered_entry_are_both_registered() -> None:
|
||||
|
|
@ -195,7 +208,7 @@ def test_the_reserve_entry_and_the_delivered_entry_are_both_registered() -> None
|
|||
three-line revert, which it only is while the reserve's registry entry still exists."""
|
||||
ids = {c.project_id for c in _CANDIDATES}
|
||||
|
||||
assert {"BYGG-KONTOR-NORD", _VEGLYS_PROJECT_ID} <= ids
|
||||
assert {"BYGG-KONTOR-NORD", _KLIENTPARK_PROJECT_ID} <= ids
|
||||
|
||||
|
||||
def test_the_projection_names_the_project_the_register_keys_on() -> None:
|
||||
|
|
@ -206,5 +219,5 @@ def test_the_projection_names_the_project_the_register_keys_on() -> None:
|
|||
(_delivered_bundle_dir() / "validator-input.json").read_text(encoding="utf-8")
|
||||
)
|
||||
|
||||
assert projection["project_id"] == _VEGLYS_PROJECT_ID
|
||||
assert projection["project_id"] == _KLIENTPARK_PROJECT_ID
|
||||
assert _delivered_baseline().project_id == projection["project_id"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue