interplane.Get Omega
Read in your language

interplane-mv

INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.

Brought by drakestapleton

GitHub aien-dev/interplane-mv#65 (code only)

closed derived b1cbd4428701ed67 #65

Imported from GitHub aien-dev/interplane-mv#65 (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 9bb16e9ee8e1306a85022e47f7cda5464059bbbb · Head b1e44f86f4b204400e4e04e107e3fd1d134a6436

Apply it

git checkout -b patch-b1cbd4428701ed67 9bb16e9ee8e1306a85022e47f7cda5464059bbbb
curl -fsSL https://interplane.io/drakestapleton/interplane-mv/patches/b1cbd4428701ed67.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
65
b1e44f86f4b204400e4e04e107e3fd1d134a6436
{"kind":"github-import","owner":"aien-dev","repo":"interplane-mv","number":65,"url":"https://github.com/aien-dev/interplane-mv/pull/65","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:09Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/bench/tools/analyze.py b/bench/tools/analyze.py
index d4c8791..2bb86af 100644
--- a/bench/tools/analyze.py
+++ b/bench/tools/analyze.py
@@ -106,16 +106,93 @@ def boot_ci(deltas: list, seed: int = BOOT_SEED, n_boot: int = BOOT_N) -> dict:
 
 # ------------------------------------------------------------------------------- loading
 
-R1_REQUIRED = ("B5",)  # conditions whose receipts must carry the R1 fields (bench_eval.r1_problems)
+R1_ALWAYS = ("B5",)  # historical rule: only B5 receipts carry R1 (PREREG-0.2y condition B5, #64)
+# PREREG-0.2y section 4: a run labelled 0.2y must satisfy R1 in every one of these arms and use no other arm.
+R1_CAMPAIGNS = {"0.2y": ("A", "B3", "B5")}
+# Historical corpora: the weaker R1 rule applies only to a run PROVEN to be that corpus. The label in the manifest is
+# self-declared and proves nothing. Proof = the manifest records the frozen tasks_digest of that corpus (the value in its
+# CORPUS-DIGEST.txt, written by validate.py/run_bench.check_corpus) AND every receipt's task id is a task of that corpus.
+# Arm lists are the historical ones: 0.2 ran A,B (PROTOCOL-0.2.md); 0.2x ran CAMPAIGN_CONDITIONS (run_bench.py; B5 is
+# "explicit only, never part of CAMPAIGN_CONDITIONS", #64), so B5 in a historical run is refused.
+HISTORICAL = {
+    "0.2": {"digest": BENCH / "CORPUS-DIGEST.txt", "tasks": BENCH / "tasks", "arms": ("A", "B")},
+    "0.2x": {"digest": BENCH / "heldout-0.2x" / "CORPUS-DIGEST.txt", "tasks": BENCH / "heldout-0.2x" / "tasks",
+             "arms": ("A", "A2", "A4", "B1", "B2", "B3", "B4")},
+}
+DIGEST_0_2Y = BENCH / "heldout-0.2y" / "CORPUS-DIGEST.txt"  # absent until the 0.2y corpus is frozen
+
+
+def frozen_tasks_digest(path: Path):
+    if not path.exists():
+        return None
+    for line in path.read_text(encoding="utf-8").splitlines():
+        if line.startswith("tasks_digest "):
+            return line.split()[1]
+    return None
+
+
+def corpus_task_ids(tasks_dir: Path) -> set:
+    return {json.loads(p.read_text(encoding="utf-8"))["id"] for p in tasks_dir.glob("*.json")}
+
+
+def r1_scope(manifest: dict, conditions: set, task_ids: set) -> tuple:
+    """Returns (arms that need R1, or None for every arm; problems). Problems refuse the run (fail closed).
+    Anything not proven historical gets the strictest rule: R1 in every arm."""
+    camp = manifest.get("campaign")
+    corpus_blk = manifest.get("corpus") if isinstance(manifest.get("corpus"), dict) else {}
+    label = camp.get("corpus") if isinstance(camp, dict) else None
+    if camp is not None and (not isinstance(label, str) or not label):
+        return None, ["campaign block has no corpus identity"]
+    di = ((manifest.get("deterministic_identity") or {}).get("campaign") or {}).get("corpus")
+    if camp is not None and di is not None and di != label:
+        return None, [f"campaign.corpus {label!r} disagrees with deterministic_identity.campaign.corpus {di!r}"]
+    digest = (corpus_blk.get("frozen") or {}).get("tasks_digest")
+    recomputed = (corpus_blk.get("recomputed") or {}).get("tasks_digest")
+    proven = next((k for k, h in HISTORICAL.items()
+                   if digest and digest == recomputed == frozen_tasks_digest(h["digest"]) and corpus_blk.get("match") is True), None)
+    if proven is not None:
+        h = HISTORICAL[proven]
+        if label is not None and label != proven:
+            return None, [f"manifest label {label!r} contradicts the frozen task-set digest of corpus {proven}"]
+        if label is None and proven != "0.2":
+            return None, [f"manifest without campaign block carries the {proven} digest"]
+        outside = sorted(task_ids - corpus_task_ids(h["tasks"]))
+        if outside:  # e.g. a dev run with --allow-nonfrozen and its own task dir: not the frozen corpus, so strict
+            return None, []
+        extra = sorted(conditions - set(h["arms"]))
+        if extra:
+            return None, [f"condition(s) {extra} were not part of historical corpus {proven} (arms {list(h['arms'])})"]
+        return R1_ALWAYS, []
+    # not proven historical from here on: strictest rule (R1 in every arm)
+    if label in R1_CAMPAIGNS:
+        arms = R1_CAMPAIGNS[label]
+        extra = sorted(conditions - set(arms))
+        problems = [f"condition(s) {extra} are not in the {label} arm list {list(arms)}"] if extra else []
+        frozen_y = frozen_tasks_digest(DIGEST_0_2Y)
+        if frozen_y is not None and not (digest == recomputed == frozen_y):
+            problems.append(f"{label} manifest does not record the frozen 0.2y tasks_digest")
+        return None, problems
+    if camp is None:
+        legacy_ok = (conditions <= set(HISTORICAL["0.2"]["arms"]) and task_ids <= corpus_task_ids(HISTORICAL["0.2"]["tasks"]))
+        if legacy_ok and not (digest or recomputed):
+            return R1_ALWAYS, []  # legacy 0.2 layout (also no manifest): frozen 0.2 task ids, 0.2 arms, no other identity claimed
+        return None, ["no provable corpus identity (no campaign block, digest absent or not frozen) for these tasks or arms"]
+    # labelled campaign that is not 0.2y and not proven historical (offline dev runs on custom task dirs): strict R1 only
+    return None, []
 
 
 def load_run(run_dir: Path, tasks_dir: Path) -> dict:
     manifest = json.loads((run_dir / "manifest.json").read_text(encoding="utf-8")) if (run_dir / "manifest.json").exists() else {}
-    rec, r1_invalid = {}, []
+    rec, r1_invalid, raw = {}, [], []
     for p in sorted((run_dir / "receipts").glob("*.json")):
         r = json.loads(p.read_text(encoding="utf-8"))
         rec.setdefault(r["task"]["id"], {})[r["condition"]] = r
-        if r["condition"] in R1_REQUIRED and not bench_eval.r1_valid(r):  # PREREG-0.2y: B5 without R1 fields is invalid
+        raw.append(r)
+    required, id_problems = r1_scope(manifest, {r["condition"] for r in raw}, {r["task"]["id"] for r in raw})
+    if id_problems:  # fail closed: an untrustworthy identity must not downgrade R1 enforcement
+        r1_invalid.append({"task": "*", "condition": "*", "problems": id_problems})
+    for r in raw:
+        if (required is None or r["condition"] in required) and not bench_eval.r1_valid(r):  # PREREG-0.2y: missing R1 fields are invalid
             r1_invalid.append({"task": r["task"]["id"], "condition": r["condition"], "problems": bench_eval.r1_problems(r)})
     tasks = {}
     for p in sorted(tasks_dir.glob("*.json")):
@@ -128,7 +205,7 @@ def refuse_r1_invalid(data: dict, label: str) -> None:
     """PREREG-0.2y validity: no run with an unrecorded query or text counts. The analyzer refuses the
     whole run rather than scoring around it."""
     if data["r1_invalid"]:
-        raise SystemExit(f"{label}: {len(data['r1_invalid'])} B5 receipt(s) without valid R1 fields, run not scored: "
+        raise SystemExit(f"{label}: {len(data['r1_invalid'])} receipt(s) or identity check(s) without valid R1 fields, run not scored: "
                          + json.dumps(data["r1_invalid"][:5]))
 
 
diff --git a/bench/tools/test_analyze.py b/bench/tools/test_analyze.py
index a7fcf40..23a5f24 100644
--- a/bench/tools/test_analyze.py
+++ b/bench/tools/test_analyze.py
@@ -130,11 +130,16 @@ def campaign_receipt(task: dict, cond: str, seed: int, rng: random.Random, recov
     return rc
 
 
+def frozen_corpus_block(name: str) -> dict:
+    d = analyze.frozen_tasks_digest(analyze.HISTORICAL[name]["digest"])
+    return {"frozen": {"tasks_digest": d}, "recomputed": {"tasks_digest": d}, "match": True}
+
+
 def write_campaign_block(out: Path, subset: dict, seed: int, recover: dict) -> None:
     """recover: (cond, expansion kind) -> bool for this block; default True."""
     rng = random.Random(seed)
     (out / "receipts").mkdir(parents=True, exist_ok=True)
-    (out / "manifest.json").write_text(json.dumps({"campaign": {"seed": seed}, "corpus": {"match": True}, "latency_validity": {"valid": True, "reasons": []},
+    (out / "manifest.json").write_text(json.dumps({"campaign": {"seed": seed, "corpus": "0.2x"}, "corpus": frozen_corpus_block("0.2x"), "latency_validity": {"valid": True, "reasons": []},
                                                    "deterministic_identity": {"identity_digest": f"sha256:synthetic-{seed}"}}, sort_keys=True) + "\n")
     for k, t in subset.items():
         for cond in CONDS7:
@@ -199,6 +204,113 @@ def analyze_to(run: Path, out: Path, extra: list = ()) -> None:
     analyze.main([str(run), "--out", str(out), *extra])
 
 
+def r1_receipt(cond: str, tid: str = "t-1", *, text: bool = True, query: bool = True, bad_query=None) -> dict:
+    """Minimal receipt carrying only what bench_eval.r1_problems reads; discovery call only for B-family arms."""
+    r = {"task": {"id": tid}, "condition": cond, "rounds": [{"round": 1}], "calls": []}
+    if text:
+        r["rounds"][0]["text"] = "assistant text"
+    if cond != "A":
+        c = {"round": 1, "index": 0, "discovery": True}
+        if bad_query is not None:
+            c.update(query=bad_query[0], error_code=bad_query[1])
+        elif query:
+            c["query"] = "serve preset"
+        r["calls"].append(c)
+    return r
+
+
+def write_r1_run(out: Path, label, receipts: list, *, digest=None, campaign: bool = True, di_corpus=None, manifest: bool = True) -> Path:
+    """digest: name of a historical corpus whose frozen digest block the manifest records (or None)."""
+    (out / "receipts").mkdir(parents=True)
+    if manifest:
+        m: dict = {"kind": "x"}
+        if campaign:
+            m["campaign"] = {"corpus": label, "seed": 42} if label is not None else {"seed": 42}
+        if digest:
+            m["corpus"] = frozen_corpus_block(digest)
+        if di_corpus is not None:
+            m["deterministic_identity"] = {"campaign": {"corpus": di_corpus}}
+        (out / "manifest.json").write_text(json.dumps(m))
+    for i, r in enumerate(receipts):
+        (out / "receipts" / f"{r['task']['id']}.{r['condition']}.{i}.json").write_text(json.dumps(r))
+    return out
+
+
+def test_r1_scope() -> None:
+    tdir = BENCH / "tasks"
+    hx = sorted(analyze.corpus_task_ids(analyze.HISTORICAL["0.2x"]["tasks"]))[:3]  # real frozen 0.2x task ids
+    h2 = sorted(analyze.corpus_task_ids(analyze.HISTORICAL["0.2"]["tasks"]))[:3]   # real frozen 0.2 task ids
+    fresh = ["fresh-y-1", "fresh-y-2", "fresh-y-3"]                                 # ids in no frozen corpus (0.2y-like)
+    assert not set(fresh) & (set(hx) | set(h2))
+    with tempfile.TemporaryDirectory() as td:
+        td = Path(td)
+        n = [0]
+
+        def load(label, receipts, **kw):
+            n[0] += 1
+            return analyze.load_run(write_r1_run(td / f"r{n[0]}", label, receipts, **kw), tdir)
+
+        def bad(d):
+            return sorted((x["task"], x["condition"]) for x in d["r1_invalid"])
+
+        def arms(ids, conds=("A", "B3", "B5"), **kw):
+            return [r1_receipt(c, i, **kw.get(c, {})) for c, i in zip(conds, ids)]
+
+        # (e) complete valid receipts in every 0.2y arm pass
+        assert load("0.2y", arms(fresh))["r1_invalid"] == []
+        # (a) missing round text in arm A, (b) missing queries in B3, (c) in B5: invalid under 0.2y
+        assert bad(load("0.2y", arms(fresh, A={"text": False}))) == [(fresh[0], "A")]
+        assert bad(load("0.2y", arms(fresh, B3={"query": False}))) == [(fresh[1], "B3")]
+        assert bad(load("0.2y", arms(fresh, B5={"query": False}))) == [(fresh[2], "B5")]
+        # (d) a raw non-string query is valid only as an invalid_arguments error, in any 0.2y arm
+        assert load("0.2y", arms(fresh, B3={"bad_query": (None, "invalid_arguments")}, B5={"bad_query": (7, "invalid_arguments")}))["r1_invalid"] == []
+        for arm, i in (("B3", 1), ("B5", 2)):
+            assert bad(load("0.2y", arms(fresh, **{arm: {"bad_query": (["x"], "ok")}}))) == [(fresh[i], arm)], arm
+        # (f) real historical runs (frozen digest recorded, ids in the frozen corpus) keep the original rule
+        hist7 = [r1_receipt(c, hx[0], text=False, query=False) for c in ("A", "A2", "B1", "B3")]
+        hist7[1]["task"]["id"] = hx[1]
+        hist7[2]["task"]["id"] = hx[2]
+        assert load("0.2x", hist7, digest="0.2x")["r1_invalid"] == []
+        assert load("0.2", [r1_receipt("A", h2[0], text=False), r1_receipt("B", h2[1], text=False, query=False)],
+                    digest="0.2")["r1_invalid"] == []
+        assert load(None, [r1_receipt("A", h2[0], text=False), r1_receipt("B", h2[1], text=False)], campaign=False, digest="0.2")["r1_invalid"] == []
+        # legacy without any manifest: only frozen 0.2 ids and 0.2 arms
+        assert load(None, [r1_receipt("A", h2[0], text=False), r1_receipt("B", h2[1], text=False)], manifest=False)["r1_invalid"] == []
+        # B5 in a historical 0.2x run is refused (B5 was never part of 0.2x; run_bench.py CAMPAIGN_CONDITIONS, #64)
+        d = load("0.2x", hist7 + [r1_receipt("B5", hx[0])], digest="0.2x")
+        assert any("not part of historical corpus 0.2x" in x["problems"][0] for x in d["r1_invalid"]), d["r1_invalid"]
+        # even a historical run still enforces R1 on B5 receipts that are present in a legal arm set
+        # (0.2x has no B5, so this is covered by the refusal above)
+        # MISLABEL: a 0.2y-like run (fresh ids, no frozen digest) labelled 0.2x or 0.2 gets the strict rule, not the weak one
+        for lab in ("0.2x", "0.2"):
+            assert bad(load(lab, arms(fresh, A={"text": False}, B3={"query": False}))) == [(fresh[0], "A"), (fresh[1], "B3")], lab
+            assert bad(load(lab, arms(fresh, A={"text": False}, B3={"query": False}), digest="0.2x" if lab == "0.2x" else "0.2")) == \
+                [(fresh[0], "A"), (fresh[1], "B3")], lab  # even carrying a real frozen digest: ids are not in that corpus
+        # a 0.2y run carrying the 0.2x digest but labelled 0.2x, with 0.2x-id receipts of another label, is refused
+        d = load("0.2", [r1_receipt("A", hx[0], text=False)], digest="0.2x")
+        assert any("contradicts the frozen task-set digest" in x["problems"][0] for x in d["r1_invalid"])
+        # no-manifest and no-campaign runs of non-historical tasks are refused, A-only included
+        assert any(x["task"] == "*" for x in load(None, [r1_receipt("A", fresh[0])], manifest=False)["r1_invalid"])
+        assert any(x["task"] == "*" for x in load(None, [r1_receipt("A", fresh[0])], campaign=False)["r1_invalid"])
+        # fail closed on identity
+        for label, d in (("campaign block without corpus", load(None, arms(fresh))),
+                         ("disagreeing identity", load("0.2y", arms(fresh), di_corpus="0.2x")),
+                         ("arm outside the 0.2y list", load("0.2y", arms(fresh) + [r1_receipt("B1", "t-B1")]))):
+            assert any(x["task"] == "*" or x["condition"] == "B1" for x in d["r1_invalid"]), label
+        assert load("0.2y", arms(fresh), di_corpus="0.2y")["r1_invalid"] == []
+        # (h) one invalid 0.2y receipt refuses the whole run, in build and in the campaign path (non-zero exit)
+        badrun = write_r1_run(td / "bad", "0.2y", arms(fresh, B3={"query": False}))
+        for call in (lambda: analyze.build(badrun, tdir, [], ""),
+                     lambda: analyze.build_campaign(badrun, [], tdir),
+                     lambda: analyze.main([str(badrun), "--out", str(td / "o")])):
+            try:
+                call()
+                raise AssertionError("an invalid 0.2y receipt did not stop scoring")
+            except SystemExit as e:
+                assert e.code not in (0, None) and "without valid R1 fields" in str(e.code), e.code
+        assert not (td / "o").exists()
+
+
 def test() -> None:
     with tempfile.TemporaryDirectory() as td:
         td = Path(td)
@@ -322,6 +434,8 @@ def main() -> int:
         return 0
     test()
     test_campaign()
+    test_r1_scope()
+    print("r1 scope tests: PASS")
     test_trust_run_no_vacuous_gates()
     return 0
 
diff --git a/bench/tools/test_runner_offline.py b/bench/tools/test_runner_offline.py
index 35b10b9..985cffa 100644
--- a/bench/tools/test_runner_offline.py
+++ b/bench/tools/test_runner_offline.py
@@ -475,6 +475,7 @@ def main() -> int:
         import analyze
         shutil_copy = Path(td) / "b5bad"
         (shutil_copy / "receipts").mkdir(parents=True)
+        (shutil_copy / "manifest.json").write_text((o5 / "manifest.json").read_text())
         (shutil_copy / "receipts" / "ambiguous-925.B5.json").write_text(json.dumps(stripped))
         (shutil_copy / "receipts" / "ambiguous-926.B5.json").write_text((o5 / "receipts" / "ambiguous-926.B5.json").read_text())
         ld = analyze.load_run(shutil_copy, b5dir)