#!/bin/bash # v1 repository checks (V1 Step 3, rewritten in wave 2 order 7 for plan revision 5, .claude/projects/2026-10-03-v1-k). # One PASS or FAIL line per check; a check that cannot run prints FAIL. Exit 1 on any FAIL. bash 3.2 safe, ASCII only. # V1_SOURCES is the frozen copy of collection 1 that holds kilde/ (default $HOME/okf/benk/samling1/20261008). P1 has its # own: P1_SOURCES is the copy of 21.09 that P1's K cites (default $HOME/okf/benk/wiki), and P1_K is P1's K bundle # (default $P1_SOURCES/prove-p1/K). The paths name no content. # # Expected state of each line after wave 2 order 7, and the plan step that turns it PASS. # tests/test_scripts.py checks that this table and the check lines below agree: # unittest tests FAIL only for the 11 tests of tests/test_change_warning.py, red by design -> Step 8 (wave 2 order 8) # unittest gates/tests PASS # unittest evals/tests PASS # mypy --strict okfwiki gates tests PASS (uvx found with command -v; tools/*.py named) # excluded terms PASS # rule 3 PASS (a run counts when at least 4 of its 8 tokens are letters only: wave 2 order 7; # files git ignores are never committed and are not read: wave 2 merge) # package boundary PASS (the fragment rule is green too, in unittest tests) # link rule on P1's K PASS (a lock on the rule of 04.10 through link_rule_report; K2 needs a K1 root) set -u cd "$(dirname "$0")/.." || exit 2 V1_SOURCES="${V1_SOURCES:-$HOME/okf/benk/samling1/20261008}" P1_SOURCES="${P1_SOURCES:-$HOME/okf/benk/wiki}" P1_K="${P1_K:-$P1_SOURCES/prove-p1/K}" export V1_SOURCES P1_SOURCES P1_K FAILED=0 check() { name="$1" shift if "$@" >/dev/null 2>&1; then echo "PASS $name" else echo "FAIL $name" FAILED=1 fi } py() { python3 -c "$1" } mypy_strict() { uvx_bin="$(command -v uvx)" || return 1 "$uvx_bin" --offline --with types-PyYAML mypy --strict okfwiki gates tests tools/*.py } check "unittest tests" python3 -m unittest discover -s tests check "unittest gates/tests" python3 -m unittest discover -s gates/tests check "unittest evals/tests" python3 -m unittest discover -s evals/tests check "mypy --strict okfwiki gates tests tools/*.py (uvx from PATH)" mypy_strict check "excluded terms in the tracked tree" bash tools/check-excluded-terms.sh check "rule 3: no 8-word run of tests/, docs/, gates/, agents/, .claude/agents/, skills/, okfwiki/, tools/ or evals/README.md is in kilde/" py ' import glob, os, re, subprocess, sys files = glob.glob(os.environ["V1_SOURCES"] + "/kilde/*.md") if not files: sys.exit(1) def text_run(run): return sum(1 for w in run if w.isalpha()) >= 4 def runs(text): w = re.findall(r"[a-z0-9]+", text.lower()) return {r for r in (tuple(w[i:i + 8]) for i in range(len(w) - 7)) if text_run(r)} git = subprocess.run(["git", "ls-files", "-co", "--exclude-standard"], capture_output=True, text=True) kept = set(git.stdout.splitlines()) if git.returncode == 0 else None mine = set() for top in ("tests", "docs", "gates", "agents", ".claude/agents", "skills", "okfwiki", "tools"): for d, dirs, names in os.walk(top): dirs[:] = [x for x in dirs if x not in ("__pycache__", ".mypy_cache")] for n in names: path = os.path.join(d, n) if kept is None or path in kept: mine |= runs(open(path, encoding="utf-8", errors="replace").read()) mine |= runs(open("evals/README.md", encoding="utf-8").read()) src = set() for f in files: src |= runs(open(f, encoding="utf-8").read()) sys.exit(0 if mine and not (mine & src) else 1)' check "package boundary: no trial, network or program-starting imports under okfwiki/ (tests/test_package.py)" py ' import os, subprocess, sys if not os.path.isfile("tests/test_package.py"): sys.exit(1) sys.exit(subprocess.run([sys.executable, "-m", "unittest", "discover", "-s", "tests", "-p", "test_package.py"]).returncode)' check "link rule on P1's K: 59 of 212 have an inbound link (the rule of 04.10, a historical lock)" py ' import os, sys from pathlib import Path sys.path.insert(0, os.getcwd()) from okfwiki.audit import link_rule_report, load_bundle k = os.environ["P1_K"] if not os.path.isdir(k): sys.exit(1) rule = link_rule_report(load_bundle(Path(k), Path(os.environ["P1_SOURCES"]))) sys.exit(0 if isinstance(rule, dict) and rule.get("pass") == 59 and rule.get("of") == 212 else 1)' exit "$FAILED"