okf-wiki 1.1.1
First public release, published as one snapshot. What changed between versions is in CHANGELOG.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
0fd86a23a3
227 changed files with 96077 additions and 0 deletions
411
tests/test_skill.py
Normal file
411
tests/test_skill.py
Normal file
|
|
@ -0,0 +1,411 @@
|
|||
"""Tests for skills/okf-wiki/SKILL.md and the agents it names: the skill is K's (Step 10 of the v1 plan, brief SC8).
|
||||
|
||||
The skill names the stop line, the provenance marks, the main page and the home, the guard, the breach stop,
|
||||
Disputed/Outdated and `generated.by`, and no code links and no exception list. Its stop command parses with
|
||||
okfwiki.cost's own parser, the reading commands of contract K6 stand in it verbatim, the compiler agent carries
|
||||
kpack.CONTRACT, the agent copies in agents/ and .claude/agents/ are byte-identical, and every module and subcommand it
|
||||
names exists. The answer router is kept as it was.
|
||||
Run: python3 -m unittest discover -s tests -p 'test_skill.py'
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
import io
|
||||
import re
|
||||
import shlex
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from okfwiki import claims, cost, kassemble, kblocks, klink, kmerge, kpack, krepair, reader, sources, view # noqa: E402
|
||||
|
||||
SKILL = ROOT / "skills" / "okf-wiki" / "SKILL.md"
|
||||
STOP = ("python3 -m okfwiki.cost stop --lines build,link,orchestration-build --cap C --unit blocks --done D "
|
||||
"--total T --kost KOST --blocks PACKS --next NEXT --next-chars CHARS")
|
||||
PLACEHOLDERS = {"C": "16000000", "D": "120", "T": "4509", "KOST": "kost.json", "PACKS": "packs.json", "NEXT": "466",
|
||||
"CHARS": "107000"}
|
||||
K6 = ( # 0-felles section 4 K6 point 6, verbatim; order 9 makes the commands
|
||||
"python3 -m okfwiki.claims list BUNDLE SOURCES --out CLAIMS [--pairs PAIRS]",
|
||||
"python3 -m okfwiki.claims calls --claims CLAIMS --pairs PAIRS --out CALLS [--ids IDS]",
|
||||
"python3 -m okfwiki.claims sample --claims CLAIMS --judged JUDGED --part-root ROOT --seed N --min 300 --out IDS",
|
||||
"python3 -m okfwiki.reader render --set PAIRS --calls CALLS --agent AGENT --out-dir TASKS",
|
||||
"python3 -m okfwiki.reader collect --set PAIRS --calls CALLS --transcripts DIR --run RUN --reader NAME --out VERDICTS "
|
||||
"--gate-passed",
|
||||
"python3 -m okfwiki.claims score --claims CLAIMS --verdicts VERDICTS [--ids IDS]",
|
||||
)
|
||||
MODULES = {"okfwiki.sources", "okfwiki.kblocks", "okfwiki.kpack", "okfwiki.klink", "okfwiki.kassemble", "okfwiki.audit",
|
||||
"okfwiki.cost", "okfwiki.claims", "okfwiki.reader", "okfwiki.view", "okfwiki.kmerge", "okfwiki.krepair"}
|
||||
PARSERS = {"okfwiki.cost": cost.build_parser, "okfwiki.kpack": kpack.build_parser, "okfwiki.klink": klink.build_parser,
|
||||
"okfwiki.kassemble": kassemble.build_parser, "okfwiki.kblocks": kblocks.build_parser,
|
||||
"okfwiki.sources": sources.build_parser, "okfwiki.kmerge": kmerge.build_parser,
|
||||
"okfwiki.claims": claims.build_parser, "okfwiki.reader": reader.build_parser,
|
||||
"okfwiki.view": view.build_parser, "okfwiki.krepair": krepair.build_parser}
|
||||
NO_PARSER = {"okfwiki.audit"} # positional arguments only, no subcommands
|
||||
NUMBERS = {"N": "2", "N+1": "3", "N-1": "1", "B": "1000", "S": "5", "R": "0.15"}
|
||||
AGENTS = ("okf-wiki-compiler", "okf-wiki-linker", "okf-wiki-reader", "okf-wiki-merger", "okf-wiki-repairer")
|
||||
|
||||
|
||||
def argv_of(command: str) -> list[str]:
|
||||
"""The words after `python3 -m MODULE`, placeholders made concrete and optional brackets taken off."""
|
||||
words = [w.strip("[]") for w in shlex.split(command)[3:]]
|
||||
return [NUMBERS.get(w, PLACEHOLDERS.get(w, w)) for w in words if w]
|
||||
|
||||
|
||||
def subcommands(parser: argparse.ArgumentParser) -> set[str]:
|
||||
return {name for a in parser._actions if isinstance(a, argparse._SubParsersAction) for name in a.choices}
|
||||
|
||||
|
||||
class SkillTest(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.text = SKILL.read_text(encoding="utf-8")
|
||||
|
||||
def section(self, heading: str) -> str:
|
||||
return self.text.split(heading, 1)[1].split("\n## ", 1)[0]
|
||||
|
||||
def test_frontmatter_names_the_skill_and_describes_when_to_use_it(self) -> None:
|
||||
self.assertTrue(self.text.startswith("---\nname: okf-wiki\ndescription: "))
|
||||
self.assertIn("\n---\n", self.text[4:])
|
||||
self.assertIn("packs of five", self.text.split("\n---\n", 1)[0])
|
||||
|
||||
def test_the_answer_router_searches_the_index_then_main_page_then_links_then_the_source(self) -> None:
|
||||
# Measured in order 31 session B: 76 of 76 whole reads of index.md on collection 1 failed with "exceeds
|
||||
# maximum allowed size (256KB)". The index is searched, never read whole (PLAN § Rammer 22).
|
||||
asking = self.section("## The router").split("**When answering a question**", 1)[1]
|
||||
self.assertNotIn("Read `index.md` first", asking)
|
||||
self.assertIn("never read whole", asking)
|
||||
steps = ("Search `index.md`", "Open the main page", "Follow its links", "Open the raw source")
|
||||
for earlier, later in zip(steps, steps[1:]):
|
||||
with self.subTest(earlier=earlier, later=later):
|
||||
self.assertLess(asking.index(earlier), asking.index(later))
|
||||
self.assertIn("`x-main-for`", asking)
|
||||
self.assertIn("Say plainly what the wiki does not cover", asking)
|
||||
|
||||
def test_the_build_chooses_existing_concepts_from_the_catalogue_before_a_new_one(self) -> None:
|
||||
building = self.section("## The router").split("**When answering a question**", 1)[0]
|
||||
self.assertLess(building.index("index lines"), building.index("new concept"))
|
||||
self.assertIn("packs of five", self.text)
|
||||
|
||||
def test_the_skill_names_what_the_build_rests_on(self) -> None:
|
||||
for phrase in ("verbatim", "the hard check", "`documented`", "`inferred`", "`merged`", "main page", "home",
|
||||
"the guard", "breach stop", "Disputed", "Outdated", "`generated.by`",
|
||||
"The auditor runs after every pack", "Code never makes a link", "no exception list"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, self.text)
|
||||
|
||||
def test_no_code_linker_and_no_closing_pass(self) -> None:
|
||||
for phrase in ("orphans", "closing pass", "x-outdated:", "x-disputed:"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertNotIn(phrase, self.text)
|
||||
|
||||
def test_the_stop_command_parses_with_the_cost_tools_own_parser(self) -> None:
|
||||
self.assertIn(STOP, self.text)
|
||||
argv = [PLACEHOLDERS.get(w, w) for w in shlex.split(STOP)[3:]]
|
||||
args = cost.build_parser().parse_args(argv)
|
||||
self.assertEqual((args.command, args.lines, args.unit), ("stop", "build,link,orchestration-build", "blocks"))
|
||||
self.assertEqual((args.kost, args.blocks), ("kost.json", "packs.json")) # --kost and --blocks both given
|
||||
self.assertEqual(466, args.next) # the operator 12.10.2026: measured cost and the next pack stop, not a projection
|
||||
|
||||
def test_the_reading_commands_of_k6_stand_verbatim_and_one_task_per_claim_is_gone(self) -> None:
|
||||
for command in K6:
|
||||
with self.subTest(command=command):
|
||||
self.assertIn(command, self.text)
|
||||
self.assertIn("okf-wiki-reader", self.text)
|
||||
self.assertIn("up to ten claims", self.text)
|
||||
reading = self.section("## Check: criterion 1 and 2").split("\n5. ", 1)[0] # step 5's krepair fix takes --answers
|
||||
for gone in ("one task per claim", "--answers", "each task to its own reader"):
|
||||
self.assertNotIn(gone, reading)
|
||||
self.assertNotIn("one task per claim", self.text)
|
||||
|
||||
def test_a_fragment_rejected_at_writing_is_dropped_and_only_an_unwritten_output_runs_the_pack_again(self) -> None:
|
||||
chain = self.section("### One pack")
|
||||
retry = next(x for x in chain.split("\n") if f"exit {kpack.EXIT_RETRY}" in x)
|
||||
self.assertIn("output left unwritten", retry)
|
||||
self.assertNotIn("rejected", retry)
|
||||
checks = self.section("## What code checks, and what stops the build")
|
||||
self.assertIn("is dropped and counted", checks)
|
||||
self.assertNotIn("A fragment that fails the hard check, or an output left unwritten", checks)
|
||||
|
||||
def exit_line(self, code: int) -> str:
|
||||
bullets = self.section("### One pack").split("\n - ")
|
||||
return " ".join(next(x for x in bullets if x.startswith(f"exit {code}:")).split())
|
||||
|
||||
def test_the_run_after_exit_codes_in_the_skill_are_the_codes_of_the_code(self) -> None:
|
||||
# review finding 45 (order 39): exit 1 and exit 7 are bound to kpack's constants as well
|
||||
for code, meanings in ((kpack.EXIT_RETRY, ("compiler",)), (kpack.EXIT_GUARD, ("guard",)),
|
||||
(kpack.EXIT_BREACH, ("STOP",)), (kpack.EXIT_REJECTED_TWICE, ("STOP", "unwritten twice")),
|
||||
(kpack.EXIT_STOP, ("STOP", "stop line", "measured", "next pack", "margin", "ceiling")),
|
||||
(kpack.EXIT_THIN, ("STOP", "floor"))):
|
||||
for meaning in meanings:
|
||||
with self.subTest(code=code, meaning=meaning):
|
||||
self.assertIn(meaning, self.exit_line(code))
|
||||
self.assertNotIn("projected", self.exit_line(kpack.EXIT_STOP)) # the projection is printed, never a stop
|
||||
self.assertEqual(len({kpack.EXIT_RETRY, kpack.EXIT_GUARD, kpack.EXIT_BREACH, kpack.EXIT_REJECTED_TWICE,
|
||||
kpack.EXIT_THIN, 0, kpack.EXIT_STOP, 2}), 8)
|
||||
|
||||
def test_cost_cut_1_one_chain_and_two_helpers_per_turn_without_an_interval(self) -> None:
|
||||
# wave 4 order 22, cost cut 1 (PLAN.md section Rammer 05.10: more packs per orchestration turn): wave 3 spent
|
||||
# about 7.5 main-session turns per pack. The steps without a model that end pack N and start pack N+1 run as
|
||||
# one chain in one shell call, then the linker for N and the compiler for N+1 start in one message. No
|
||||
# interval: the compiler for N+1 is rendered after run-after N, so it sees every pack before it.
|
||||
one = self.text.split("### One pack", 1)[1].split("\n## ", 1)[0]
|
||||
flat = " ".join(one.split())
|
||||
self.assertIn('step() { "$@"; e=$?; echo "exit $e: $3 $4"; return $e; }', one)
|
||||
chain = [line.strip().rstrip("\\").strip().removesuffix("&&").strip() for line in one.splitlines()
|
||||
if line.strip().startswith("step python3 -m okfwiki.")]
|
||||
self.assertEqual([c.split()[3:5] for c in chain], [["okfwiki.klink", "pass-after"], ["okfwiki.kpack", "run-after"],
|
||||
["okfwiki.klink", "pass-before"],
|
||||
["okfwiki.kpack", "run-before"]])
|
||||
for c in chain:
|
||||
words = [PLACEHOLDERS.get(w, w) for w in shlex.split(c)[3:]]
|
||||
words = ["2" if w in ("N", "N-1", "N+1") else w for w in words]
|
||||
with self.subTest(command=words[1]):
|
||||
PARSERS[words[0]]().parse_args(words[1:])
|
||||
self.assertIn("the linker for pack N and the compiler for pack N+1 in one message", flat)
|
||||
self.assertIn("stops at the first command whose exit is not 0", flat)
|
||||
self.assertNotRegex(one, r"--to\b") # --total is not --to
|
||||
|
||||
def test_the_compiler_writes_each_output_in_its_own_turn(self) -> None:
|
||||
# order 22 A2: in round 1 the compiler for pack 1 hit the limit on one answer's output and wrote a fifth of
|
||||
# what wave 3 wrote; a pack of more than two parts has one output per two parts, each written in its own turn
|
||||
flat = " ".join(self.section("### One pack").split())
|
||||
self.assertIn("the first output holds the first task part alone and every later one two", flat)
|
||||
self.assertIn("each in its own turn", flat)
|
||||
self.assertIn("an output left unwritten", flat)
|
||||
|
||||
def test_a_rebuild_has_a_floor_of_cited_blocks_per_source_and_exit_7_stops(self) -> None:
|
||||
# order 22 A2: condition (b) of the wave's goal (every source cites at least as many blocks as before),
|
||||
# checked after every pack instead of first in session C, after the ceiling is spent
|
||||
one = self.section("### One pack")
|
||||
flat = " ".join(one.split())
|
||||
m = re.search(r"python3 -m okfwiki\.kpack cited [^`\n]*", self.text)
|
||||
self.assertIsNotNone(m, "the skill names no kpack cited command")
|
||||
assert m is not None
|
||||
words = [PLACEHOLDERS.get(w, w) for w in shlex.split(m.group(0))[3:]]
|
||||
kpack.build_parser().parse_args(words)
|
||||
self.assertIn("--floor FLOOR", flat)
|
||||
line = next((x for x in one.split("\n") if "exit 7" in x), "")
|
||||
self.assertIn("STOP", line)
|
||||
self.assertIn("floor", line)
|
||||
run_after = next(line.strip().removesuffix("&&").strip() for line in one.splitlines()
|
||||
if line.strip().startswith("step python3 -m okfwiki.kpack run-after"))
|
||||
words = ["2" if w == "N" else PLACEHOLDERS.get(w, w) for w in shlex.split(run_after)[4:]]
|
||||
kpack.build_parser().parse_args([*words, "--floor", "floor.json"])
|
||||
|
||||
def test_the_skill_and_kpack_say_how_a_built_collection_is_continued(self) -> None:
|
||||
# order 27 A2: the packs packs.json records keep their sources, new sources follow in new packs of a size
|
||||
# set per pack, the skeleton gains the new docs pages, and the first new pack starts with run-before alone
|
||||
cont = self.section("### Continue a built collection")
|
||||
flat = " ".join(cont.split())
|
||||
m = re.search(r"python3 -m okfwiki\.kpack skeleton [^`\n]*--extend[^`\n]*", cont)
|
||||
self.assertIsNotNone(m, "the skill names no skeleton --extend command")
|
||||
assert m is not None
|
||||
kpack.build_parser().parse_args(shlex.split(m.group(0))[3:])
|
||||
for phrase in ("keep their sources", "new packs after the last", "docs pages before release notes",
|
||||
"--size S", "an existing entry never changes"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, flat)
|
||||
sentence = next((s for s in re.split(r"(?<=\.) ", flat) if "first new pack" in s), "")
|
||||
self.assertIn("run-before", sentence)
|
||||
self.assertIn("leaves out pass-after", sentence)
|
||||
helptext = " ".join((kpack.__doc__ or "").split())
|
||||
self.assertIn("--extend", helptext)
|
||||
self.assertIn("A built collection is continued", helptext)
|
||||
|
||||
def test_new_packs_can_keep_the_groups_apart_under_a_cap_of_blocks(self) -> None:
|
||||
# order 28 A2: docs pages and release notes never in one new pack, and at most about B blocks per new pack
|
||||
flat = " ".join(self.section("### Continue a built collection").split())
|
||||
for phrase in ("--max-blocks B", "--groups-apart", "a source over B alone", "registered in packs.json"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, flat)
|
||||
m = re.search(r"python3 -m okfwiki\.kpack run-before [^`\n]*--groups-apart[^`\n]*", self.text)
|
||||
self.assertIsNotNone(m, "the skill names no run-before with the options")
|
||||
assert m is not None
|
||||
words = ["13" if w == "N" else ("1000" if w == "B" else ("5" if w == "S" else w))
|
||||
for w in shlex.split(m.group(0))[3:]]
|
||||
args = kpack.build_parser().parse_args(words)
|
||||
self.assertEqual((args.max_blocks, args.groups_apart), (1000, True))
|
||||
|
||||
def test_a_floor_for_a_new_fetch_scales_by_the_blocks_that_can_carry_a_claim(self) -> None:
|
||||
# c1 pack 16 (09.11.2026): a floor scaled by all blocks now held a page that split out its step headings to
|
||||
# more than its unchanged prose could give; kpack floor leaves out the blocks that carry no claim
|
||||
one = self.section("### One pack")
|
||||
flat = " ".join(one.split())
|
||||
m = re.search(r"python3 -m okfwiki\.kpack floor [^`\n]*", one)
|
||||
self.assertIsNotNone(m, "the skill names no kpack floor command")
|
||||
assert m is not None
|
||||
args = kpack.build_parser().parse_args(argv_of(m.group(0)))
|
||||
self.assertEqual((args.command, args.history_rate), ("floor", 0.15))
|
||||
for phrase in ("carry no claim", "thematic break", "only bold text"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, flat)
|
||||
|
||||
def test_the_history_sources_of_a_pack_have_a_floor_together(self) -> None:
|
||||
# order 28 A4: a release note has no floor of its own; the pack's history sources together, from history_rate
|
||||
flat = " ".join(self.section("### One pack").split())
|
||||
self.assertIn("history_rate", flat)
|
||||
self.assertIn("history sources of a pack", flat)
|
||||
|
||||
def test_a_page_without_a_home_the_operator_approves_goes_on_his_list_and_the_build_goes_on(self) -> None:
|
||||
# order 28 A5 (the operator 14.10.2026, "Stopp, du godkjenner, videre"): the stop stands, he approves the page
|
||||
# as a reported exception on a list only he changes, and run-after goes on from the stop
|
||||
flat = " ".join(self.text.split())
|
||||
self.assertIn(f"WORK/{kpack.HOMELESS_APPROVED}", flat)
|
||||
for phrase in ("no code and no model writes it", "never gets a forced link", "the auditor still reports",
|
||||
"There is no exception list for links"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, flat)
|
||||
line = " ".join(next(x for x in self.section("### One pack").split("\n - ") if x.startswith("exit 5")).split())
|
||||
self.assertIn("STOP", line)
|
||||
self.assertIn("again from run-after", line)
|
||||
|
||||
def test_a_document_with_no_readable_content_the_operator_approves_goes_on_the_same_list(self) -> None:
|
||||
# the operator 13.11.2026: a source no page cites (no readable content) is reported instead of stopping the
|
||||
# build when he approves it; nothing is forced
|
||||
flat = " ".join(self.text.split())
|
||||
for phrase in ("no readable content", "under `sources` (the source, the pack, the date and his words)",
|
||||
"it never gets a forced fragment or main page"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, flat)
|
||||
line = " ".join(next(x for x in self.section("### One pack").split("\n - ") if x.startswith("exit 5")).split())
|
||||
self.assertIn("no readable content", line)
|
||||
|
||||
def test_a_build_over_several_sessions_keeps_one_ledger_and_one_link_pass_per_pack(self) -> None:
|
||||
# order 28 A6: a new orchestrating session about every ten packs; every session in the ledger, and the link
|
||||
# pass of a session's last pack runs once, in the next session's first message and chain
|
||||
part = " ".join(self.section("### A build over several sessions").split())
|
||||
for phrase in ("appends its own line", "before its first model run", "never rewritten",
|
||||
"the linker for the last pack of the session before", "pass-after for that pack",
|
||||
"exactly once"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, part)
|
||||
|
||||
def test_like_concepts_are_judged_by_the_model_and_merged_by_code(self) -> None:
|
||||
# order 29 A4: the candidate pairs come from code, the model judges each pair, code merges; the operator
|
||||
# 13.11.2026: the merged page carries the short name, and the other names stand on the page and in the index
|
||||
part = " ".join(self.section("## Like concepts").split())
|
||||
for phrase in ("every pair of pages", "the same once spacing, punctuation, case and code spelling are set aside",
|
||||
"the words of one name all stand in the other", "no pair is left out", "several pairs",
|
||||
"a group with a pair inside judged different is not merged", "the model judges each pair",
|
||||
"code merges", "a pair without a verdict is not merged", "okf-wiki-merger",
|
||||
"into the page with the shortest name", "is cut, so it stands once",
|
||||
"aliases in the build's catalogue", "stand on the page as `x-aliases`", "(also: A; B)",
|
||||
"the first sentence of its own claims", "--operator FILE",
|
||||
"a control pair judged same stops"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase.lower(), part.lower())
|
||||
for sub in ("propose", "controls", "tasks", "verdicts", "apply"): # review finding 42: tasks needs controls
|
||||
self.assertIn(f"python3 -m okfwiki.kmerge {sub}", part)
|
||||
self.assertIn("--controls", part)
|
||||
self.assertIn("--only", part)
|
||||
|
||||
def test_every_module_and_subcommand_the_skill_names_exists(self) -> None:
|
||||
named = set(re.findall(r"python3 -m (okfwiki\.\w+)", self.text))
|
||||
self.assertEqual(MODULES, named)
|
||||
for m in named:
|
||||
self.assertTrue((ROOT / (m.replace(".", "/") + ".py")).is_file(), m)
|
||||
self.assertEqual(MODULES - NO_PARSER, set(PARSERS)) # review finding 46: every module with a parser is checked
|
||||
for module, sub in set(re.findall(r"python3 -m (okfwiki\.\w+) ([a-z][a-z-]*)", self.text)):
|
||||
if module in PARSERS:
|
||||
with self.subTest(command=f"{module} {sub}"):
|
||||
self.assertIn(sub, subcommands(PARSERS[module]()))
|
||||
for agent in AGENTS:
|
||||
self.assertIn(agent, self.text)
|
||||
self.assertTrue((ROOT / "agents" / f"{agent}.md").is_file(), agent)
|
||||
|
||||
def test_every_command_the_skill_writes_out_parses_with_its_modules_parser(self) -> None:
|
||||
# review finding 46 (order 39): a renamed subcommand or option of claims, reader or view passed before
|
||||
commands = re.findall(r"`(python3 -m (okfwiki\.\w+) [^`]+)`", self.text)
|
||||
self.assertGreater(len(commands), 20)
|
||||
for command, module in commands:
|
||||
if module in NO_PARSER:
|
||||
continue
|
||||
with self.subTest(command=command):
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
PARSERS[module]().parse_args(argv_of(command))
|
||||
|
||||
def test_an_unsupported_claim_is_repaired_at_its_fragment_and_read_again(self) -> None:
|
||||
# review finding 44 (order 39): the repair runs through krepair and the shipped repairer, not kpack replace
|
||||
step = " ".join(self.section("## Check: criterion 1 and 2").split("\n5. ", 1)[1].split())
|
||||
order = ("python3 -m okfwiki.krepair list", "python3 -m okfwiki.krepair task", "okf-wiki-repairer",
|
||||
"python3 -m okfwiki.krepair fix", "python3 -m okfwiki.kassemble build",
|
||||
"python3 -m okfwiki.krepair diff", "with `--ids`")
|
||||
for earlier, later in zip(order, order[1:]):
|
||||
with self.subTest(earlier=earlier, later=later):
|
||||
self.assertLess(step.index(earlier), step.index(later))
|
||||
self.assertIn("V1-<run>-repair-", step) # the description cost isolation --line repair attributes
|
||||
self.assertNotIn("kpack replace", step)
|
||||
|
||||
|
||||
class AgentFilesTest(unittest.TestCase):
|
||||
def test_the_compiler_agent_carries_the_contract_of_the_code(self) -> None:
|
||||
shipped = (ROOT / "agents" / "okf-wiki-compiler.md").read_text(encoding="utf-8")
|
||||
self.assertIn(kpack.CONTRACT, shipped)
|
||||
head = shipped.split("\n---\n", 1)[0]
|
||||
self.assertIn("name: okf-wiki-compiler", head)
|
||||
self.assertIn("tools: Read, Write", head)
|
||||
self.assertIn("model: opus", head)
|
||||
self.assertNotIn("TRIAL", shipped)
|
||||
|
||||
def test_the_compiler_writes_its_outputs_one_per_turn_and_leaves_no_block_out_to_fit(self) -> None:
|
||||
# order 22 A2: told by Claude Code to break the work into smaller pieces, the compiler in round 1 left blocks
|
||||
# out; the outputs are cut by code to fit one answer each
|
||||
shipped = (ROOT / "agents" / "okf-wiki-compiler.md").read_text(encoding="utf-8")
|
||||
work = " ".join(shipped.split("## How to work", 1)[1].split("\n## ", 1)[0].split())
|
||||
self.assertIn("each in its own turn", work)
|
||||
self.assertIn("never leave a block out to make an output fit", work)
|
||||
self.assertNotIn("write the one JSON file", work)
|
||||
|
||||
def test_the_compiler_is_never_told_to_drop_a_history_concept_without_a_home(self) -> None:
|
||||
# order 10: without a home the page is homeless and the guard asks; the prompt must not contradict the contract
|
||||
shipped = (ROOT / "agents" / "okf-wiki-compiler.md").read_text(encoding="utf-8")
|
||||
history = shipped.split("## History sources", 1)[1].split("\n## ", 1)[0]
|
||||
self.assertNotIn("not kept", history)
|
||||
self.assertIn("home", history)
|
||||
|
||||
def test_the_skill_says_a_home_stays_with_its_page_on_replace_and_remove(self) -> None:
|
||||
skill = (ROOT / "skills" / "okf-wiki" / "SKILL.md").read_text(encoding="utf-8")
|
||||
self.assertNotIn("main page and home records go with it", skill)
|
||||
self.assertIn("A home belongs to its page", skill)
|
||||
self.assertIn("a home the model gives anew wins", skill)
|
||||
self.assertIn("the page is no main page itself", " ".join(skill.split()))
|
||||
|
||||
def test_no_build_text_shares_a_run_of_eight_words_with_the_readers_instructions(self) -> None:
|
||||
# wave 4 0-felles section 2: the compiler never gets the reader's task text, so it cannot learn to pass the
|
||||
# reader instead of saying what the source says; the rule is the one reader render uses (reader.shared_runs)
|
||||
texts = {"agents/okf-wiki-compiler.md": (ROOT / "agents" / "okf-wiki-compiler.md").read_text(encoding="utf-8"),
|
||||
"agents/okf-wiki-linker.md": (ROOT / "agents" / "okf-wiki-linker.md").read_text(encoding="utf-8"),
|
||||
"kpack.CONTRACT": kpack.CONTRACT, "skills/okf-wiki/SKILL.md": SKILL.read_text(encoding="utf-8")}
|
||||
pairs = [reader.Pair(name, text, ()) for name, text in texts.items()]
|
||||
self.assertEqual(reader.shared_runs(reader.INSTRUCTIONS, pairs), [])
|
||||
planted = reader.Pair("planted", " ".join(reader.INSTRUCTIONS.split()[40:52]), ())
|
||||
self.assertEqual(reader.shared_runs(reader.INSTRUCTIONS, [planted]), ["planted"]) # the check can fail
|
||||
|
||||
def test_the_merger_reads_one_task_and_answers_one_line_per_pair(self) -> None:
|
||||
# order 29 A4: tools Read only; same concept or not, from the meaning of the claims and the quotes
|
||||
shipped = (ROOT / "agents" / "okf-wiki-merger.md").read_text(encoding="utf-8")
|
||||
head, body = shipped.split("\n---\n", 1)
|
||||
self.assertIn("name: okf-wiki-merger", head)
|
||||
self.assertIn("\ntools: Read\n", head + "\n")
|
||||
self.assertIn("model: opus", head)
|
||||
self.assertIn("effort: high", head)
|
||||
text = " ".join(body.split())
|
||||
for phrase in ("one task file", "read nothing else", "one line per pair", "the same concept",
|
||||
"the meaning of the claims and the quotes"):
|
||||
with self.subTest(phrase=phrase):
|
||||
self.assertIn(phrase, text)
|
||||
self.assertIn("same", kmerge.CONTRACT)
|
||||
self.assertIn("different", kmerge.CONTRACT)
|
||||
|
||||
def test_the_agent_copies_are_byte_identical(self) -> None:
|
||||
for name in ("okf-wiki-compiler.md", "okf-wiki-linker.md", "okf-wiki-merger.md"):
|
||||
with self.subTest(agent=name):
|
||||
self.assertEqual((ROOT / "agents" / name).read_bytes(), (ROOT / ".claude" / "agents" / name).read_bytes())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue