Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-mv/patches/78472b5e5597f0c5 # interplane-mv INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/interplane-mv#67 (code only) closed derived `78472b5e5597f0c5` #67 Imported from GitHub aien-dev/interplane-mv#67 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `49879ab9c96d4146903bff9f858af638843a0d3c` · Head `cd9ee77bec1cfeab696fd479e8626cde6a2dab56` ### Apply it ``` git checkout -b patch-78472b5e5597f0c5 49879ab9c96d4146903bff9f858af638843a0d3c curl -fsSL https://interplane.io/drakestapleton/interplane-mv/patches/78472b5e5597f0c5.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/interplane-mv 67 cd9ee77bec1cfeab696fd479e8626cde6a2dab56 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"interplane-mv","number":67,"url":"https://github.com/aien-dev/interplane-mv/pull/67","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:09Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4e4339..5fca868 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: python bench/tools/test_authoring_02y.py python bench/tools/test_assemble_02y.py python bench/tools/assemble_02y.py --check-slots + PYTHONPATH=python python bench/tools/test_runner_corpus_y.py - name: analyzer tests and synthetic-run fixture (no model, no GPU) run: | python bench/tools/test_analyze.py diff --git a/bench/tools/run_bench.py b/bench/tools/run_bench.py index 828a963..a58b32c 100644 --- a/bench/tools/run_bench.py +++ b/bench/tools/run_bench.py @@ -308,6 +308,9 @@ REASONING_FIELDS = ("reasoning_effort", "chat_template_kwargs") ADDENDUM_REL = Path("prompts") / "discovery-addendum.md" # under the held-out root HELDOUT_SEEDS = (42, 43, 44) CAMPAIGN_CORPUS = "0.2x" +# PREREG-0.2y: the new 120-task set and its 30-task calibration set run the campaign path too (sim-1, qual split). +Y_CORPORA = ("0.2y", "0.2y-cal") +CAMPAIGN_CORPORA = (CAMPAIGN_CORPUS,) + Y_CORPORA def condition_spec(cx: dict, cond: str) -> dict: @@ -920,6 +923,27 @@ def make_cx(args, tasks_dir: Path, root: Path = BENCH, conds=None) -> dict: } +def corpus_gate(corpus: str, tasks_dir: Path, which: str, partial_ok: bool = False) -> list: + """Load the tasks of a 0.2y corpus and refuse a missing, empty or partial one (exit with a message). + + ``partial_ok`` (with --allow-nonfrozen, synthetic tasks only) skips the exact-count rule, never the + missing or empty rule. Returns the selected tasks.""" + import validate + + if not tasks_dir.is_dir(): + raise SystemExit(f"corpus {corpus}: tasks folder {tasks_dir} does not exist: refusing to run") + if not list(tasks_dir.glob("*.json")): + raise SystemExit(f"corpus {corpus}: tasks folder {tasks_dir} holds no tasks: refusing to run") + every = load_tasks(tasks_dir, "all", []) + want = validate.Y_CALIBRATION_TOTAL if corpus == "0.2y-cal" else validate.Y_TOTAL + if len(every) != want and not partial_ok: + raise SystemExit(f"corpus {corpus}: {len(every)} tasks, expected exactly {want}: partial corpus, refusing to run") + tasks = load_tasks(tasks_dir, which, []) + if not tasks: + raise SystemExit(f"corpus {corpus}: no task has split {which!r}: refusing to run") + return tasks + + def check_corpus(strict: bool, corpus: str = "0.2") -> dict: import validate # bench/tools/validate.py @@ -967,8 +991,12 @@ def main(argv=None) -> int: ap = argparse.ArgumentParser(description=__doc__.split("\n")[0]) ap.add_argument("--tasks", choices=["dev", "qual", "all"], default=None, help="default: dev for corpus 0.2, qual for corpus 0.2x") - ap.add_argument("--corpus", choices=["0.2", CAMPAIGN_CORPUS], default="0.2", - help="0.2 = bench/tasks; 0.2x = the held-out set bench/heldout-0.2x (PROTOCOL-0.2x.md); needs --backends sim-1") + ap.add_argument("--corpus", choices=["0.2", *CAMPAIGN_CORPORA], default="0.2", + help="0.2 = bench/tasks; 0.2x = the held-out set bench/heldout-0.2x (PROTOCOL-0.2x.md); 0.2y = bench/heldout-0.2y " + "(120 tasks) and 0.2y-cal = its 30-task calibration set (PREREG-0.2y); all need --backends sim-1. " + "0.2y and 0.2y-cal refuse a missing, empty or partial tasks folder and a corpus without its frozen digest file") + ap.add_argument("--check-corpus", action="store_true", + help="load the corpus tasks, apply the completeness rules, print the count and exit; no model, no Odysseus") ap.add_argument("--condition", choices=list(CONDITION_IDS) + ["both", "all"], default="both", help="A/B/both = 0.2. A2, A4, B1..B4 = the PROTOCOL-0.2x.md conditions; all = the seven, in order " "A A2 A4 B1 B2 B3 B4 rotated left by (task index mod 7). B3 is arm 3 (runtime-v1), " @@ -1002,17 +1030,35 @@ def main(argv=None) -> int: out = Path(args.out) run_id = out.name.rstrip("/") - heldout = args.corpus == CAMPAIGN_CORPUS - root = BENCH / "heldout-0.2x" if heldout else BENCH + heldout = args.corpus in CAMPAIGN_CORPORA + if args.corpus in Y_CORPORA: + import validate + root = validate.CORPORA[args.corpus]["root"] + else: + root = BENCH / "heldout-0.2x" if heldout else BENCH tasks_dir = Path(args.tasks_dir) if args.tasks_dir else root / "tasks" args.tasks = args.tasks or ("qual" if heldout else "dev") + if args.corpus in Y_CORPORA: + gated = corpus_gate(args.corpus, tasks_dir, args.tasks, partial_ok=args.allow_nonfrozen) + if args.check_corpus: + print(f"corpus {args.corpus}: {len(gated)} tasks load from {tasks_dir}; completeness rules pass") + return 0 + elif args.check_corpus: + raise SystemExit("--check-corpus is for the 0.2y corpora") + if args.corpus in Y_CORPORA and not args.allow_nonfrozen \ + and os.path.realpath(tasks_dir) != os.path.realpath(validate.CORPORA[args.corpus]["tasks"]): + # The frozen digest covers the canonical folder only: a real run reads exactly those tasks. + raise SystemExit(f"corpus {args.corpus}: --tasks-dir {tasks_dir} is not the frozen tasks folder " + f"{validate.CORPORA[args.corpus]['tasks']}: refusing to run (synthetic runs need --allow-nonfrozen)") args.campaign_mode = heldout or args.condition not in ("A", "B", "both") if args.campaign_mode: if args.backends != "sim-1": raise SystemExit("0.2x conditions and the held-out corpus need --backends sim-1 (PROTOCOL-0.2x.md section 10)") if args.expansion_policy != "0.2": raise SystemExit("--expansion-policy is fixed by the condition id in 0.2x (B3 = runtime-v1, others 0.2)") - if heldout and args.seed not in HELDOUT_SEEDS and not args.allow_nonfrozen: + if args.corpus == "0.2y-cal" and args.seed != HELDOUT_SEEDS[0] and not args.allow_nonfrozen: + raise SystemExit("the calibration run is condition A, seed 42, once (PREREG-0.2y section 5)") + if heldout and args.corpus != "0.2y-cal" and args.seed not in HELDOUT_SEEDS and not args.allow_nonfrozen: raise SystemExit(f"held-out runs use seeds {list(HELDOUT_SEEDS)} (PROTOCOL-0.2x.md section 8)") if args.condition == "both": conds = list(CAMPAIGN_CONDITIONS[:1]) + ["B"] if not args.campaign_mode else list(CAMPAIGN_CONDITIONS) @@ -1020,6 +1066,9 @@ def main(argv=None) -> int: conds = list(CAMPAIGN_CONDITIONS) else: conds = [args.condition] + if args.corpus == "0.2y-cal" and conds != ["A"]: + # Never bypassed, not even for synthetic runs: no B condition ever runs on the calibration set. + raise SystemExit("the calibration run is condition A, seed 42, once (PREREG-0.2y section 5): pass --condition A") src = os.environ.get("ODYSSEUS_SRC", "") ody = _odysseus.load() if ody is None or not src: @@ -1051,6 +1100,7 @@ def main(argv=None) -> int: manifest_path = out / "manifest.json" manifest = { "kind": "interplane_bench_manifest", "manifest_version": "0.2.0", "run_id": run_id, + "allow_nonfrozen": bool(args.allow_nonfrozen), # true = synthetic or unfrozen inputs: never a result "tasks": args.tasks, "task_ids": [t["id"] for t in tasks], "conditions": conds, "interplane": git_state(REPO), "runner": {"run_bench_sha256": file_sha(Path(__file__)), "bench_eval_sha256": file_sha(BENCH / "tools" / "bench_eval.py")}, "odysseus": env["odysseus"], diff --git a/bench/tools/test_runner_corpus_y.py b/bench/tools/test_runner_corpus_y.py new file mode 100644 index 0000000..46737e4 --- /dev/null +++ b/bench/tools/test_runner_corpus_y.py @@ -0,0 +1,160 @@ +"""Offline tests: run_bench.py accepts --corpus 0.2y and 0.2y-cal and refuses missing, empty or partial corpora. + +No model, no Odysseus, no GPU. Stdlib unittest: PYTHONPATH=python python3 bench/tools/test_runner_corpus_y.py +""" + +from __future__ import annotations + +import contextlib +import io +import json +import sys +import tempfile +import os +import unittest +from unittest import mock +from pathlib import Path + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import run_bench as R # noqa: E402 + + +def make_dir(root: Path, n: int, split: str = "qual") -> Path: + d = root / "tasks" + d.mkdir(parents=True, exist_ok=True) + for i in range(n): + (d / f"t-{i:03d}.json").write_text(json.dumps({"id": f"t-{i:03d}", "split": split}), encoding="utf-8") + return d + + +def check(corpus: str, tasks_dir: Path, *extra) -> tuple: + """(exit message or 0, stdout) of `run_bench --corpus X --check-corpus --tasks-dir D`.""" + buf = io.StringIO() + try: + with contextlib.redirect_stdout(buf): + rc = R.main(["--corpus", corpus, "--check-corpus", "--backends", "sim-1", "--out", "/nonexistent/out", + "--tasks-dir", str(tasks_dir), *extra]) + except SystemExit as e: + rc = e.code + return rc, buf.getvalue() + + +class CorpusOption(unittest.TestCase): + def test_both_corpora_are_accepted_choices(self): + self.assertEqual(R.Y_CORPORA, ("0.2y", "0.2y-cal")) + with self.assertRaises(SystemExit) as cm: + R.main(["--corpus", "0.2z", "--out", "x"]) + self.assertEqual(cm.exception.code, 2) # argparse rejects an unknown corpus + + def test_full_corpus_loads(self): + with tempfile.TemporaryDirectory() as tmp: + self.assertEqual(check("0.2y", make_dir(Path(tmp), 120))[0], 0) + with tempfile.TemporaryDirectory() as tmp: + rc, out = check("0.2y-cal", make_dir(Path(tmp), 30)) + self.assertEqual(rc, 0) + self.assertIn("30 tasks load", out) + + def test_missing_folder_is_refused(self): + rc, _ = check("0.2y", Path("/nonexistent/tasks")) + self.assertIn("does not exist", str(rc)) + + def test_empty_folder_is_refused(self): + with tempfile.TemporaryDirectory() as tmp: + d = Path(tmp) / "tasks" + d.mkdir() + self.assertIn("holds no tasks", str(check("0.2y", d)[0])) + self.assertIn("holds no tasks", str(check("0.2y-cal", d, "--allow-nonfrozen")[0])) + + def test_partial_corpus_is_refused(self): + with tempfile.TemporaryDirectory() as tmp: + d = make_dir(Path(tmp), 119) + self.assertIn("partial corpus", str(check("0.2y", d)[0])) + with tempfile.TemporaryDirectory() as tmp: + self.assertIn("expected exactly 30", str(check("0.2y-cal", make_dir(Path(tmp), 29))[0])) + with tempfile.TemporaryDirectory() as tmp: # the target count is wrong for the calibration set + self.assertIn("expected exactly 30", str(check("0.2y-cal", make_dir(Path(tmp), 120))[0])) + + def test_partial_is_allowed_only_for_synthetic_runs(self): + with tempfile.TemporaryDirectory() as tmp: + self.assertEqual(check("0.2y", make_dir(Path(tmp), 5), "--allow-nonfrozen")[0], 0) + + def test_no_qual_tasks_is_refused(self): + with tempfile.TemporaryDirectory() as tmp: + self.assertIn("no task has split", str(check("0.2y", make_dir(Path(tmp), 120, "dev"))[0])) + + def test_repository_corpus_without_tasks_is_refused(self): + # the default tasks folder of 0.2y does not exist until the authoring PR merges + import validate + if (validate.CORPORA["0.2y"]["tasks"]).is_dir(): + self.skipTest("0.2y tasks exist in this checkout") + buf = io.StringIO() + with contextlib.redirect_stdout(buf), self.assertRaises(SystemExit) as cm: + R.main(["--corpus", "0.2y", "--check-corpus", "--backends", "sim-1", "--out", "/nonexistent/out"]) + self.assertIn("does not exist", str(cm.exception.code)) + + def test_missing_or_mismatched_digest_refuses_a_real_run(self): + # strict mode: an absent digest file (every value None) or a different digest refuses; runs whatever the checkout holds + import validate + now = {"tasks_digest": "sha256:a", "inputs_digest": "sha256:b", "protocol_sha256": "sha256:c"} + with mock.patch.object(validate, "digests", return_value=now): + for frozen in ({}, {**now, "tasks_digest": "sha256:stale"}): + with mock.patch.object(validate, "read_digest_file", return_value=frozen): + with self.assertRaises(SystemExit) as cm: + R.check_corpus(True, "0.2y-cal") + self.assertIn("differs from CORPUS-DIGEST.txt", str(cm.exception)) + self.assertFalse(R.check_corpus(False, "0.2y-cal")["match"]) + with mock.patch.object(validate, "read_digest_file", return_value=dict(now)): + self.assertTrue(R.check_corpus(True, "0.2y-cal")["match"]) + + def test_check_corpus_flag_is_only_for_y_corpora(self): + with self.assertRaises(SystemExit) as cm: + R.main(["--corpus", "0.2", "--check-corpus", "--out", "x"]) + self.assertIn("0.2y corpora", str(cm.exception)) + + + +def real_run(corpus: str, tasks_dir: Path, *extra) -> str: + """Exit message of a real (not --check-corpus) run. Without ODYSSEUS_SRC a run that gets past every corpus guard + stops at the Odysseus check, before any model request.""" + with mock.patch.dict(os.environ, {"ODYSSEUS_SRC": ""}), contextlib.redirect_stdout(io.StringIO()): + try: + R.main(["--corpus", corpus, "--backends", "sim-1", "--out", "/nonexistent/out", "--tasks-dir", str(tasks_dir), *extra]) + except SystemExit as e: + return str(e.code) + return "no exit" + + +class RealRunGuards(unittest.TestCase): + PAST_GUARDS = "ODYSSEUS_SRC" + + def test_other_tasks_folder_is_refused_for_a_real_run(self): + # the frozen digest covers the canonical folder only: a complete 120-task folder elsewhere is still refused + with tempfile.TemporaryDirectory() as tmp: + d = make_dir(Path(tmp), 120) + self.assertIn("is not the frozen tasks folder", real_run("0.2y", d)) + self.assertIn(self.PAST_GUARDS, real_run("0.2y", d, "--allow-nonfrozen")) + + def test_calibration_runs_condition_a_only(self): + with tempfile.TemporaryDirectory() as tmp: + d = make_dir(Path(tmp), 30) + for cond in ("both", "all", "B3", "A2"): + msg = real_run("0.2y-cal", d, "--allow-nonfrozen", "--condition", cond) + self.assertIn("condition A, seed 42", msg, cond) + self.assertIn(self.PAST_GUARDS, real_run("0.2y-cal", d, "--allow-nonfrozen", "--condition", "A")) + + def test_calibration_seed_is_42(self): + import validate + with tempfile.TemporaryDirectory() as tmp: + d = make_dir(Path(tmp), 30) + with mock.patch.dict(validate.CORPORA["0.2y-cal"], {"tasks": d}): # d plays the frozen folder + self.assertIn("condition A, seed 42", real_run("0.2y-cal", d, "--condition", "A", "--seed", "43")) + self.assertIn(self.PAST_GUARDS, real_run("0.2y-cal", d, "--condition", "A", "--seed", "42")) + self.assertIn(self.PAST_GUARDS, real_run("0.2y", make_dir(Path(tmp) / "y", 120), "--allow-nonfrozen")) + + def test_manifest_records_nonfrozen(self): + src = R.Path(R.__file__).read_text(encoding="utf-8") + self.assertIn('"allow_nonfrozen": bool(args.allow_nonfrozen)', src) + +if __name__ == "__main__": + unittest.main() ```