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#25 (code only)

closed derived f470f6216d09ffd2 #25

Imported from GitHub aien-dev/interplane-mv#25 (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 ffa40140c33bbbf0f5f7bde19e2ace13c5862f92 · Head 3d6720d067f440f1095d714a80e1a8dbfdc49646

greptile-apps[bot] reviewed (COMMENTED) on 2026-10-05 00:23 UTC

aien-dev has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Apply it

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

Changes

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0d1529e..d4624ca 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -116,3 +116,5 @@ jobs:
           ODYSSEUS_SRC=$GITHUB_WORKSPACE/../odysseus PYTHONPATH=$GITHUB_WORKSPACE/python:. PYTHONDONTWRITEBYTECODE=1 \
             python -m pytest tests -q -p no:cacheprovider -rs | tee pytest.log
           ! grep -q "skipped" pytest.log
+      - name: bench runner offline test (scripted endpoint, sim-1 backends, runtime-v1 with denial/approval negative controls)
+        run: ODYSSEUS_SRC=$GITHUB_WORKSPACE/../odysseus PYTHONDONTWRITEBYTECODE=1 python bench/tools/test_runner_offline.py
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0b69f22..ce3a8ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
 - Benchmark corpus (44 tasks), protocol, paired runner and analyzer; run `qual-20261004T2207Z`.
 - Bench simulated backends `sim-1` (`bench/stubs/backends.json`, `run_bench.py --backends sim-1`): every tool a task lists executes deterministically after Odysseus authorizes it; `validate.py` checks coverage, determinism and that stores do not leak expansion answers. Default stays the 0.2 reference behaviour; `inputs_digest` updated.
 - Pre-registered 0.2x protocol (`bench/PROTOCOL-0.2x.md`, future work, no results): 120-task held-out set (`bench/heldout-0.2x/`), the 0.2 tasks become dev cases, seven conditions (four one-factor arms with matched full-catalog baselines), runtime-triggered expansion rules and caps, thresholds and a power table (`stats.py --power`); `validate.py --corpus 0.2x` in CI.
+- Runtime-triggered expansion `run_bench.py --expansion-policy runtime-v1` (PROTOCOL-0.2x arm 3): host-side T1/T2/T3 over the existing `discover`/`expand`, N1/N2 negative rules, duplicate and schema-budget caps, `runtime_triggers` receipts; offline tests include denial and approval negative controls. Default `0.2` unchanged.
 - AIEN adapter on the real `EffectAuthority` path (sovereign-core #203, #204, pinned 6554aac), single-use approval tests.
 
 - `selection.measure`: `rendered_bytes` and an optional unit-disciplined `tokens` block (`bytes`, `tokens_model_reported`, `tokens_endpoint_tokenizer`, `tokens_estimated`); `TokenCounter` with `BytesOnly` and `EstimatedTokens` (estimator v1) in both languages.
diff --git a/bench/README.md b/bench/README.md
index 7bdb6ce..95cbefb 100644
--- a/bench/README.md
+++ b/bench/README.md
@@ -157,12 +157,22 @@ exist.
   before the first request; `--resume` skips completed pairs. Condition B also exposes one
   read-only discovery tool, `interplane_capabilities_search{query}`, that grants nothing and
   executes nothing in the runtime.
+- `--expansion-policy runtime-v1` replaces the 0.2 condition-B expansion with the host-side
+  triggers of `PROTOCOL-0.2x.md` section 5 (arm 3). An unknown tool name runs a catalog search
+  (`discover` per name token, then `expand` with `discovery_hit`). An unexposed tool is added with
+  `requested_excluded`. A typed missing-capability error widens its domain. Denied and pending
+  calls never trigger (N1, N2), each (trigger, name) pair is tried once, and an expansion over 30 %
+  of the full-catalog schema bytes is not applied. Every decision goes to the receipt's
+  `runtime_triggers`, and every attempted expansion goes to `expansions`, with the previous and new
+  selection digests, the added and refused names, and the budget left. The default `0.2` keeps the
+  0.2 behaviour and identity digest unchanged.
 - `tools/bench_eval.py` is the deterministic judge and the per-run metrics, shared by the runner
   and the analyzer. `tools/analyze.py <run-dir>` (stdlib only, no inference) writes
   `summary.json`, `summary.md` and `tasks.csv`, byte-identically for the same input.
 - Offline tests: `tools/test_analyze.py` (stdlib, runs in CI against a checked-in synthetic run)
   and `tools/test_runner_offline.py` (a scripted fake endpoint; needs the Odysseus venv; also runs
-  every `sim-1` backend kind twice and checks the results are identical).
+  every `sim-1` backend kind twice and checks the results are identical, and runs `runtime-v1`
+  with the denial and approval negative controls).
 - Corpus digests: adding `stubs/backends.json` and `stubs/stores/` changed `inputs_digest` in
   `CORPUS-DIGEST.txt`. `tasks_digest` and `protocol_sha256` are unchanged. The 0.2 runs carry the
   digests they ran against in their own `manifest.json`, which is unchanged.
diff --git a/bench/tools/run_bench.py b/bench/tools/run_bench.py
index 54c333d..2935535 100644
--- a/bench/tools/run_bench.py
+++ b/bench/tools/run_bench.py
@@ -259,6 +259,117 @@ def raw_ok(raw: dict) -> bool:
 
 # ------------------------------------------------------------------------------- one run
 
+# ---------------------------------------------------------------- runtime-triggered expansion
+# PROTOCOL-0.2x.md section 5 (arm 3). Host-side, visibility only: it runs after Odysseus has decided
+# a call and only ever calls interplane.crossaxis.discover / expand. It never decides, executes,
+# retries or re-issues a call, and never touches approvals.
+
+RUNTIME_POLICY = "runtime-v1"
+EXPANSION_POLICIES = ("0.2", RUNTIME_POLICY)
+SCHEMA_BUDGET_RATIO = 0.30
+DISCOVER_LIMIT = 8
+MISSING_CODES = ("capability_not_found", "stale_capability")
+SUPPRESSED = {"denied": "N1_policy_denied", "requires_approval": "N2_approval_required"}
+CAP_REASONS = ("max_expansions", "max_added_per_expansion", "schema_budget")
+EXHAUSTED_NOTE = ("No further tools can be made available in this conversation. Answer with the tools "
+                  "you have, or tell the user what is missing.")
+
+
+def name_tokens(name: str) -> list:
+    """Search tokens of a requested tool name: split on _ . -, lowercase, length >= 3, first-seen order."""
+    out: list = []
+    for tok in re.split(r"[_.\-]+", name.lower()):
+        if len(tok) >= 3 and tok not in out:
+            out.append(tok)
+    return out
+
+
+class RuntimeExpansion:
+    """Triggers T1 (unknown tool -> catalog search), T2 (unexposed tool -> requested_excluded) and
+    T3 (typed missing capability -> widen the domain), with negative rules N1/N2 (denied and
+    pending calls never trigger), one attempt per (trigger, name), and a schema-byte budget."""
+
+    def __init__(self, catalog, by_name: dict, full_bytes: int, render_bytes):
+        self.catalog, self.by_name = catalog, by_name
+        self.limit = int(full_bytes * SCHEMA_BUDGET_RATIO)
+        self.render_bytes = render_bytes
+        self.seen: set = set()
+        self.log: list = []
+
+    def classify(self, rec: dict, exposed: set):
+        code, cap, tool = rec["error_code"], rec["capability"], rec["tool"]
+        if code == "unknown_capability" or (code == "capability_not_found" and (cap or tool) not in self.by_name):
+            return "T1", tool
+        if code in MISSING_CODES and cap in self.by_name:
+            return "T3", cap
+        if cap is not None and cap in self.by_name and cap not in exposed:
+            return "T2", cap
+        return None, None
+
+    def on_call(self, rec: dict, round_no: int, index: int, selection):
+        """Returns (selection, expansion_event or None, append_exhausted_note)."""
+        names = [e["name"] for e in selection.selected]
+        trig, name = self.classify(rec, set(names))
+        if trig is None:
+            return selection, None, False
+        entry = {"round": round_no, "call_index": index, "trigger": trig, "name": name,
+                 "signal": {"error_code": rec["error_code"], "exposed": rec["exposed"], "status": rec["status"]}}
+        self.log.append(entry)
+        if rec["status"] in SUPPRESSED:
+            entry["outcome"] = SUPPRESSED[rec["status"]]
+            return selection, None, False
+        if (trig, name) in self.seen:
+            entry["outcome"] = "duplicate_trigger"
+            return selection, None, False
+        self.seen.add((trig, name))
+        if trig == "T1":
+            hits: set = set()
+            for tok in name_tokens(name or ""):
+                hits.update(discover(self.catalog, selection, tok, limit=DISCOVER_LIMIT))
+            hits_l = sorted(hits)[:DISCOVER_LIMIT]
+            entry["query_tokens"] = name_tokens(name or "")
+            if not hits_l:
+                entry["outcome"] = "no_hits"
+                return selection, None, False
+            evidence = {"kind": "discovery_hit", "query": name, "names": hits_l}
+        elif trig == "T2":
+            evidence = {"kind": "requested_excluded", "name": name}
+        else:
+            evidence = {"kind": "requested_excluded", "name": name, "include_domain_siblings": True}
+        prev_digest = selection_digest(selection)
+        event = {"round": round_no, "call_index": index, "policy": RUNTIME_POLICY, "trigger": trig, "name": name,
+                 "signal": entry["signal"], "reason": evidence["kind"],
+                 "previous_selection_digest": prev_digest, "previous_exposed": names}
+        try:
+            new = expand(selection, self.catalog, evidence)
+        except ExpansionError as err:
+            entry["outcome"] = "error"
+            event.update({"error": str(err), "added": [], "refused": [], "selection_digest": prev_digest})
+            return selection, event, False
+        exp = new.extra["expansions"][-1]
+        added, refused = list(exp["added"]), list(exp["refused"])
+        bytes_after = self.render_bytes([e["name"] for e in new.selected])
+        if added and bytes_after > self.limit:
+            refused = [{"name": n, "reason": "schema_budget"} for n in added] + refused
+            added, new = [], selection
+            bytes_after = self.render_bytes(names)
+        bounds = new.selector.get("expansion") or {}
+        used = sum(1 for e in (new.extra.get("expansions") or []) if e.get("added"))
+        max_exp = bounds.get("max_expansions", 2)
+        event.update({
+            "evidence_digest": exp["evidence_digest"], "expansion_round": exp["round"],
+            "selection_digest": selection_digest(new), "added": added, "refused": refused,
+            "budget": {"expansions_left": max(max_exp - used, 0), "schema_bytes_limit": self.limit,
+                       "schema_bytes_after": bytes_after, "schema_bytes_left": self.limit - bytes_after},
+        })
+        if trig == "T1":
+            event["hits"] = hits_l
+        note = not added and any(r["reason"] in CAP_REASONS for r in refused)
+        event["exhausted_note"] = note
+        entry["outcome"] = "expanded" if added else "refused"
+        return new, event, note
+
+
 def render(by_name: dict, names: list, cond: str) -> list:
     tools = openai_tools_renderer([by_name[n] for n in names])
     return tools + [DISCOVERY_SPEC] if cond == "B" else tools
@@ -314,6 +425,11 @@ def _run(cx: dict, task: dict, cond: str, run_id: str, ws: str) -> dict:
     def current_names() -> list:
         return all_names if selection is None else [e["name"] for e in selection.selected]
 
+    rt = None
+    if cond == "B" and cx.get("expansion_policy") == RUNTIME_POLICY:
+        rt = RuntimeExpansion(catalog, by_name, cx["full_tools_bytes"],
+                              lambda names: len(jcs(render(by_name, names, "B")).encode("utf-8")))
+
     rounds, calls, expansion_events, coverage_trace, round_tools = [], [], [], [], []
     final_answer, ended, infra_error = None, "max_rounds", None
     n_eff = 0
@@ -395,7 +511,16 @@ def _run(cx: dict, task: dict, cond: str, run_id: str, ws: str) -> dict:
                 tool_msgs[i] = out.rendered[j]
         # ---- expansion and discovery, in call order (visibility only; authority was already decided)
         for i in range(len(orig)):
-            if i in recs:
+            if i in recs and rt is not None:
+                selection, ev, note = rt.on_call(recs[i], turn + 1, i, selection)
+                if ev is not None:
+                    expansion_events.append(ev)
+                    n_eff += 1 if ev["added"] else 0
+                if note and tool_msgs[i] is not None:
+                    tm = dict(tool_msgs[i])
+                    tm["content"] = (tm.get("content") or "") + "\n\n" + EXHAUSTED_NOTE
+                    tool_msgs[i] = tm
+            elif i in recs:
                 cap = recs[i]["capability"]
                 if cond == "B" and cap is not None and cap in by_name and cap not in set(current_names()):
                     try:
@@ -459,6 +584,7 @@ def _run(cx: dict, task: dict, cond: str, run_id: str, ws: str) -> dict:
         "final_exposed_names": list(final_names), "coverage_trace": coverage_trace, "wall_ms": wall_ms,
         "selection": selection, "base_messages": base_messages, "_round_tools": round_tools,
         "trace_id": trace_id, "workspace_events": dict(authority.bench_events),
+        "runtime_triggers": rt.log if rt is not None else None,
     }
 
 
@@ -526,6 +652,7 @@ def make_receipt(cx: dict, task: dict, cond: str, run: dict, attempt: int, prior
         "discovery_tool": DISCOVERY if cond == "B" else None,
         "selection": selection_block,
         "rounds": run["rounds"], "calls": run["calls"], "expansions": run["expansions"],
+        **({"runtime_triggers": run["runtime_triggers"]} if run.get("runtime_triggers") is not None else {}),
         "final_exposed_names": run["final_exposed_names"] if cond == "B" else None,
         "coverage_trace": run["coverage_trace"],
         "ended": run["ended"], "infra_error": run["infra_error"],
@@ -649,6 +776,10 @@ def build_identity(cx: dict, tasks: list) -> dict:
     }
     if cx["backends"] != "reference":  # the 0.2 reference identity stays byte-identical
         ident["backends"] = backends_identity(cx)
+    if cx["expansion_policy"] != "0.2":
+        ident["expansion_policy"] = {"name": cx["expansion_policy"], "schema_budget_ratio": SCHEMA_BUDGET_RATIO,
+                                     "full_tools_bytes": cx["full_tools_bytes"], "discover_limit": DISCOVER_LIMIT,
+                                     "triggers": ["T1", "T2", "T3"], "suppressed": sorted(SUPPRESSED.values())}
     ident["identity_digest"] = digest_of(ident)
     return ident
 
@@ -670,6 +801,8 @@ def make_cx(args, tasks_dir: Path) -> dict:
         "system_prompt": sp, "client": client, "counter": LiveCounter(client), "max_rounds": args.max_rounds,
         "fixture_digests": {f: tree_digest(BENCH / f) for f in fixtures},
         "backends": args.backends,
+        "expansion_policy": args.expansion_policy,
+        "full_tools_bytes": len(jcs(openai_tools_renderer(catalog.capabilities)).encode("utf-8")),
         "backend_registry": sim_backends.load_backends() if args.backends == "sim-1" else None,
         "generation": {"temperature": args.temperature, "seed": args.seed, "max_tokens": args.max_tokens,
                        "timeout_s": args.timeout, "max_rounds": args.max_rounds, "dialect": "openai"},
