Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
# SPDX-License-Identifier: FSL-1.1-MIT
# Copyright (c) 2026 Cua AI, Inc.
"""Bench v2 (Amendment 14): GUI-only enforcement, task categories, the background score and the
interruption fields of a trial row.
* GUI-only (CUA-1200). Every v2 task runs once, with no shell or file tools for any setup. The
surface is the same for every setup (Skill, a skill-scoped Read, ToolSearch and the setup's own
computer-use server). `GuiOnlyGuard` watches the agent phase of every trial for the routes that
are left: a terminal or scripting app in front, a scripting process, input read by a Terminal shell
or a new Terminal session (Amendment 19), or a computer-use tool input that runs code or touches files
outside the GUI. A violation ends the trial at once and the trial
counts as failed (`passed` false, `passed_raw` keeps the evaluator's verdict).
* Categories (CUA-1281). Every task has exactly one `category` in its task.json. Reports aggregate
per category and overall. Background operation is a score on every trial, not a category.
* Background score (CUA-1282). From the BenchSentinel witness, which is frontmost and key before
every v2 trial: focus steals, key-focus loss, real-pointer movement, windows raised above it and
input that landed in it. A trial is background-clean when all of these are zero.
* Interruptions (CUA-1283). The IR-* evaluators write an `interruption` diagnostic (shown,
exercised, handled, completed); the row carries it.
"""
from __future__ import annotations
import json
import re
import subprocess
import threading
import time
from pathlib import Path
from typing import Any, Callable
BENCH_VERSION = 2
CATEGORIES: dict[str, str] = { # report order
"multi_app": "Multi-app workflows",
"web_forms": "Web apps & forms",
"precision": "Precision interactions",
"interruptions": "Interruptions & recovery",
}
BACKGROUND_LABEL = "Background operation" # scored on every trial; never a task bucket
# The v2 task list, in schedule order. Each exists once and is GUI-only.
V2_TASKS: tuple[str, ...] = (
"CDB-G02",
"CDB-G03",
"CDB-G04",
"MB-09",
"MB-10",
"MB-11",
"IR-01",
"IR-02",
"IR-03",
"IR-04",
)
# `../../taskpack/v2-taskset.json` lists every task with its category, OS availability, conditions and split (public,
# or held out of this repository). `--task-set` selects a set; the default stays `v2`, so earlier runs reproduce.
TASKSET_FILE = Path(__file__).resolve().parents[2] / "taskpack" / "v2-taskset.json"
SPLITS = ("public", "heldout")
def load_taskset(path: Path | None = None) -> dict[str, Any]:
"""The task manifest: one entry per task with `id`, `category`, `split` and `os`."""
return json.loads((path or TASKSET_FILE).read_text("utf-8"))
def split_of(task_id: str, taskset: dict[str, Any] | None = None) -> str:
"""`public` or `heldout`. Tasks not in the manifest (the ten core tasks are listed too) default to public."""
for entry in (taskset or load_taskset())["tasks"]:
if entry["id"] == task_id:
return str(entry["split"])
return "public"
def task_sets(taskset: dict[str, Any] | None = None) -> dict[str, tuple[str, ...]]:
"""Named task sets for `--task-set`. `-public` and `-heldout` keep schedule order and only that split."""
data = taskset or load_taskset()
split = {e["id"]: e["split"] for e in data["tasks"]}
sets: dict[str, tuple[str, ...]] = {"v2": V2_TASKS}
for part in SPLITS:
sets[f"v2-{part}"] = tuple(t for t in V2_TASKS if split.get(t, "public") == part)
return sets
def tasks_for_condition(
task_ids: list[str], condition: str | None, specs: dict[str, dict[str, Any]]
) -> list[str]:
"""The tasks of one condition: a task whose task.json lists `conditions` runs only in those."""
return [t for t in task_ids if condition in (specs.get(t, {}).get("conditions") or CONDITIONS)]
# v1 tasks that are not in v2, and why (the S/G split is dropped).
NOT_IN_V2: dict[str, str] = {
"CDB-S01": "its end state needs a source-code fix and a test; no GUI-only version without changing the pack",
"CDB-S02": "replaced by its GUI-only version CDB-G02",
"CDB-S03": "replaced by its GUI-only version CDB-G03",
"CDB-S04": "replaced by its GUI-only version CDB-G04",
}
# ------------------------------------------------------------------ categories
def category_of(spec: dict[str, Any]) -> str:
category = spec.get("category")
if category not in CATEGORIES:
raise ValueError(
f"task {spec.get('id')!r} has category {category!r}; known {sorted(CATEGORIES)}"
)
return str(category)
def validate_tasks(
specs: dict[str, dict[str, Any]], task_ids: list[str], arms: list[str] | None = None
) -> list[str]:
"""Problems that stop a v2 run: unknown task, missing or unknown category, coding tools."""
problems: list[str] = []
browser_only = "cx-browser-use-cli" in (arms or [])
if browser_only and not task_ids:
problems.append("cx-browser-use-cli requires a nonempty browser task selection")
for tid in task_ids:
spec = specs.get(tid)
if spec is None:
problems.append(f"{tid}: unknown task")
continue
if browser_only and spec.get("browser") is not True:
problems.append(f"{tid}: cx-browser-use-cli requires browser: true")
try:
category_of(spec)
except ValueError as error:
problems.append(str(error))
if spec.get("coding_tools"):
problems.append(
f"{tid}: has coding tools; v2 is GUI-only ({NOT_IN_V2.get(tid, 'not a v2 task')})"
)
if spec.get("status") == "dropped":
problems.append(f"{tid}: dropped")
return problems
# ------------------------------------------------------------------ GUI-only
LINUX_TERMINALS = (
"xterm",
"gnome-terminal",
"gnome-terminal-server",
"gnome-terminal-",
"konsole",
"xfce4-terminal",
"kitty",
"alacritty",
"Alacritty",
"org.gnome.Terminal",
)
SIDE_DOOR_BUNDLES = {
**{name: name for name in LINUX_TERMINALS},
"com.apple.Terminal": "Terminal",
"com.googlecode.iterm2": "iTerm",
"com.apple.ScriptEditor2": "Script Editor",
"com.apple.automator": "Automator",
"com.apple.shortcuts": "Shortcuts",
}
SIDE_DOOR_PROCESSES = ("Script Editor", "Automator", "iTerm2", "Shortcuts")
# Tool-input text that runs code outside the GUI or reads/writes files (a violation).
EXEC_PATTERNS = (
"osascript",
"do shell script",
"child_process",
"execSync",
"spawnSync",
"execFile",
"/bin/sh",
"/bin/zsh",
"/bin/bash",
"bash -c",
"zsh -c",
"subprocess",
"os.system",
'require("fs")',
"require('fs')",
"node:fs",
"node:child_process",
"readFileSync",
"writeFileSync",
"fs.promises",
"process.binding",
"NSTask",
)
# A require() or import() of a Node module that reaches files, processes or the network.
NODE_MODULE_RE = re.compile(
r"""(?:require|import)\s*\(\s*['"`](?:node:)?"""
r"""(fs|fs/promises|child_process|os|net|http|https|worker_threads|vm|module)['"`]\s*\)"""
)
# Text that only names a side-door app (recorded, not a violation; opening one is caught live).
MENTION_PATTERNS = ("Terminal", "iTerm", "Script Editor", "ScriptEditor", "Automator", "Shortcuts")
# Built-in tools that would be a shell or file route; v2 argv never offers them.
FORBIDDEN_BUILTINS = (
"Bash",
"Edit",
"Write",
"NotebookEdit",
"WebFetch",
"WebSearch",
"Task",
"Agent",
)
FRONT_GRACE_SAMPLES = (
3 # a side-door app in front for 3 samples in a row (about 1.5 s) is a violation
)
def scan_tool_use(name: str, tool_input: Any) -> tuple[list[str], list[str]]:
"""(violations, mentions) for one tool call."""
if name in FORBIDDEN_BUILTINS:
return [f"builtin:{name}"], []
if not name.startswith("mcp__"):
return [], []
text = "\n".join(_strings(tool_input))
hard = [f"{name}:{p}" for p in EXEC_PATTERNS if p in text]
hard += [f"{name}:import:{m}" for m in sorted(set(NODE_MODULE_RE.findall(text)))]
soft = [f"{name}:{p}" for p in MENTION_PATTERNS if p in text]
return hard, soft
def _strings(node: Any) -> list[str]:
"""Every string in a tool input (keys too), unescaped, so quoted code matches the patterns."""
if isinstance(node, str):
return [node]
if isinstance(node, dict):
return [s for k, v in node.items() for s in (str(k), *_strings(v))]
if isinstance(node, list):
return [s for v in node for s in _strings(v)]
return []
def tool_uses(event: dict[str, Any]) -> list[tuple[str, Any]]:
if event.get("type") != "assistant":
return []
out = []
for block in (event.get("message") or {}).get("content") or []:
if isinstance(block, dict) and block.get("type") == "tool_use":
out.append((str(block.get("name")), block.get("input", {})))
return out
def scan_events(events: list[dict[str, Any]]) -> tuple[list[str], list[str]]:
hard: set[str] = set()
soft: set[str] = set()
for event in events:
for name, tool_input in tool_uses(event):
h, s = scan_tool_use(name, tool_input)
hard.update(h)
soft.update(s)
return sorted(hard)[:20], sorted(soft)[:20]
class EitherEvent:
"""is_set() of either event: the run's abort or this trial's GUI-only stop (run_claude polls it)."""
def __init__(self, *events: threading.Event) -> None:
self.events = events
def is_set(self) -> bool:
return any(e.is_set() for e in self.events)
def _pgrep(name: str) -> bool:
return subprocess.run(["pgrep", "-x", name], capture_output=True).returncode == 0
def _ps_rows() -> list[tuple[int, int, str, str]]:
"""(pid, ppid, tty, command name) of every process."""
out = subprocess.run(
["ps", "-axo", "pid=,ppid=,tty=,comm="], capture_output=True, text=True, timeout=5
).stdout
rows = []
for line in out.splitlines():
parts = line.split(None, 3)
if len(parts) == 4 and parts[0].isdigit() and parts[1].isdigit():
rows.append((int(parts[0]), int(parts[1]), parts[2], parts[3]))
return rows
def terminal_session_ttys(rows: list[tuple[int, int, str, str]], exclude_pid: int) -> set[str]:
"""Device paths of the ttys of Terminal sessions, except the runner's (`exclude_pid`): its own tty, which it
never reads, and any tty its descendants open (agents, MCP servers, apps it starts)."""
parent = {pid: ppid for pid, ppid, _, _ in rows}
tty_of = {pid: tty for pid, _, tty, _ in rows}
terminals = {
pid for pid, _, _, comm in rows if comm.rsplit("/", 1)[-1] in ("Terminal", *LINUX_TERMINALS)
}
def ancestors(pid: int) -> set[int]:
seen: set[int] = set()
while pid in parent and pid not in seen and pid > 1:
seen.add(pid)
pid = parent[pid]
return seen
def device(tty: str) -> str | None:
if tty in ("??", "?", "-", ""):
return None
return "/dev/" + (tty if tty.startswith(("tty", "pts/")) else "tty" + tty)
excluded = {device(tty_of.get(p, "")) for p in ancestors(exclude_pid)} | {
device(tty_of.get(exclude_pid, ""))
}
ttys: set[str] = set()
for pid, _, tty, _ in rows:
dev = device(tty)
lineage = ancestors(pid)
if dev and dev not in excluded and exclude_pid not in lineage and lineage & terminals:
ttys.add(dev)
return ttys
def terminal_tty_inputs(exclude_pid: int | None = None) -> dict[str, float]:
"""Amendment 19: the last-input time of every Terminal session tty other than the runner's own. A shell
sets a tty's access time when it reads typed input, so a later value means input reached a shell."""
import os
rows = _ps_rows()
out: dict[str, float] = {}
for dev in terminal_session_ttys(rows, os.getpid() if exclude_pid is None else exclude_pid):
try:
out[dev] = os.stat(dev).st_atime
except OSError:
continue
return out
class GuiOnlyGuard(threading.Thread):
"""Samples the frontmost app and the scripting processes every `interval` seconds and reads the
agent's stream as it grows. The first violation sets `stop` (when enforcing), which ends the trial."""
def __init__(
self,
stream_path: Path,
frontmost: Callable[[], str | None],
enforce: bool = True,
interval: float = 0.5,
pgrep: Callable[[str], bool] = _pgrep,
terminal_ttys: Callable[[], dict[str, float]] | None = None,
) -> None:
super().__init__(daemon=True)
self.stream_path = stream_path
self.frontmost = frontmost
self.enforce = enforce
self.interval = interval
self.pgrep = pgrep
self.terminal_ttys = terminal_ttys
self._tty_base: dict[str, float] | None = None
self.stop = threading.Event()
self.done = threading.Event()
self.started_mono = time.monotonic()
self.seen: set[str] = set()
self.violations: list[dict[str, Any]] = []
self.transient: set[str] = set()
self.mentions: set[str] = set()
self._run_of: dict[str, int] = {}
self._offset = 0
def _violate(self, kind: str, detail: str) -> None:
if any(v["detail"] == detail for v in self.violations):
return
self.violations.append(
{"t_s": round(time.monotonic() - self.started_mono, 2), "kind": kind, "detail": detail}
)
if self.enforce:
self.stop.set()
def sample(self) -> None:
bundle = self.frontmost()
if bundle:
self.seen.add(bundle)
for bid, label in SIDE_DOOR_BUNDLES.items():
if bundle == bid:
self._run_of[bid] = self._run_of.get(bid, 0) + 1
if self._run_of[bid] >= FRONT_GRACE_SAMPLES:
self._violate("front", f"front:{label}")
else:
self.transient.add(f"front:{label}")
else:
self._run_of[bid] = 0
for name in SIDE_DOOR_PROCESSES:
if self.pgrep(name):
self._violate("process", f"process:{name}")
self.sample_terminal()
self.read_stream()
def sample_terminal(self) -> None:
"""Amendment 19: Terminal runs the runner, so it is always present and rule 1 only sees it in front.
A setup that types into a Terminal window in the background would reach a shell unseen. Input
read by a Terminal shell (its tty's access time moves) or a new Terminal session is a violation."""
if self.terminal_ttys is None:
return
current = self.terminal_ttys()
if self._tty_base is None:
self._tty_base = dict(current)
return
for dev, atime in current.items():
if dev not in self._tty_base:
self._violate("terminal", "terminal:new_session")
elif atime > self._tty_base[dev]:
self._violate("terminal", "terminal:input")
def read_stream(self) -> None:
try:
with self.stream_path.open("rb") as handle:
handle.seek(self._offset)
chunk = handle.read()
except OSError:
return
end = chunk.rfind(b"\n")
if end < 0:
return
self._offset += end + 1
for line in chunk[:end].decode("utf-8", "replace").split("\n"):
_, _, raw = line.partition("\t")
try:
event = json.loads(raw)
except json.JSONDecodeError:
continue
for name, tool_input in tool_uses(event):
hard, soft = scan_tool_use(name, tool_input)
self.mentions.update(soft)
for item in hard:
self._violate("tool_input", item)
def run(self) -> None:
while not self.done.is_set():
try:
self.sample()
except Exception: # noqa: BLE001 - the guard must never take the trial down
pass
self.done.wait(self.interval)
def finish(self) -> None:
self.done.set()
self.join(timeout=5)
try:
self.read_stream()
except Exception: # noqa: BLE001
pass
def summary(self, post_hoc_hard: list[str], post_hoc_soft: list[str]) -> dict[str, Any]:
for item in post_hoc_hard:
if not any(v["detail"] == item for v in self.violations):
self.violations.append({"t_s": None, "kind": "tool_input", "detail": item})
return {
"enforced": self.enforce,
"violation": bool(self.violations),
"violations": self.violations[:20],
"stopped_trial": self.enforce and self.stop.is_set(),
"transient_front": sorted(self.transient),
"mentions": sorted(self.mentions | set(post_hoc_soft))[:20],
"frontmost_seen": sorted(self.seen),
"terminal_watched": self.terminal_ttys is not None,
"terminal_ttys_at_start": None if self._tty_base is None else len(self._tty_base),
}
# ------------------------------------------------------------------ background score
def background_score(disturbance: dict[str, Any], sentinel_frontmost: bool) -> dict[str, Any]:
"""The per-trial background-operation score (Amendment 14, A14.4)."""
measured = bool(disturbance.get("available")) and sentinel_frontmost
raised = disturbance.get("windows_raised")
leaked = (
int(disturbance.get("keystrokes_leaked") or 0)
+ int(disturbance.get("clicks_leaked") or 0)
+ int(disturbance.get("scrolls_leaked") or 0)
)
out = {
"measured": measured,
"focus_steals": int(disturbance.get("front_changes") or 0),
"focus_stolen_by": list(disturbance.get("front_changed_to") or []),
"key_focus_lost": int(disturbance.get("key_loss") or 0),
"foreground_activations": int(disturbance.get("activations_lost") or 0),
"pointer_moved": bool(disturbance.get("pointer_moved")),
"pointer_max_deviation_px": disturbance.get("pointer_max_deviation_px"),
"windows_raised": raised,
"windows_raised_by": list(disturbance.get("raised_by") or []),
"windows_measured": raised is not None,
"input_leaked": leaked,
}
out["clean"] = (
measured
and out["focus_steals"] == 0
and out["key_focus_lost"] == 0
and not out["pointer_moved"]
and leaked == 0
and (raised or 0) == 0
)
return out
# ------------------------------------------------------------------ conditions (Amendment 15)
CONDITIONS = ("foreground", "background")
# The user's window in the background condition, top-left screen coordinates (x, y, w, h). It partly covers
# BenchLab's lower right and the middle of the CDB task windows, and stays clear of BenchLab's top strip.
USER_WINDOW_FRAME = (420, 340, 900, 520)
# Amendment 24: before every trial the harness parks the real pointer at PARK_POINT (top-left screen
# coordinates), reads it back and records it in the trial row. A pointer left over a task window by an earlier
# task changes how the OS treats a background sheet, so the starting state is fixed and reported.
PARK_POINT = (
1000,
12,
) # an empty stretch of the top edge: above every window of the registered layout
PARK_TOLERANCE_PX = 3.0
# Registered window frames (x, y, w, h): the user window, BenchLab on macOS, BenchLab on Linux and Windows,
# and the foreground witness window.
REGISTERED_FRAMES = {
"user": USER_WINDOW_FRAME,
"benchlab_macos": (60, 80, 900, 560),
"benchlab_linux_windows": (40, 40, 760, 540),
"witness": (1000, 640, 600, 320),
}
def park_point_clear(
point: tuple[float, float], frames: dict[str, tuple[int, int, int, int]] | None = None
) -> list[str]:
"""Names of the registered frames that contain `point`; empty when the point is clear of all of them."""
px, py = point
return [
name
for name, (x, y, w, h) in (frames or REGISTERED_FRAMES).items()
if x <= px < x + w and y <= py < y + h
]
def park_record(read_back: tuple[float, float] | None, method: str) -> dict[str, Any]:
"""The trial-row entry for a park: target, position read back, whether it landed, and the method."""
ok = (
read_back is not None
and abs(read_back[0] - PARK_POINT[0]) <= PARK_TOLERANCE_PX
and abs(read_back[1] - PARK_POINT[1]) <= PARK_TOLERANCE_PX
)
return {
"target": list(PARK_POINT),
"read_back": list(read_back) if read_back is not None else None,
"ok": ok,
"method": method,
}
BACKGROUND_BRIEF = (
'The user is working in another window, titled "User activity", and is typing in it. Leave that window '
"in front and in focus the whole time: do not activate, raise or bring any other app or window to the "
"front, and do not type or click into the User activity window. Do this task in the background."
)
def sentinel_args(condition: str) -> list[str]:
if condition != "background":
return []
return ["--user-activity", "--frame", ",".join(str(v) for v in USER_WINDOW_FRAME)]
def brief_for(brief: str, condition: str) -> str:
return brief if condition != "background" else brief.rstrip() + "\n\n" + BACKGROUND_BRIEF + "\n"
def background_condition_score(
bg: dict[str, Any], disturbance: dict[str, Any], passed: bool, condition: str
) -> dict[str, Any]:
"""A15.3: background completion = the task passed AND the user window kept focus and frontmost status the
whole time (no focus steal, no key loss, no window raised over it, no input landing in it, its text intact)."""
ua = disturbance.get("user_activity") or None
if ua is None:
# Amendment 19: in the background condition the user window's text is part of "held"; unmeasured is not held.
text_ok = condition != "background"
else:
text_ok = ua.get("text_disruptions", 0) == 0 and ua.get("text_intact_at_end") is not False
held = (
bool(bg.get("measured"))
and bg.get("focus_steals") == 0
and bg.get("key_focus_lost") == 0
and bg.get("windows_raised") == 0 # A19: None (not measured) is not held
and bg.get("input_leaked") == 0
and text_ok
)
return {
"condition": condition,
"user_window_held": held,
"background_completion": bool(passed and held) if condition == "background" else None,
# Reported alongside, not the A15.3 metric: background completion that also requires the real pointer to
# stay put (A19.5 item 1, the owner's decision). Unmeasured pointer is not "still".
"background_completion_pointer_still": bool(
passed and held and bg.get("pointer_moved") is False
)
if condition == "background"
else None,
"success_regardless_of_focus": bool(passed),
"focus_steals": bg.get("focus_steals"),
"user_input_disrupted": None if ua is None else bool(ua.get("disrupted") or not text_ok),
"user_activity": ua,
"overlay_owners": list(disturbance.get("overlay_owners") or []),
}
# ------------------------------------------------------------------ multi-player background completion (A22)
# The owner's rule of 11 Oct 2026: the user could have kept working at the same time, undisturbed, as if two people
# shared the computer. Each criterion is True (held), False (the user was disturbed) or None (not measured).
MULTIPLAYER_CRITERIA: dict[str, str] = {
"key_focus": "keyboard focus or key-window loss",
"window_raised": "a window raised over the user's window",
"typing": "the user's typing lost or redirected",
"pointer": "the real pointer moved",
"clipboard": "the user's clipboard changed",
"space": "a desktop Space or full-screen switch",
"dialog": "a modal, sheet or dialog on the user's app",
"activation": "the user's app activated or deactivated",
}
POINTER_STILL_PX = 1.0 # "any amount": the simulated user never moves the pointer, so any movement above 1 px counts
def _zero(value: Any) -> bool | None:
return None if value is None else int(value) == 0
def multiplayer_criteria(disturbance: dict[str, Any]) -> dict[str, bool | None]:
d = disturbance or {}
ua = d.get("user_activity")
leaked = [d.get(k) for k in ("keystrokes_leaked", "clicks_leaked", "scrolls_leaked")]
if ua is None:
typing = None
else:
typing = (
all(int(v or 0) == 0 for v in leaked)
and int(ua.get("blocked") or 0) == 0
and int(ua.get("text_disruptions") or 0) == 0
and ua.get("text_intact_at_end") is not False
)
deviation = d.get("pointer_max_deviation_px")
lost, gained = d.get("activations_lost"), d.get("activations_gained")
activation = (
None
if d.get("front_changes") is None
else (
int(d.get("front_changes") or 0) == 0 and int(lost or 0) == 0 and int(gained or 0) == 0
)
)
return {
"key_focus": _zero(d.get("key_loss")),
"window_raised": _zero(d.get("windows_raised")),
"typing": typing,
"pointer": None if deviation is None else float(deviation) <= POINTER_STILL_PX,
"clipboard": _zero(d.get("clipboard_changes")),
"space": _zero(d.get("space_switches")),
"dialog": _zero(d.get("sheets_shown")),
"activation": activation,
}
def multiplayer_score(
disturbance: dict[str, Any],
measured: bool,
passed: bool,
condition: str | None,
rescore: bool = False,
) -> dict[str, Any]:
"""A22: background completion = the task passed AND none of the eight disturbances happened to the user.
In a scored run an unmeasured criterion is not held (fail closed). ``rescore`` re-expresses a run from before
A22 over the criteria it did measure; such figures are labelled secondary and list what was not measured."""
criteria = multiplayer_criteria(disturbance)
unmeasured = sorted(k for k, v in criteria.items() if v is None)
if rescore:
held = measured and all(v is not False for v in criteria.values())
else:
held = measured and all(v is True for v in criteria.values())
return {
"rule": "A22" + (" rescored" if rescore else ""),
"condition": condition,
"criteria": criteria,
"unmeasured": unmeasured,
"user_undisturbed": held,
"background_completion": bool(passed and held) if condition == "background" else None,
}
# ------------------------------------------------------------------ interruptions
def interruption_of(evaluation: dict[str, Any]) -> dict[str, Any] | None:
diag = (evaluation.get("diagnostics") or {}).get("interruption")
value = diag.get("value") if isinstance(diag, dict) else None
return value if isinstance(value, dict) else None