fix: findings from the independent review

Scenario runner: stops when overridden base parameters leave the start out
of balance (new field startlikevekt: krev, kalibrer, ubalanse); stops on
non-finite results; says that models with a court queue drift slowly even
without a shock and prints the drift before the shock; queue in months of
inflow; never deletes files it did not write; stricter limits.
Check: anchored on the note's own checksums for core and reference files,
runs the scenario files too, exact comparison for the diagnosis, honest
wording when parts were skipped or an extension is broken.
Launcher: unknown field names in input are rejected with a suggestion;
unwritable folders give a message, not a traceback.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-11-11 15:27:14 +01:00
commit 776325c680
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
14 changed files with 1524 additions and 199 deletions

View file

@ -5,6 +5,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import arbeidskopi as arbeidskopi_modul
import pytest
from conftest import EKSEMPLER, FASIT, ROT, kjor
@ -100,3 +101,28 @@ def test_endring_i_kopiens_kjerne_brukes(arbeidskopi: Path, tmp_path: Path) -> N
plugin = kjor("scenario", str(KJEDE_S2), "--ut", str(tmp_path / "plugin"))
assert plugin.returncode == 0, plugin.stderr
assert (tmp_path / "plugin" / "kjede_s2.dat").read_bytes() == (FASIT / "data" / "kjede_s2.dat").read_bytes()
def test_nekter_mappe_inne_i_pluginen(tmp_path: Path) -> None:
mal = ROT / "nyttsted-test-arbeidskopi"
assert not mal.exists()
prosess = kjor("arbeidskopi", str(mal))
assert prosess.returncode == 2, prosess.stdout
assert "ligger inne i" in prosess.stderr
assert not mal.exists()
assert not (tmp_path / "x").exists()
def test_lisenssetningen(arbeidskopi: Path) -> None:
assert "Alt i pluginen er under MIT-lisensen (se `LICENSE`)." in (arbeidskopi / "LES-MEG.md").read_text(
encoding="utf-8")
def test_kommandoene_skrives_for_windows(tmp_path: Path) -> None:
mal = tmp_path / "Kari Nordmann" / "rettsstat-modell"
tekst = arbeidskopi_modul.les_meg(mal, [], windows=True)
assert f'python "{mal / "modell" / "kjor.py"}" scenario' in tekst
assert "python3" not in tekst
assert "'" not in tekst.split("## Slik kjører du kopien", 1)[1].split("## Slik kontrollerer", 1)[0]
posix = arbeidskopi_modul.les_meg(mal, [], windows=False)
assert f"python3 '{mal / 'modell' / 'kjor.py'}' scenario" in posix