@@ -725,6 +858,9 @@ def main(argv=None) -> int:
     ap.add_argument("--backends", choices=["reference", "sim-1"], default="reference",
                     help="reference = 0.2 behaviour (only read_file/ls/glob/grep and task stubs execute); "
                          "sim-1 = bench/stubs/backends.json simulated backends")
+    ap.add_argument("--expansion-policy", choices=list(EXPANSION_POLICIES), default="0.2",
+                    help="0.2 = the 0.2 condition-B expansion (unexposed call -> requested_excluded); "
+                         "runtime-v1 = PROTOCOL-0.2x.md section 5 triggers T1-T3 with N1/N2 and caps (arm 3)")
     args = ap.parse_args(argv)
 
     out = Path(args.out)
@@ -778,6 +914,7 @@ def main(argv=None) -> int:
         "catalog": {"digest": identity["catalog_digest"], "capabilities": identity["catalog_capabilities"]},
         "corpus": corpus, "system_prompt_digest": identity["system_prompt_digest"], "generation": cx["generation"],
         "backends": identity.get("backends", {"mode": "reference"}),
+        "expansion_policy": identity.get("expansion_policy", {"name": "0.2"}),
         "order_rule": "tasks in id order; A first for even 0-based index, B first for odd (PROTOCOL-0.2.md section 2)",
         "deterministic_identity": identity,
     }
diff --git a/bench/tools/test_runner_offline.py b/bench/tools/test_runner_offline.py
index 261aa0e..16f9760 100644
--- a/bench/tools/test_runner_offline.py
+++ b/bench/tools/test_runner_offline.py
@@ -4,7 +4,9 @@ No GPU, no model, no qual task: synthetic tasks (derived from dev tasks) exercis
 path (Lenshift -> Core -> CrossAxis -> Crossveil with the real OdysseusAuthority): an excluded
 tool call that triggers expansion, a discovery call, an injected fault with retry, and an unknown
 tool name, and (``--backends sim-1``) every simulated backend kind, twice, with identical results.
-Needs the Odysseus venv and ODYSSEUS_SRC (not run in the stdlib-only CI job):
+``--expansion-policy runtime-v1`` (PROTOCOL-0.2x.md section 5): triggers T1 and T2, the duplicate
+rule, the cap-exhausted note, and the negative controls N1 (denied) and N2 (approval pending).
+Needs the Odysseus venv and ODYSSEUS_SRC (CI job adapter-odysseus runs it):
 
   ODYSSEUS_SRC=<odysseus@2992bf6> <venv>/bin/python bench/tools/test_runner_offline.py
 """
@@ -62,6 +64,31 @@ def script(messages, tools):
             tool = user.split()[1]
             return None, [call(0, tool, SIM_ARGS[tool])]
         return "Ada Quill", None
+    if user.startswith("RT-T2"):  # an unexposed catalog tool, once
+        if n_tool == 0:
+            return None, [call(0, "read_file", {"path": "README.md"})]
+        return "lanternfish", None
+    if user.startswith("RT-T1"):  # an unknown name twice: the second is a duplicate trigger
+        if n_tool < 2:
+            return None, [call(n_tool, "workspace_summary", {})]
+        return "workspace_summary is not available", None
+    if user.startswith("RT-CAP"):  # three unexposed tools: the third exceeds max_expansions
+        # tools with no backend fail with execution_error (N5): an unexposed call still fires T2
+        seq = ["list_serve_presets", "list_cookbook_servers", "list_downloads"]
+        if n_tool < 3:
+            return None, [call(n_tool, seq[n_tool], {})]
+        Handler.tool_contents.append([m.get("content") for m in messages if m["role"] == "tool"])
+        return "done", None
+    if user.startswith("RT-N1"):  # non-admin calls an unexposed admin tool: denied, never expanded
+        if n_tool == 0:
+            return None, [call(0, "manage_tokens", {"action": "list"})]
+        return "denied", None
+    if user.startswith("RT-N2"):  # a workspace read arms the gate; the unexposed send is held for approval
+        if n_tool == 0:
+            return None, [call(0, "read_file", {"path": "README.md"})]
+        if n_tool == 1:
+            return None, [call(1, "send_email", {"to": "a@example.org", "subject": "s", "body": "b"})]
+        return "needs approval", None
     if user.startswith("UNKNOWN"):
         if n_tool == 0:
             return None, [call(0, "summarize_repo", {})]
@@ -71,6 +98,7 @@ def script(messages, tools):
 
 class Handler(BaseHTTPRequestHandler):
     log = []
+    tool_contents = []
 
     def log_message(self, *a):
         pass
@@ -195,6 +223,76 @@ def main() -> int:
                         "--out", str(rout), "--tasks-dir", str(sdir), "--allow-nonfrozen", "--no-warmup", "--only", sim_ids["ask_user"]])
         c = json.loads((rout / "receipts" / f"{sim_ids['ask_user']}.A.json").read_text())["calls"][0]
         assert c["synthetic"] is None and c["error_code"] == "execution_error", c
+        # runtime-v1 expansion policy (arm 3), condition B only, sim-1 backends
+        rdir = Path(td) / "rttasks"
+        rdir.mkdir()
+        rt_tasks = {
+            "RT-T2": task_from("ambiguous-920", "ambiguous-004", "RT-T2 calendar question", split="dev", requested_domains=["calendar"]),
+            "RT-T1": task_from("ambiguous-921", "ambiguous-004", "RT-T1 calendar question", split="dev", requested_domains=["calendar"]),
+            "RT-CAP": task_from("ambiguous-922", "ambiguous-004", "RT-CAP calendar question", split="dev", requested_domains=["calendar"]),
+            "RT-N1": task_from("ambiguous-923", "ambiguous-004", "RT-N1 calendar question", split="dev", requested_domains=["calendar"],
+                               authority_profile={"admin": False, "delegated_credential": False}),
+            "RT-N2": task_from("ambiguous-924", "ambiguous-004", "RT-N2 file question", split="dev", requested_domains=["filesystem"]),
+        }
+        for t in rt_tasks.values():
+            (rdir / f"{t['id']}.json").write_text(json.dumps(t))
+        rtout = Path(td) / "rtrun"
+        rc = run_bench.main(["--tasks", "dev", "--condition", "B", "--endpoint", f"http://127.0.0.1:{srv.server_port}/v1",
+                             "--out", str(rtout), "--tasks-dir", str(rdir), "--allow-nonfrozen", "--no-warmup",
+                             "--backends", "sim-1", "--expansion-policy", "runtime-v1"])
+        assert rc == 0
+        m = json.loads((rtout / "manifest.json").read_text())
+        assert m["expansion_policy"]["name"] == "runtime-v1", m["expansion_policy"]
+        RT = lambda k: json.loads((rtout / "receipts" / f"{rt_tasks[k]['id']}.B.json").read_text())
+        r = RT("RT-T2")
+        (ev,) = r["expansions"]
+        assert ev["trigger"] == "T2" and ev["added"] == ["read_file"] and ev["reason"] == "requested_excluded", ev
+        assert ev["previous_selection_digest"] != ev["selection_digest"] and "read_file" not in ev["previous_exposed"]
+        assert ev["budget"]["expansions_left"] == 1 and ev["budget"]["schema_bytes_left"] > 0, ev["budget"]
+        # N4: the triggering call went through the pipeline once and is never re-issued
+        assert [c["tool"] for c in r["calls"]] == ["read_file"] and r["calls"][0]["executed"] is True
+        r = RT("RT-T1")
+        assert [t["outcome"] for t in r["runtime_triggers"]] == ["expanded", "duplicate_trigger"], r["runtime_triggers"]
+        (ev,) = r["expansions"]
+        assert ev["trigger"] == "T1" and ev["reason"] == "discovery_hit" and ev["added"] and ev["hits"], ev
+        assert all(c["executed"] is False and c["error_code"] == "unknown_capability" for c in r["calls"])
+        r = RT("RT-CAP")
+        assert [e["trigger"] for e in r["expansions"]] == ["T2", "T2", "T2"], (r["runtime_triggers"], [(c["tool"], c["status"], c["error_code"], c["exposed"]) for c in r["calls"]])
+        last = r["expansions"][-1]
+        assert last["added"] == [] and {x["reason"] for x in last["refused"]} == {"max_expansions"} and last["exhausted_note"]
+        assert any(run_bench.EXHAUSTED_NOTE in (c or "") for c in Handler.tool_contents[-1]), Handler.tool_contents[-1]
+        assert r["metrics"]["effective_expansions"] == 2
+        # N1: the denied call stays denied: no expansion, no execution
+        r = RT("RT-N1")
+        assert r["calls"][0]["status"] == "denied" and r["calls"][0]["executed"] is False
+        assert r["expansions"] == [] and [t["outcome"] for t in r["runtime_triggers"]] == ["N1_policy_denied"]
+        assert "manage_tokens" not in r["final_exposed_names"]
+        # N2: the pending call stays pending: no expansion, no execution, no approval consumed
+        r = RT("RT-N2")
+        assert r["calls"][1]["tool"] == "send_email" and r["calls"][1]["status"] == "requires_approval", r["calls"]
+        assert r["calls"][1]["executed"] is False
+        assert r["expansions"] == [] and [t["outcome"] for t in r["runtime_triggers"]] == ["N2_approval_required"]
+        assert "send_email" not in r["final_exposed_names"]
+        # T3 and the schema budget, directly on the policy (no live call yields these codes today)
+        cat = run_bench.catalog_with_domains()
+        byn = {c.name: c for c in cat.capabilities}
+        rbytes = lambda names: len(run_bench.jcs(run_bench.render(byn, names, "B")).encode("utf-8"))
+        sel0 = run_bench.select(cat, ["calendar"], always_include=run_bench.ALWAYS_INCLUDE,
+                                renderer=run_bench.openai_tools_renderer)[0]
+        miss = {"error_code": "capability_not_found", "capability": "read_file", "tool": "read_file",
+                "status": "not_found", "exposed": False}
+        pol = run_bench.RuntimeExpansion(cat, byn, len(run_bench.jcs(run_bench.openai_tools_renderer(cat.capabilities)).encode("utf-8")), rbytes)
+        sel1, ev, note = pol.on_call(miss, 1, 0, sel0)
+        assert ev["trigger"] == "T3" and "read_file" in ev["added"] and len(ev["added"]) > 1 and not note, ev
+        assert ev["budget"]["schema_bytes_after"] <= ev["budget"]["schema_bytes_limit"]
+        tiny = run_bench.RuntimeExpansion(cat, byn, rbytes([e["name"] for e in sel0.selected]), rbytes)
+        sel2, ev, note = tiny.on_call(miss, 1, 0, sel0)
+        assert sel2 is sel0 and ev["added"] == [] and note, ev
+        assert [x["name"] for x in ev["refused"] if x["reason"] == "schema_budget"][:1] == ["read_file"], ev["refused"]
+        # judge reproduces from the stored transcript under runtime-v1 too
+        for t in rt_tasks.values():
+            rr = json.loads((rtout / "receipts" / f"{t['id']}.B.json").read_text())
+            assert bench_eval.judge(t, "B", rr["transcript"]) == rr["judge"]
         # resume: nothing is rerun
         before = len(Handler.log)
         run_bench.main(["--tasks", "dev", "--condition", "both", "--endpoint", f"http://127.0.0.1:{srv.server_port}/v1",