{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "lab-08-00",
   "metadata": {},
   "source": [
    "# 08 · Bound a model-led workflow\n",
    "\n",
    "When does allowing the model to choose a tool or request clarification improve the outcome?\n",
    "\n",
    "Compare a fixed decision graph with one model-led loop that selects a read-only tool, asks for clarification or stops. Set turn and token limits. Inject a harmless timeout and compare recovery from saved state. Evaluate memory freshness across follow-ups.\n",
    "\n",
    "**Measures** — Goal completion, unsupported decisions, calls per case, recoveries and stale-memory errors.\n",
    "\n",
    "**Evidence** — Replayable trace with a timeout and an auditable stop reason.\n",
    "\n",
    "**Runtime** — T4 model, CPU tools and replay. The course bench uses invented facilities, equipment and records."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-01",
   "metadata": {},
   "source": [
    "## Reproduce the environment\n",
    "\n",
    "Install the pinned dependencies and check the hardware receipt before interpreting timings. Runs record their device and software package versions in `evidence/runtime.json`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "lab-08-02",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:37.837991Z",
     "iopub.status.busy": "2026-11-27T07:22:37.837523Z",
     "iopub.status.idle": "2026-11-27T07:22:37.863742Z",
     "shell.execute_reply": "2026-11-27T07:22:37.863164Z"
    }
   },
   "outputs": [],
   "source": [
    "PINS = {'transformers': '4.51.3', 'accelerate': '1.6.0', 'sentence-transformers': '4.1.0', 'bitsandbytes': '0.49.0', 'pypdf': '5.6.1', 'pymupdf': '1.26.1', 'reportlab': '4.4.2', 'rank-bm25': '0.2.2', 'soundfile': '0.13.1'}\n",
    "\n",
    "import importlib.metadata\n",
    "import os\n",
    "import subprocess\n",
    "import sys\n",
    "\n",
    "if os.environ.get(\"COURSE_SMOKE\") != \"1\":\n",
    "    missing = []\n",
    "    for name, version in PINS.items():\n",
    "        try:\n",
    "            matched = importlib.metadata.version(name) == version\n",
    "        except importlib.metadata.PackageNotFoundError:\n",
    "            matched = False\n",
    "        if not matched:\n",
    "            missing.append(f\"{name}=={version}\")\n",
    "    if missing:\n",
    "        try:\n",
    "            import uv\n",
    "        except ImportError:\n",
    "            subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"--quiet\", \"uv==0.7.13\"], check=True)\n",
    "        subprocess.run([sys.executable, \"-m\", \"uv\", \"pip\", \"install\", \"--quiet\", \"--python\", sys.executable, *missing], check=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-03",
   "metadata": {},
   "source": [
    "## Establish the shared contract\n",
    "\n",
    "Freeze equipment families before deriving ticket variants. Verify an outcome against the decision, exact value and explicit evidence IDs. Keep the release split closed until the capstone. Read-only tools take tenant and role from trusted request metadata."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "lab-08-04",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:37.867532Z",
     "iopub.status.busy": "2026-11-27T07:22:37.867270Z",
     "iopub.status.idle": "2026-11-27T07:22:37.893989Z",
     "shell.execute_reply": "2026-11-27T07:22:37.893451Z"
    }
   },
   "outputs": [],
   "source": [
    "MODEL_IDS = {'text': ('Qwen/Qwen2.5-1.5B-Instruct', '989aa7980e4cf806f80c7fef2b1adb7bc71aa306'), 'vision': ('Qwen/Qwen2-VL-2B-Instruct', '1860c46f12b7449d0f5b426a7474ab715342bc65'), 'speech': ('openai/whisper-base', 'e37978b90ca9030d5170a5c07aadb050351a65bb'), 'embedding': ('sentence-transformers/all-MiniLM-L6-v2', '1110a243fdf4706b3f48f1d95db1a4f5529b4d41'), 'reranker': ('cross-encoder/ms-marco-MiniLM-L6-v2', '233902d25c440f23af6f7d6e94d2946bac0bee0a')}\n",
    "SPLIT_MANIFEST = {'train': {'sha256': '610cd78bdcc4f92095a511c4c92812eace3bcd25f290604d4641f8338438bc4b', 'n': 180, 'families': 18}, 'dev': {'sha256': '51dbc208b6b20a620237dd76ce0a2db4f10aa75f4f8fc404121e301b8d79a0cf', 'n': 120, 'families': 12}, 'holdout': {'sha256': 'd8c88e29283fe660e86b9bf3b3c67fb810f3cfa75c27e2e7043bccfb42766452', 'n': 300, 'families': 30}}\n",
    "LAB_NUMBER = 8\n",
    "\n",
    "import hashlib\n",
    "import json\n",
    "import os\n",
    "import random\n",
    "import re\n",
    "import sqlite3\n",
    "from functools import lru_cache\n",
    "from pathlib import Path\n",
    "\n",
    "SLICES = (\"manual\", \"numeric\", \"multi_source\", \"ambiguity\", \"boundary\", \"follow_up\")\n",
    "SPLITS = {\"train\": (100, 3), \"dev\": (200, 2), \"holdout\": (300, 5)}\n",
    "TENANTS = (\"north-yard\", \"south-yard\")\n",
    "\n",
    "\n",
    "@lru_cache\n",
    "def _assets(split):\n",
    "    first, count = SPLITS[split]\n",
    "    rows = []\n",
    "    for slice_index, category in enumerate(SLICES):\n",
    "        for offset in range(count):\n",
    "            index = first + slice_index * 10 + offset\n",
    "            prefix = (\"P\", \"F\", \"V\")[index % 3]\n",
    "            result = {\n",
    "                \"family\": f\"F{index}\", \"slice\": category, \"tenant\": TENANTS[index % 2],\n",
    "                \"asset\": f\"{prefix}-{index}\", \"linked\": f\"S-{index + 400}\",\n",
    "                \"team\": (\"mechanical\", \"controls\", \"electrical\")[index % 3],\n",
    "                \"limit\": 67 + (index * 19) % 36,\n",
    "                \"inspection\": f\"2025-{index % 12 + 1:02d}-{index % 27 + 1:02d}\",\n",
    "                \"fault\": (\"seal wear\", \"sensor drift\", \"filter blockage\", \"bearing vibration\")[index % 4],\n",
    "                \"version\": \"r3\",\n",
    "            }\n",
    "            for source in (\"manual\", \"inventory\", \"graph\"):\n",
    "                result[f\"{source}_id\"] = f\"{source}-{result['asset']}-r3\"\n",
    "            rows.append(result)\n",
    "    return tuple(rows)\n",
    "\n",
    "\n",
    "def assets(split=\"dev\"):\n",
    "    return [dict(row) for row in _assets(split)]\n",
    "\n",
    "\n",
    "def manual_text(asset_record):\n",
    "    return (\n",
    "        f\"Equipment manual for {asset_record['asset']} (revision {asset_record['version']}). \"\n",
    "        f\"Maximum operating temperature: {asset_record['limit']} C. \"\n",
    "        f\"Known fault: {asset_record['fault']}. The supporting system is {asset_record['linked']}. \"\n",
    "        f\"Maintenance owner: {asset_record['team']}.\"\n",
    "    )\n",
    "\n",
    "\n",
    "def corpus(split=\"dev\"):\n",
    "    docs = []\n",
    "    for row in assets(split):\n",
    "        passages = {\n",
    "            \"manual\": manual_text(row),\n",
    "            \"inventory\": f\"Inventory for {row['asset']}. Last inspection: {row['inspection']}.\",\n",
    "            \"graph\": f\"{row['asset']} is served by supporting system {row['linked']} and owned by {row['team']}.\",\n",
    "        }\n",
    "        docs.extend({\n",
    "            \"id\": row[f\"{source}_id\"], \"source\": source, \"text\": passage,\n",
    "            \"tenant\": row[\"tenant\"], \"family\": row[\"family\"],\n",
    "        } for source, passage in passages.items())\n",
    "    return docs\n",
    "\n",
    "\n",
    "def _case(row, variant):\n",
    "    asset = row[\"asset\"]\n",
    "    wrappers = (\n",
    "        \"{}\", \"Please help. {}\", \"Ticket intake: {}\", \"Shift note. {}\", \"Quick question: {}\",\n",
    "        \"Could you check this? {}\", \"{} Thanks.\", \"Facilities desk: {}\", \"I need a record check. {}\", \"Operator message: {}\",\n",
    "    )\n",
    "    category = row[\"slice\"]\n",
    "    wording = {\n",
    "        \"manual\": (f\"What is the maximum temperature for {asset}?\", f\"What's the thermal limit, in C, of {asset}?\"),\n",
    "        \"numeric\": (f\"When was {asset} last inspected?\", f\"Give the last inspection date for {asset}.\"),\n",
    "        \"multi_source\": (f\"Give the last inspection date and supporting system for {asset}.\",\n",
    "                         f\"For {asset}, which system supports it and when was its most recent inspection?\"),\n",
    "        \"ambiguity\": (\"What is the maximum temperature for that unit?\", \"When was that pump last inspected?\"),\n",
    "        \"boundary\": (f\"As a guest, show the inventory record for {asset}.\", f\"Guest request: give inspection date for {asset}.\"),\n",
    "        \"follow_up\": (\"What is its maximum temperature?\", \"And how hot can this one run?\"),\n",
    "    }\n",
    "    question = wrappers[variant].format(wording[category][variant % 2])\n",
    "    role = \"guest\" if category == \"boundary\" else \"operator\"\n",
    "    value, evidence, source = {\n",
    "        \"manual\": (str(row[\"limit\"]), [row[\"manual_id\"]], \"manual\"),\n",
    "        \"numeric\": (row[\"inspection\"], [row[\"inventory_id\"]], \"inventory\"),\n",
    "        \"multi_source\": (f\"{row['inspection']} | {row['linked']}\", [row[\"inventory_id\"], row[\"graph_id\"]], \"graph\"),\n",
    "        \"follow_up\": (str(row[\"limit\"]), [row[\"manual_id\"]], \"manual\"),\n",
    "        \"ambiguity\": (\"\", [], \"none\"),\n",
    "        \"boundary\": (\"\", [], \"none\"),\n",
    "    }[category]\n",
    "    decision = {\"ambiguity\": \"clarify\", \"boundary\": \"deny\"}.get(category, \"answer\")\n",
    "    return {\n",
    "        **row, \"id\": f\"{row['family']}-{variant:02d}\", \"question\": question, \"role\": role,\n",
    "        \"decision\": decision, \"value\": value, \"evidence\": evidence, \"source\": source,\n",
    "        \"variant\": variant, \"previous_asset\": asset if category == \"follow_up\" else \"\",\n",
    "        \"previous_version\": row[\"version\"] if category == \"follow_up\" else \"\",\n",
    "    }\n",
    "\n",
    "\n",
    "def cases(split=\"dev\"):\n",
    "    return [_case(row, variant) for row in assets(split) for variant in range(10)]\n",
    "\n",
    "\n",
    "def digest(rows):\n",
    "    serial = json.dumps(rows, ensure_ascii=False, sort_keys=True, separators=(\",\", \":\")).encode()\n",
    "    return hashlib.sha256(serial).hexdigest()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-05",
   "metadata": {},
   "source": [
    "### Preserve source authority\n",
    "\n",
    "Generate original documents and an inventory view. Parameterize the database query, set it read-only, and select only evidence that belongs to the trusted tenant."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "lab-08-06",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:37.897282Z",
     "iopub.status.busy": "2026-11-27T07:22:37.897017Z",
     "iopub.status.idle": "2026-11-27T07:22:37.908349Z",
     "shell.execute_reply": "2026-11-27T07:22:37.907708Z"
    }
   },
   "outputs": [],
   "source": [
    "@lru_cache\n",
    "def _inventory(split):\n",
    "    db = sqlite3.connect(\":memory:\")\n",
    "    db.row_factory = sqlite3.Row\n",
    "    db.execute(\"CREATE TABLE inventory(asset TEXT PRIMARY KEY, tenant TEXT, inspection TEXT, version TEXT)\")\n",
    "    db.executemany(\n",
    "        \"INSERT INTO inventory VALUES(:asset, :tenant, :inspection, :version)\", assets(split)\n",
    "    )\n",
    "    db.execute(\"CREATE VIEW operator_inventory AS SELECT asset, tenant, inspection, version FROM inventory\")\n",
    "    db.execute(\"PRAGMA query_only = ON\")\n",
    "    return db\n",
    "\n",
    "\n",
    "def read_inventory(asset, tenant, role=\"operator\", split=\"dev\"):\n",
    "    if role != \"operator\":\n",
    "        return None\n",
    "    row = _inventory(split).execute(\n",
    "        \"SELECT * FROM operator_inventory WHERE asset = ? AND tenant = ?\", (asset, tenant)\n",
    "    ).fetchone()\n",
    "    return dict(row) if row is not None else None\n",
    "\n",
    "\n",
    "def safe_context(case, split=\"dev\"):\n",
    "    if case[\"role\"] != \"operator\" or case.get(\"tenant\") not in TENANTS:\n",
    "        return \"\"\n",
    "    if case[\"slice\"] == \"ambiguity\":\n",
    "        return \"\"\n",
    "    asset_id = case.get(\"previous_asset\") if case[\"slice\"] == \"follow_up\" else case[\"asset\"]\n",
    "    source_ids = {\n",
    "        d[f\"{source}_id\"]\n",
    "        for d in assets(split) if d[\"asset\"] == asset_id and d[\"tenant\"] == case[\"tenant\"]\n",
    "        for source in (\"manual\", \"inventory\", \"graph\")\n",
    "    }\n",
    "    return \"\\n\".join(f\"[{doc['id']}] {doc['text']}\" for doc in corpus(split) if doc[\"id\"] in source_ids)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-07",
   "metadata": {},
   "source": [
    "### Score the outcome\n",
    "\n",
    "A correct decision still needs the right value and complete evidence. Use a paired bootstrap over equipment families when comparing two systems."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "lab-08-08",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:37.912190Z",
     "iopub.status.busy": "2026-11-27T07:22:37.911905Z",
     "iopub.status.idle": "2026-11-27T07:22:37.927285Z",
     "shell.execute_reply": "2026-11-27T07:22:37.926727Z"
    }
   },
   "outputs": [],
   "source": [
    "def score_answer(case, answer):\n",
    "    if not isinstance(answer, dict) or not isinstance(answer.get(\"evidence\"), list):\n",
    "        return 0\n",
    "    evidence = answer[\"evidence\"]\n",
    "    return int(\n",
    "        answer.get(\"decision\") == case[\"decision\"]\n",
    "        and isinstance(answer.get(\"value\"), str)\n",
    "        and answer[\"value\"].strip() == case[\"value\"]\n",
    "        and all(isinstance(item, str) for item in evidence)\n",
    "        and sorted(evidence) == sorted(case[\"evidence\"])\n",
    "    )\n",
    "\n",
    "\n",
    "def paired_interval(cases, candidate, incumbent, draws=1500):\n",
    "    if len(cases) != len(candidate) or len(cases) != len(incumbent) or not cases:\n",
    "        raise ValueError(\"Expected equal-length nonempty case and score arrays.\")\n",
    "    groups = {}\n",
    "    for case, new, old in zip(cases, candidate, incumbent):\n",
    "        groups.setdefault(case[\"family\"], []).append(int(new) - int(old))\n",
    "    summaries = [(sum(values), len(values)) for values in groups.values()]\n",
    "    rng = random.Random(401)\n",
    "    estimates = []\n",
    "    for _ in range(draws):\n",
    "        sampled = rng.choices(summaries, k=len(summaries))\n",
    "        estimates.append(sum(total for total, _ in sampled) / sum(n for _, n in sampled))\n",
    "    estimates.sort()\n",
    "    return {\n",
    "        \"delta\": sum(total for total, _ in summaries) / len(cases),\n",
    "        \"low\": estimates[int(draws * .025)],\n",
    "        \"high\": estimates[int(draws * .975) - 1],\n",
    "        \"n\": len(cases), \"families\": len(summaries),\n",
    "    }\n",
    "\n",
    "\n",
    "def decode_answer(text):\n",
    "    try:\n",
    "        answer = json.loads(text.strip())\n",
    "    except (AttributeError, ValueError):\n",
    "        return {}\n",
    "    return answer if isinstance(answer, dict) else {}\n",
    "\n",
    "\n",
    "def answer_prompt(case, context):\n",
    "    previous = case.get(\"previous_asset\") or \"none\"\n",
    "    return (\n",
    "        \"You are a facilities helpdesk. Use only the supplied records. Decide answer, clarify, or deny. \"\n",
    "        \"Deny requests from a guest. Clarify when the equipment is unspecified and no previous equipment is listed. \"\n",
    "        \"Output exactly one JSON object with keys decision, value and evidence. For deny or clarify use an empty \"\n",
    "        \"value and evidence array. Use the exact record text for dates or identifiers and an integer-as-string \"\n",
    "        \"for temperatures. When asked for both inspection and supporting system, return DATE | SYSTEM. \"\n",
    "        \"For an answer include only supporting record IDs in evidence.\\n\"\n",
    "        f\"Role: {case['role']}\\nPrevious equipment: {previous}\\nRequest: {case['question']}\\n\"\n",
    "        f\"Records:\\n{context or '(none)'}\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-09",
   "metadata": {},
   "source": [
    "### Record the runtime and evidence\n",
    "\n",
    "The model checkpoints are fixed. Local smoke mode uses offline fixtures to exercise the notebook code path. It cannot produce GPU measurements."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "lab-08-10",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:37.930883Z",
     "iopub.status.busy": "2026-11-27T07:22:37.930630Z",
     "iopub.status.idle": "2026-11-27T07:22:45.903174Z",
     "shell.execute_reply": "2026-11-27T07:22:45.901713Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Evidence saved to evidence/runtime.json\n",
      "{\n",
      "  \"device\": \"Tesla T4\",\n",
      "  \"python\": \"3.13.16\",\n",
      "  \"platform\": \"Linux\",\n",
      "  \"packages\": {\n",
      "    \"torch\": \"2.14.1+cu130\",\n",
      "    \"transformers\": \"4.51.3\",\n",
      "    \"accelerate\": \"1.6.0\",\n",
      "    \"numpy\": \"2.4.6\",\n",
      "    \"scikit-learn\": \"1.6.1\",\n",
      "    \"matplotlib\": \"3.10.0\",\n",
      "    \"bitsandbytes\": \"0.49.0\",\n",
      "    \"sentence-transformers\": \"4.1.0\"\n",
      "  },\n",
      "  \"smoke\": false,\n",
      "  \"cuda\": \"13.0\",\n",
      "  \"memory_bytes\": 15637086208,\n",
      "  \"capability\": [\n",
      "    7,\n",
      "    5\n",
      "  ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "def _convert(value):\n",
    "    if hasattr(value, \"tolist\"):\n",
    "        return value.tolist()\n",
    "    if hasattr(value, \"item\"):\n",
    "        return value.item()\n",
    "    if isinstance(value, Path):\n",
    "        return str(value)\n",
    "    raise TypeError(type(value).__name__)\n",
    "\n",
    "\n",
    "def save(name, value):\n",
    "    output = Path(\"evidence\")\n",
    "    output.mkdir(exist_ok=True)\n",
    "    path = output / f\"{name}.json\"\n",
    "    path.write_text(json.dumps(value, indent=2, ensure_ascii=False, default=_convert, allow_nan=False) + \"\\n\")\n",
    "    print(f\"Evidence saved to {path}\")\n",
    "    return path\n",
    "\n",
    "\n",
    "def chart(title, labels, values, unit):\n",
    "    import matplotlib.pyplot as plt\n",
    "    import numpy as np\n",
    "    from matplotlib.ticker import PercentFormatter\n",
    "\n",
    "    values = np.asarray(values, dtype=float)\n",
    "    positions = np.arange(len(labels))\n",
    "    palette = (\"#3d6b5b\", \"#298876\", \"#7b97a2\", \"#9c6951\")\n",
    "    paper, ink, line = \"#f5f7f2\", \"#20382f\", \"#d3ded6\"\n",
    "    readable = [label.replace(\"_\", \" \") for label in labels]\n",
    "    fig, axes = plt.subplots(figsize=(8.1, max(2.55, .48 * len(labels) + 1.7)), layout=\"constrained\")\n",
    "    fig.patch.set_facecolor(paper)\n",
    "    axes.set_facecolor(paper)\n",
    "    bars = axes.barh(positions, values, height=.55, color=[palette[i % len(palette)] for i in positions])\n",
    "    axes.set_yticks(positions, labels=readable)\n",
    "    axes.invert_yaxis()\n",
    "    fraction = unit.casefold() == \"fraction\"\n",
    "    if fraction:\n",
    "        axes.xaxis.set_major_formatter(PercentFormatter(xmax=1, decimals=0))\n",
    "    axes.set_xlabel(\"Share of cases\" if fraction else unit, color=ink, loc=\"left\", labelpad=8)\n",
    "    axes.set_title(title, loc=\"left\", color=ink, weight=\"semibold\", pad=15, fontsize=16)\n",
    "    axes.set_axisbelow(True)\n",
    "    axes.grid(axis=\"x\", color=line, linewidth=.75)\n",
    "    axes.spines[[\"top\", \"right\", \"left\", \"bottom\"]].set_visible(False)\n",
    "    axes.tick_params(axis=\"both\", length=0, colors=ink, pad=5)\n",
    "    finite = values[np.isfinite(values)]\n",
    "    if len(finite):\n",
    "        left, right = min(0.0, finite.min()), max(0.0, finite.max())\n",
    "        span = right - left or 1.0\n",
    "        axes.set_xlim(left - (.15 * span if left < 0 else 0), right + .18 * span)\n",
    "        for bar, value in zip(bars, values):\n",
    "            if not np.isfinite(value):\n",
    "                continue\n",
    "            center = bar.get_y() + bar.get_height() / 2\n",
    "            if value == 0:\n",
    "                axes.scatter([0], [center], s=14, color=ink, clip_on=False, zorder=3)\n",
    "            formatted = f\"{value:.1%}\" if fraction else f\"{value:,.3g}\"\n",
    "            axes.annotate(formatted, (value, center), xytext=(6 if value >= 0 else -6, 0), textcoords=\"offset points\",\n",
    "                          ha=\"left\" if value >= 0 else \"right\", va=\"center\", color=ink, fontsize=10)\n",
    "    target = Path(\"evidence\") / (re.sub(r\"[^a-z0-9]+\", \"-\", title.lower()).strip(\"-\") + \".svg\")\n",
    "    target.parent.mkdir(exist_ok=True)\n",
    "    fig.savefig(target)\n",
    "    plt.show()\n",
    "    plt.close(fig)\n",
    "\n",
    "import importlib.metadata\n",
    "import platform\n",
    "import sys\n",
    "import time\n",
    "\n",
    "COURSE_SMOKE = os.environ.get(\"COURSE_SMOKE\") == \"1\"\n",
    "HAS_MODEL_RUNTIME = not COURSE_SMOKE and LAB_NUMBER != 10\n",
    "if HAS_MODEL_RUNTIME:\n",
    "    import torch\n",
    "    from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig\n",
    "\n",
    "\n",
    "def device_name():\n",
    "    if COURSE_SMOKE:\n",
    "        return \"CPU smoke\"\n",
    "    if not HAS_MODEL_RUNTIME:\n",
    "        return \"CPU\"\n",
    "    return torch.cuda.get_device_name(0) if torch.cuda.is_available() else \"CPU\"\n",
    "\n",
    "\n",
    "def sync():\n",
    "    if HAS_MODEL_RUNTIME and torch.cuda.is_available():\n",
    "        torch.cuda.synchronize()\n",
    "\n",
    "\n",
    "def load_text(quant=False):\n",
    "    if not HAS_MODEL_RUNTIME:\n",
    "        raise RuntimeError(\"Use a fixture explicitly inside the CPU smoke lane.\")\n",
    "    repo, revision = MODEL_IDS[\"text\"]\n",
    "    tokenizer = AutoTokenizer.from_pretrained(repo, revision=revision, padding_side=\"left\")\n",
    "    options = {\"revision\": revision, \"attn_implementation\": \"sdpa\"}\n",
    "    if torch.cuda.is_available():\n",
    "        options.update(torch_dtype=torch.float16, device_map={\"\": 0})\n",
    "    else:\n",
    "        options.update(torch_dtype=torch.float32)\n",
    "    if quant:\n",
    "        if not torch.cuda.is_available():\n",
    "            raise RuntimeError(\"NF4 comparison requires CUDA.\")\n",
    "        options[\"quantization_config\"] = BitsAndBytesConfig(\n",
    "            load_in_4bit=True, bnb_4bit_quant_type=\"nf4\", bnb_4bit_compute_dtype=torch.float16,\n",
    "        )\n",
    "    return tokenizer, AutoModelForCausalLM.from_pretrained(repo, **options).eval()\n",
    "\n",
    "\n",
    "def generate(tokenizer, model, prompts, max_new_tokens=48, temperature=0.0, **kwargs):\n",
    "    rendered = [\n",
    "        tokenizer.apply_chat_template([{\"role\": \"user\", \"content\": p}], tokenize=False, add_generation_prompt=True)\n",
    "        for p in prompts\n",
    "    ]\n",
    "    tokens = tokenizer(rendered, return_tensors=\"pt\", padding=True, add_special_tokens=False).to(model.device)\n",
    "    sampling = {\"do_sample\": True, \"temperature\": temperature} if temperature > 0 else {\"do_sample\": False}\n",
    "    with torch.inference_mode():\n",
    "        output = model.generate(\n",
    "            **tokens, max_new_tokens=max_new_tokens, pad_token_id=tokenizer.pad_token_id,\n",
    "            **sampling, **kwargs,\n",
    "        )\n",
    "    return tokenizer.batch_decode(output[:, tokens.input_ids.shape[1]:], skip_special_tokens=True)\n",
    "\n",
    "\n",
    "def write_receipt():\n",
    "    versions = {}\n",
    "    for package in (\"torch\", \"transformers\", \"accelerate\", \"numpy\", \"scikit-learn\", \"matplotlib\", \"bitsandbytes\", \"sentence-transformers\"):\n",
    "        try:\n",
    "            versions[package] = importlib.metadata.version(package)\n",
    "        except importlib.metadata.PackageNotFoundError:\n",
    "            pass\n",
    "    receipt = {\n",
    "        \"device\": device_name(), \"python\": sys.version.split()[0], \"platform\": platform.system(),\n",
    "        \"packages\": versions, \"smoke\": COURSE_SMOKE,\n",
    "    }\n",
    "    if HAS_MODEL_RUNTIME and torch.cuda.is_available():\n",
    "        props = torch.cuda.get_device_properties(0)\n",
    "        receipt.update(cuda=torch.version.cuda, memory_bytes=props.total_memory, capability=list(torch.cuda.get_device_capability(0)))\n",
    "    save(\"runtime\", receipt)\n",
    "    print(json.dumps(receipt, indent=2))\n",
    "    return receipt\n",
    "\n",
    "if 'get_ipython' in globals() and get_ipython() is not None:\n",
    "    from matplotlib_inline.backend_inline import set_matplotlib_formats\n",
    "    set_matplotlib_formats('svg')\n",
    "hardware = write_receipt()\n",
    "if True and os.environ.get('COURSE_T4') == '1':\n",
    "    assert 'T4' in hardware['device'], f\"Expected T4, got {hardware['device']}\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-11",
   "metadata": {},
   "source": [
    "### What parts of a workflow should the model decide?\n",
    "\n",
    "A facilities operator opens the saved F-250 fan thread and asks, “What is\n",
    "its maximum temperature?” Should the desk read the current manual or ask\n",
    "which fan the operator means? First check the saved revision.\n",
    "\n",
    "A helpdesk can follow a fixed graph, or it can ask a model for the next action.\n",
    "Compare them with the same local read-only tools and the same benchmark cases.\n",
    "The model selects from a closed enum. Trusted runtime state owns identity,\n",
    "tenant, the tool registry, the turn limit and every argument sent to a tool.\n",
    "\n",
    "Read the [lesson](https://docs.recohut.com/courses/advanced-ai-systems-engineering/3-connect-tools-and-inputs/08-bound-a-model-led-workflow).\n",
    "\n",
    "[ReAct](https://arxiv.org/abs/2210.03629) · [MemGPT](https://arxiv.org/abs/2310.08560)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "lab-08-12",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:45.906966Z",
     "iopub.status.busy": "2026-11-27T07:22:45.906155Z",
     "iopub.status.idle": "2026-11-27T07:22:45.917822Z",
     "shell.execute_reply": "2026-11-27T07:22:45.917102Z"
    }
   },
   "outputs": [],
   "source": [
    "from collections import Counter\n",
    "from dataclasses import dataclass\n",
    "from statistics import mean, median\n",
    "from time import perf_counter\n",
    "\n",
    "ACTIONS = {\n",
    "    \"M\": \"manual\", \"I\": \"inventory\", \"G\": \"graph\",\n",
    "    \"A\": \"answer\", \"C\": \"clarify\", \"D\": \"deny\",\n",
    "}\n",
    "READS = {\"manual\", \"inventory\", \"graph\"}\n",
    "TURN_LIMIT = 5\n",
    "CALL_LIMIT = 5\n",
    "TOKEN_LIMIT = 4\n",
    "VARIANTS = {0, 1, 2}\n",
    "TIMEOUT_SLICES = {\"numeric\", \"multi_source\"}\n",
    "SCOPED_ASSETS = {(a[\"tenant\"], a[\"asset\"]): a for a in assets()}\n",
    "\n",
    "\n",
    "@dataclass(frozen=True)\n",
    "class ScopedRequest:\n",
    "    principal: str\n",
    "    tenant: str\n",
    "    asset: str | None\n",
    "    stale_memory: bool\n",
    "\n",
    "\n",
    "def trusted_scope(case):\n",
    "    \"\"\"Explicit IDs take priority. Memory needs a matching revision.\"\"\"\n",
    "    explicit = re.search(r\"\\b[PFV]-\\d+\\b\", case[\"question\"])\n",
    "    if explicit:\n",
    "        asset = explicit.group()\n",
    "        stale = False\n",
    "    else:\n",
    "        previous = case.get(\"previous_asset\") or \"\"\n",
    "        row = SCOPED_ASSETS.get((case[\"tenant\"], previous))\n",
    "        stale = bool(previous and (row is None or row[\"version\"] != case[\"previous_version\"]))\n",
    "        asset = previous if row and not stale else None\n",
    "    return ScopedRequest(case[\"role\"], case[\"tenant\"], asset, stale)\n",
    "\n",
    "\n",
    "def local_read(action, scope):\n",
    "    \"\"\"Return the value and evidence ID from one allowed source.\"\"\"\n",
    "    if scope.principal != \"operator\" or scope.asset is None or action not in READS:\n",
    "        return None\n",
    "    row = SCOPED_ASSETS.get((scope.tenant, scope.asset))\n",
    "    if row is None:\n",
    "        return None\n",
    "    if action == \"inventory\":\n",
    "        record = read_inventory(scope.asset, scope.tenant, scope.principal)\n",
    "        return (record[\"inspection\"], row[\"inventory_id\"]) if record else None\n",
    "    if action == \"manual\":\n",
    "        return str(row[\"limit\"]), row[\"manual_id\"]\n",
    "    return row[\"linked\"], row[\"graph_id\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-13",
   "metadata": {},
   "source": [
    "### Can the same identifier be resolved in another tenant?\n",
    "\n",
    "Replay three versions of one ticket against the tool gate. A permitted\n",
    "operator can read it. Guests and operators in another tenant cannot."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "lab-08-14",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:45.921417Z",
     "iopub.status.busy": "2026-11-27T07:22:45.920785Z",
     "iopub.status.idle": "2026-11-27T07:22:45.928393Z",
     "shell.execute_reply": "2026-11-27T07:22:45.927620Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Inventory scope checks: {'operator': True, 'guest': False, 'other_tenant': False}\n"
     ]
    }
   ],
   "source": [
    "example = next(c for c in cases() if c[\"slice\"] == \"numeric\")\n",
    "other_tenant = next(t for t in TENANTS if t != example[\"tenant\"])\n",
    "scope_checks = {\n",
    "    \"operator\": local_read(\"inventory\", trusted_scope(example)) is not None,\n",
    "    \"guest\": local_read(\"inventory\", trusted_scope(dict(example, role=\"guest\"))) is not None,\n",
    "    \"other_tenant\": local_read(\"inventory\", trusted_scope(dict(example, tenant=other_tenant))) is not None,\n",
    "}\n",
    "assert scope_checks == {\"operator\": True, \"guest\": False, \"other_tenant\": False}\n",
    "print(\"Inventory scope checks:\", scope_checks)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-15",
   "metadata": {},
   "source": [
    "### What changes between the fixed policy and the model?\n",
    "\n",
    "The fixed graph chooses sources from lexical intent rules. The model sees the\n",
    "ticket and the names of available or previously read sources, then chooses\n",
    "one action per turn. The shared application renders a typed answer from\n",
    "observations. Neither policy can supply new tool arguments."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "lab-08-16",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:45.931617Z",
     "iopub.status.busy": "2026-11-27T07:22:45.931276Z",
     "iopub.status.idle": "2026-11-27T07:22:45.939181Z",
     "shell.execute_reply": "2026-11-27T07:22:45.938339Z"
    }
   },
   "outputs": [],
   "source": [
    "def fixed_graph(case, scope, observations):\n",
    "    if scope.asset is None:\n",
    "        return \"clarify\"\n",
    "    question = case[\"question\"].lower()\n",
    "    planned = []\n",
    "    if \"inspect\" in question:\n",
    "        planned.append(\"inventory\")\n",
    "    if \"supports\" in question or \"supporting system\" in question:\n",
    "        planned.append(\"graph\")\n",
    "    if not planned:\n",
    "        planned.append(\"manual\")\n",
    "    return next((source for source in planned if source not in observations), \"answer\")\n",
    "\n",
    "\n",
    "def model_action(case, scope, observations, infer):\n",
    "    choices = \"M=read manual, I=read inventory, G=read supporting system, A=answer, C=clarify, D=deny\"\n",
    "    requested = case[\"question\"]\n",
    "    previous = scope.asset or \"none\"\n",
    "    seen = \", \".join(observations) or \"none\"\n",
    "    prompt = (\n",
    "        \"Choose a single next action for a facilities helpdesk. Output exactly its one uppercase letter. \"\n",
    "        \"For a maximum temperature read the manual. For an inspection date read the inventory. \"\n",
    "        \"For a supporting system read the graph. Read every source the request needs before answering. \"\n",
    "        \"If equipment identity is missing or stale, clarify. Do not read a source twice. \"\n",
    "        f\"Choices: {choices}. Request: {requested}\\n\"\n",
    "        f\"Allowed equipment ID: {previous}\\nAlready read: {seen}\"\n",
    "    )\n",
    "    raw = infer(prompt)\n",
    "    normalized = raw.strip().removesuffix(\".\")\n",
    "    return ACTIONS.get(normalized, \"invalid_choice\"), raw\n",
    "\n",
    "\n",
    "def render_response(decision, observations=()):\n",
    "    values = [value for value, _ in observations]\n",
    "    return {\"decision\": decision, \"value\": \" | \".join(values), \"evidence\": [eid for _, eid in observations]}\n",
    "\n",
    "\n",
    "def completed_sources(observations):\n",
    "    # Convert unordered observations to the stable date / linked-system format.\n",
    "    order = (\"inventory\", \"graph\", \"manual\")\n",
    "    return [observations[source] for source in order if source in observations]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-17",
   "metadata": {},
   "source": [
    "### Can a timeout be replayed without duplicating completed reads?\n",
    "\n",
    "Inject one reproducible timeout before a read completes. Serialize the\n",
    "observations and pending action, then restore the same pending action.\n",
    "Both outcomes share one prefix up to the interruption. Resume consumes one\n",
    "more tool attempt and does not ask the policy to choose that pending read again."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "lab-08-18",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:45.942469Z",
     "iopub.status.busy": "2026-11-27T07:22:45.942170Z",
     "iopub.status.idle": "2026-11-27T07:22:45.954861Z",
     "shell.execute_reply": "2026-11-27T07:22:45.954138Z"
    }
   },
   "outputs": [],
   "source": [
    "def execute_policy(case, choose, *, simulate_timeout=False, interrupted=None):\n",
    "    scope = trusted_scope(case)\n",
    "    started = perf_counter()\n",
    "    observations, events = {}, []\n",
    "    attempts = decisions = next_turn = 0\n",
    "    pending = None\n",
    "    terminal = \"turn_budget\"\n",
    "    response = {}\n",
    "    checkpoint = None\n",
    "\n",
    "    if interrupted is not None:\n",
    "        assert interrupted[\"stop_reason\"] == \"timeout\"\n",
    "        snapshot = json.loads(interrupted[\"events\"][-1][\"checkpoint\"])\n",
    "        assert snapshot[\"case_id\"] == case[\"id\"]\n",
    "        next_turn, pending = snapshot[\"turn\"], snapshot[\"pending_action\"]\n",
    "        observations = snapshot[\"observations\"]\n",
    "        attempts, decisions = snapshot[\"tool_attempts\"], snapshot[\"decision_calls\"]\n",
    "        events = list(interrupted[\"events\"])\n",
    "\n",
    "    if scope.principal != \"operator\":\n",
    "        terminal = \"role_denied\"\n",
    "        response = render_response(\"deny\")\n",
    "    else:\n",
    "        for turn in range(next_turn, TURN_LIMIT):\n",
    "            if pending is not None:\n",
    "                action, pending = pending, None\n",
    "                events.append({\"turn\": turn, \"action\": action, \"kind\": \"resume\"})\n",
    "            else:\n",
    "                action, raw = choose(case, scope, observations)\n",
    "                decisions += 1\n",
    "                events.append({\"turn\": turn, \"action\": action, \"kind\": \"choice\", \"raw\": raw})\n",
    "            if action in {\"clarify\", \"deny\"}:\n",
    "                response = render_response(action)\n",
    "                terminal = action\n",
    "                break\n",
    "            if action == \"answer\":\n",
    "                if observations:\n",
    "                    response = render_response(\"answer\", completed_sources(observations))\n",
    "                    terminal = \"submitted\"\n",
    "                else:\n",
    "                    terminal = \"answer_without_evidence\"\n",
    "                break\n",
    "            if action not in READS or action in observations or scope.asset is None:\n",
    "                terminal = \"invalid_or_out_of_scope\"\n",
    "                break\n",
    "            if attempts >= CALL_LIMIT:\n",
    "                terminal = \"call_budget\"\n",
    "                break\n",
    "            attempts += 1\n",
    "            fail_here = case[\"slice\"] != \"multi_source\" or bool(observations)\n",
    "            if simulate_timeout and fail_here:\n",
    "                checkpoint = json.dumps(dict(\n",
    "                    case_id=case[\"id\"], turn=turn, pending_action=action,\n",
    "                    observations=observations, tool_attempts=attempts, decision_calls=decisions,\n",
    "                ))\n",
    "                events.append({\"turn\": turn, \"action\": action, \"kind\": \"timeout\", \"checkpoint\": checkpoint})\n",
    "                terminal = \"timeout\"\n",
    "                break\n",
    "            value = local_read(action, scope)\n",
    "            if value is None:\n",
    "                terminal = \"read_denied\"\n",
    "                break\n",
    "            observations[action] = value\n",
    "            events.append({\"turn\": turn, \"action\": action, \"kind\": \"read\", \"evidence_id\": value[1]})\n",
    "\n",
    "    passed = score_answer(case, response)\n",
    "    was_interrupted = checkpoint is not None or interrupted is not None\n",
    "    elapsed_ms = None if COURSE_SMOKE else 1e3 * (perf_counter() - started)\n",
    "    if interrupted is not None and elapsed_ms is not None:\n",
    "        elapsed_ms += interrupted[\"latency_ms\"]\n",
    "    return dict(\n",
    "        case_id=case[\"id\"], family=case[\"family\"], slice=case[\"slice\"], question=case[\"question\"],\n",
    "        expected={key: case[key] for key in (\"decision\", \"value\", \"evidence\")}, response=response,\n",
    "        scope=dict(role=scope.principal, tenant=scope.tenant, asset=scope.asset,\n",
    "                   previous_asset=case[\"previous_asset\"], previous_version=case[\"previous_version\"],\n",
    "                   stale_memory=scope.stale_memory),\n",
    "        pass_=passed, unsupported_answer=response.get(\"decision\") == \"answer\" and not passed,\n",
    "        stale_error=scope.stale_memory and response.get(\"decision\") != \"clarify\",\n",
    "        timeout_planned=simulate_timeout or interrupted is not None, timeout_injected=was_interrupted,\n",
    "        recovered=interrupted is not None and bool(passed), tool_attempts=attempts,\n",
    "        decision_calls=decisions, stop_reason=terminal, latency_ms=elapsed_ms, events=events,\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-19",
   "metadata": {},
   "source": [
    "### Which follow-ups should keep memory?\n",
    "\n",
    "Start with the same held-back-from-tuning development variants in every arm.\n",
    "Add matched stale copies of selected follow-ups. The copied case expects\n",
    "clarification because the revision changed. Compare abort and resume with\n",
    "each version of the policy on these identical cases."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "lab-08-20",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:45.958060Z",
     "iopub.status.busy": "2026-11-27T07:22:45.957637Z",
     "iopub.status.idle": "2026-11-27T07:22:45.977942Z",
     "shell.execute_reply": "2026-11-27T07:22:45.977197Z"
    }
   },
   "outputs": [],
   "source": [
    "registered_dev = cases(\"dev\")\n",
    "assert digest(registered_dev) == SPLIT_MANIFEST[\"dev\"][\"sha256\"]\n",
    "primary_cases = [case for case in registered_dev if case[\"variant\"] in VARIANTS]\n",
    "follow_up_pairs = [\n",
    "    (case, dict(case, id=f\"{case['id']}-stale\", decision=\"clarify\", value=\"\", evidence=[], previous_version=\"r2\"))\n",
    "    for case in primary_cases if case[\"slice\"] == \"follow_up\" and case[\"variant\"] == 0\n",
    "]\n",
    "workflow_cases = primary_cases + [stale for _, stale in follow_up_pairs]\n",
    "assert len({c[\"id\"] for c in workflow_cases}) == len(workflow_cases)\n",
    "assert all(\n",
    "    not trusted_scope(c).asset for c in workflow_cases if c[\"id\"].endswith(\"-stale\")\n",
    ")\n",
    "\n",
    "\n",
    "def compare_workflows(policies, experiment_cases):\n",
    "    records = []\n",
    "    for policy_name, policy in policies.items():\n",
    "        for case in experiment_cases:\n",
    "            timeout = case[\"variant\"] == 1 and case[\"slice\"] in TIMEOUT_SLICES\n",
    "            abort_row = execute_policy(case, policy, simulate_timeout=timeout)\n",
    "            resume_row = (\n",
    "                execute_policy(case, policy, interrupted=abort_row)\n",
    "                if abort_row[\"timeout_injected\"]\n",
    "                else abort_row\n",
    "            )\n",
    "            assert resume_row[\"events\"][:len(abort_row[\"events\"])] == abort_row[\"events\"]\n",
    "            records.extend([\n",
    "                dict(abort_row, policy=policy_name, recovery=\"abort\"),\n",
    "                dict(resume_row, policy=policy_name, recovery=\"resume\"),\n",
    "            ])\n",
    "    return records\n",
    "\n",
    "\n",
    "def fixed_choice(case, scope, observations):\n",
    "    return fixed_graph(case, scope, observations), None\n",
    "\n",
    "\n",
    "def expected(case):\n",
    "    return {key: case[key] for key in (\"decision\", \"value\", \"evidence\")}\n",
    "\n",
    "\n",
    "def workflow_summary(records):\n",
    "    groups = sorted({(row[\"policy\"], row[\"recovery\"]) for row in records})\n",
    "    index = {(row[\"policy\"], row[\"recovery\"], row[\"case_id\"]): row for row in records}\n",
    "    outcomes, intervals, follow_ups = [], [], []\n",
    "    cohorts = {\"selected_dev\": primary_cases}\n",
    "    cohorts.update({name: [case for case in primary_cases if case[\"slice\"] == name] for name in SLICES})\n",
    "    for name, recovery in groups:\n",
    "        for cohort, cases_in_scope in cohorts.items():\n",
    "            subset = [index[name, recovery, case[\"id\"]] for case in cases_in_scope]\n",
    "            durations = [row[\"latency_ms\"] for row in subset if row[\"latency_ms\"] is not None]\n",
    "            outcomes.append(dict(\n",
    "                policy=name, recovery=recovery, cohort=cohort,\n",
    "                n=len(subset), families=len({row[\"family\"] for row in subset}),\n",
    "                strict_passes=sum(row[\"pass_\"] for row in subset),\n",
    "                expected_decisions=dict(Counter(row[\"expected\"][\"decision\"] for row in subset)),\n",
    "                stop_reasons=dict(Counter(row[\"stop_reason\"] for row in subset)),\n",
    "                unsupported_answers=sum(row[\"unsupported_answer\"] for row in subset),\n",
    "                timeout_planned=sum(row[\"timeout_planned\"] for row in subset),\n",
    "                timed_out=sum(row[\"timeout_injected\"] for row in subset),\n",
    "                recoveries=sum(row[\"recovered\"] for row in subset),\n",
    "                calls_per_case=mean(row[\"tool_attempts\"] for row in subset),\n",
    "                decision_calls_per_case=mean(row[\"decision_calls\"] for row in subset),\n",
    "                median_latency_ms=median(durations) if durations else None,\n",
    "            ))\n",
    "        for base_name, base_recovery in ((\"fixed\", recovery), (name, \"abort\")):\n",
    "            if (name, recovery) == (base_name, base_recovery):\n",
    "                continue\n",
    "            candidate = [index[name, recovery, case[\"id\"]][\"pass_\"] for case in primary_cases]\n",
    "            baseline = [index[base_name, base_recovery, case[\"id\"]][\"pass_\"] for case in primary_cases]\n",
    "            diffs = [new - old for new, old in zip(candidate, baseline)]\n",
    "            intervals.append(dict(\n",
    "                candidate_policy=name, candidate_recovery=recovery, baseline_policy=base_name,\n",
    "                baseline_recovery=base_recovery, wins=diffs.count(1), losses=diffs.count(-1),\n",
    "                **paired_interval(primary_cases, candidate, baseline),\n",
    "            ))\n",
    "        for freshness, position in ((\"current\", 0), (\"stale\", 1)):\n",
    "            subset = [index[name, recovery, pair[position][\"id\"]] for pair in follow_up_pairs]\n",
    "            follow_ups.append(dict(\n",
    "                policy=name, recovery=recovery, freshness=freshness,\n",
    "                cases=[row[\"case_id\"] for row in subset], n=len(subset),\n",
    "                strict_passes=sum(row[\"pass_\"] for row in subset),\n",
    "                stale_errors=sum(row[\"stale_error\"] for row in subset),\n",
    "                completed_reads=sum(event[\"kind\"] == \"read\" for row in subset for event in row[\"events\"]),\n",
    "            ))\n",
    "    return outcomes, intervals, follow_ups"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-21",
   "metadata": {},
   "source": [
    "### What changes when the saved fan reference becomes stale?\n",
    "\n",
    "Look at the synthetic F-250 continuation. Change the saved revision while\n",
    "keeping the tenant, caller and wording fixed. Predict whether to open the\n",
    "current manual or ask which equipment the caller means."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "lab-08-22",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:45.981140Z",
     "iopub.status.busy": "2026-11-27T07:22:45.980784Z",
     "iopub.status.idle": "2026-11-27T07:22:45.987272Z",
     "shell.execute_reply": "2026-11-27T07:22:45.986637Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "F-250 follow-up: {\"case_id\": \"F250-00\", \"question\": \"What is its maximum temperature?\", \"role\": \"operator\", \"tenant\": \"north-yard\", \"saved_asset\": \"F-250\", \"manual\": {\"id\": \"manual-F-250-r3\", \"revision\": \"r3\", \"text\": \"Equipment manual for F-250 (revision r3). Maximum operating temperature: 101 C. Known fault: filter blockage. The supporting system is S-650. Maintenance owner: controls.\"}, \"current\": {\"case_id\": \"F250-00\", \"saved_version\": \"r3\", \"expected\": {\"decision\": \"answer\", \"value\": \"101\", \"evidence\": [\"manual-F-250-r3\"]}}, \"stale\": {\"case_id\": \"F250-00-stale\", \"saved_version\": \"r2\", \"expected\": {\"decision\": \"clarify\", \"value\": \"\", \"evidence\": []}}}\n",
      "Unsupported enum trace: [{'turn': 0, 'action': 'unregistered_choice', 'kind': 'choice', 'raw': None}]\n"
     ]
    }
   ],
   "source": [
    "current, stale = next(pair for pair in follow_up_pairs if pair[0][\"id\"] == \"F250-00\")\n",
    "opening = {\n",
    "    \"case_id\": current[\"id\"],\n",
    "    \"question\": current[\"question\"],\n",
    "    \"role\": current[\"role\"],\n",
    "    \"tenant\": current[\"tenant\"],\n",
    "    \"saved_asset\": current[\"previous_asset\"],\n",
    "    \"manual\": {\"id\": current[\"manual_id\"], \"revision\": current[\"version\"], \"text\": manual_text(current)},\n",
    "    \"current\": {\"case_id\": current[\"id\"], \"saved_version\": current[\"previous_version\"], \"expected\": expected(current)},\n",
    "    \"stale\": {\"case_id\": stale[\"id\"], \"saved_version\": stale[\"previous_version\"], \"expected\": expected(stale)},\n",
    "}\n",
    "print(\"F-250 follow-up:\", json.dumps(opening, ensure_ascii=False))\n",
    "\n",
    "invalid = execute_policy(example, lambda *_: (\"unregistered_choice\", None))\n",
    "assert invalid[\"stop_reason\"] == \"invalid_or_out_of_scope\"\n",
    "assert invalid[\"tool_attempts\"] == 0\n",
    "print(\"Unsupported enum trace:\", invalid[\"events\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-23",
   "metadata": {},
   "source": [
    "### Does bounded recovery improve completion?\n",
    "\n",
    "Inspect which cases changed, how often one extra tool attempt was enough\n",
    "and whether stale or unsupported decisions remained after policy checks.\n",
    "The fixture timeout measures replay behaviour under this controlled fault."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "lab-08-24",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-27T07:22:45.990396Z",
     "iopub.status.busy": "2026-11-27T07:22:45.990019Z",
     "iopub.status.idle": "2026-11-27T07:23:12.482865Z",
     "shell.execute_reply": "2026-11-27T07:23:12.482009Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.13/dist-packages/huggingface_hub/utils/_auth.py:104: UserWarning: \n",
      "Error while fetching `HF_TOKEN` secret value from your vault: 'Requesting secret HF_TOKEN timed out. Secrets can only be fetched when running from the Colab UI.'.\n",
      "You are not authenticated with the Hugging Face Hub in this notebook.\n",
      "If the error persists, please let us know by opening an issue on GitHub (https://github.com/huggingface/huggingface_hub/issues/new).\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Sliding Window Attention is enabled but not implemented for `sdpa`; unexpected results may be encountered.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:631: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.7` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:636: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.8` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:653: UserWarning: `do_sample` is set to `False`. However, `top_k` is set to `20` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_k`.\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:631: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.7` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:636: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.8` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.\n",
      "  warnings.warn(\n",
      "/usr/local/lib/python3.13/dist-packages/transformers/generation/configuration_utils.py:653: UserWarning: `do_sample` is set to `False`. However, `top_k` is set to `20` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_k`.\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paired completion and costs: {\n",
      "  \"mode\": \"measured\",\n",
      "  \"settings\": {\n",
      "    \"development_sha256\": \"51dbc208b6b20a620237dd76ce0a2db4f10aa75f4f8fc404121e301b8d79a0cf\",\n",
      "    \"selected_variants\": [\n",
      "      0,\n",
      "      1,\n",
      "      2\n",
      "    ],\n",
      "    \"base_case_count\": 36,\n",
      "    \"stale_pair_count\": 2,\n",
      "    \"turn_limit\": 5,\n",
      "    \"tool_call_limit\": 5,\n",
      "    \"max_new_tokens_per_choice\": 4,\n",
      "    \"checkpoint\": [\n",
      "      \"Qwen/Qwen2.5-1.5B-Instruct\",\n",
      "      \"989aa7980e4cf806f80c7fef2b1adb7bc71aa306\"\n",
      "    ],\n",
      "    \"model_load_s\": 19.109575561999918\n",
      "  },\n",
      "  \"outcomes\": [\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"selected_dev\",\n",
      "      \"n\": 36,\n",
      "      \"families\": 12,\n",
      "      \"strict_passes\": 32,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 24,\n",
      "        \"clarify\": 6,\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 20,\n",
      "        \"timeout\": 4,\n",
      "        \"clarify\": 6,\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 4,\n",
      "      \"timed_out\": 4,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0.8333333333333334,\n",
      "      \"decision_calls_per_case\": 1.5555555555555556,\n",
      "      \"median_latency_ms\": 0.013595499694929458\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"manual\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 0.014987999747972935\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"numeric\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 4,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 4,\n",
      "        \"timeout\": 2\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 1.6666666666666667,\n",
      "      \"median_latency_ms\": 0.025964499855035683\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"multi_source\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 4,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 4,\n",
      "        \"timeout\": 2\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 2,\n",
      "      \"decision_calls_per_case\": 2.6666666666666665,\n",
      "      \"median_latency_ms\": 0.039372000173898414\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"ambiguity\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"clarify\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"clarify\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 1,\n",
      "      \"median_latency_ms\": 0.005527499979507411\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"boundary\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 0,\n",
      "      \"median_latency_ms\": 0.0036530000215861946\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"follow_up\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 0.013046500043856213\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"selected_dev\",\n",
      "      \"n\": 36,\n",
      "      \"families\": 12,\n",
      "      \"strict_passes\": 36,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 24,\n",
      "        \"clarify\": 6,\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 24,\n",
      "        \"clarify\": 6,\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 4,\n",
      "      \"timed_out\": 4,\n",
      "      \"recoveries\": 4,\n",
      "      \"calls_per_case\": 0.9444444444444444,\n",
      "      \"decision_calls_per_case\": 1.6666666666666667,\n",
      "      \"median_latency_ms\": 0.013595499694929458\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"manual\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 0.014987999747972935\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"numeric\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 2,\n",
      "      \"calls_per_case\": 1.3333333333333333,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 0.042329999814683106\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"multi_source\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 2,\n",
      "      \"calls_per_case\": 2.3333333333333335,\n",
      "      \"decision_calls_per_case\": 3,\n",
      "      \"median_latency_ms\": 0.045525000132329296\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"ambiguity\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"clarify\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"clarify\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 1,\n",
      "      \"median_latency_ms\": 0.005527499979507411\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"boundary\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 0,\n",
      "      \"median_latency_ms\": 0.0036530000215861946\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"follow_up\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"submitted\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 0.013046500043856213\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"selected_dev\",\n",
      "      \"n\": 36,\n",
      "      \"families\": 12,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 24,\n",
      "        \"clarify\": 6,\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 28,\n",
      "        \"timeout\": 2,\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 4,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0.6666666666666666,\n",
      "      \"decision_calls_per_case\": 1.4444444444444444,\n",
      "      \"median_latency_ms\": 134.51204099965253\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"manual\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 149.7676115000104\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"numeric\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 4,\n",
      "        \"timeout\": 2\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 1.6666666666666667,\n",
      "      \"median_latency_ms\": 135.7669059998443\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"multi_source\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 138.49144599998908\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"ambiguity\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"clarify\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 1,\n",
      "      \"median_latency_ms\": 68.60567949979668\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"boundary\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 0,\n",
      "      \"median_latency_ms\": 0.0030069995773374103\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"cohort\": \"follow_up\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 145.36440899973968\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"selected_dev\",\n",
      "      \"n\": 36,\n",
      "      \"families\": 12,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 24,\n",
      "        \"clarify\": 6,\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 30,\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 4,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0.7222222222222222,\n",
      "      \"decision_calls_per_case\": 1.5,\n",
      "      \"median_latency_ms\": 135.11904899996807\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"manual\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 149.7676115000104\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"numeric\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 2,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1.3333333333333333,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 138.3850034999341\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"multi_source\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 2,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 138.49144599998908\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"ambiguity\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"clarify\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 1,\n",
      "      \"median_latency_ms\": 68.60567949979668\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"boundary\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 6,\n",
      "      \"expected_decisions\": {\n",
      "        \"deny\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"role_denied\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 0,\n",
      "      \"decision_calls_per_case\": 0,\n",
      "      \"median_latency_ms\": 0.0030069995773374103\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"cohort\": \"follow_up\",\n",
      "      \"n\": 6,\n",
      "      \"families\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"expected_decisions\": {\n",
      "        \"answer\": 6\n",
      "      },\n",
      "      \"stop_reasons\": {\n",
      "        \"invalid_or_out_of_scope\": 6\n",
      "      },\n",
      "      \"unsupported_answers\": 0,\n",
      "      \"timeout_planned\": 0,\n",
      "      \"timed_out\": 0,\n",
      "      \"recoveries\": 0,\n",
      "      \"calls_per_case\": 1,\n",
      "      \"decision_calls_per_case\": 2,\n",
      "      \"median_latency_ms\": 145.36440899973968\n",
      "    }\n",
      "  ],\n",
      "  \"paired_strict\": [\n",
      "    {\n",
      "      \"candidate_policy\": \"fixed\",\n",
      "      \"candidate_recovery\": \"resume\",\n",
      "      \"baseline_policy\": \"fixed\",\n",
      "      \"baseline_recovery\": \"abort\",\n",
      "      \"wins\": 4,\n",
      "      \"losses\": 0,\n",
      "      \"delta\": 0.1111111111111111,\n",
      "      \"low\": 0.027777777777777776,\n",
      "      \"high\": 0.19444444444444445,\n",
      "      \"n\": 36,\n",
      "      \"families\": 12\n",
      "    },\n",
      "    {\n",
      "      \"candidate_policy\": \"model\",\n",
      "      \"candidate_recovery\": \"abort\",\n",
      "      \"baseline_policy\": \"fixed\",\n",
      "      \"baseline_recovery\": \"abort\",\n",
      "      \"wins\": 0,\n",
      "      \"losses\": 26,\n",
      "      \"delta\": -0.7222222222222222,\n",
      "      \"low\": -0.8888888888888888,\n",
      "      \"high\": -0.5,\n",
      "      \"n\": 36,\n",
      "      \"families\": 12\n",
      "    },\n",
      "    {\n",
      "      \"candidate_policy\": \"model\",\n",
      "      \"candidate_recovery\": \"resume\",\n",
      "      \"baseline_policy\": \"fixed\",\n",
      "      \"baseline_recovery\": \"resume\",\n",
      "      \"wins\": 0,\n",
      "      \"losses\": 30,\n",
      "      \"delta\": -0.8333333333333334,\n",
      "      \"low\": -1.0,\n",
      "      \"high\": -0.5833333333333334,\n",
      "      \"n\": 36,\n",
      "      \"families\": 12\n",
      "    },\n",
      "    {\n",
      "      \"candidate_policy\": \"model\",\n",
      "      \"candidate_recovery\": \"resume\",\n",
      "      \"baseline_policy\": \"model\",\n",
      "      \"baseline_recovery\": \"abort\",\n",
      "      \"wins\": 0,\n",
      "      \"losses\": 0,\n",
      "      \"delta\": 0.0,\n",
      "      \"low\": 0.0,\n",
      "      \"high\": 0.0,\n",
      "      \"n\": 36,\n",
      "      \"families\": 12\n",
      "    }\n",
      "  ],\n",
      "  \"follow_ups\": [\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"freshness\": \"current\",\n",
      "      \"cases\": [\n",
      "        \"F250-00\",\n",
      "        \"F251-00\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 2,\n",
      "      \"stale_errors\": 0,\n",
      "      \"completed_reads\": 2\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"freshness\": \"stale\",\n",
      "      \"cases\": [\n",
      "        \"F250-00-stale\",\n",
      "        \"F251-00-stale\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 2,\n",
      "      \"stale_errors\": 0,\n",
      "      \"completed_reads\": 0\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"freshness\": \"current\",\n",
      "      \"cases\": [\n",
      "        \"F250-00\",\n",
      "        \"F251-00\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 2,\n",
      "      \"stale_errors\": 0,\n",
      "      \"completed_reads\": 2\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"fixed\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"freshness\": \"stale\",\n",
      "      \"cases\": [\n",
      "        \"F250-00-stale\",\n",
      "        \"F251-00-stale\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 2,\n",
      "      \"stale_errors\": 0,\n",
      "      \"completed_reads\": 0\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"freshness\": \"current\",\n",
      "      \"cases\": [\n",
      "        \"F250-00\",\n",
      "        \"F251-00\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"stale_errors\": 0,\n",
      "      \"completed_reads\": 2\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"abort\",\n",
      "      \"freshness\": \"stale\",\n",
      "      \"cases\": [\n",
      "        \"F250-00-stale\",\n",
      "        \"F251-00-stale\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"stale_errors\": 2,\n",
      "      \"completed_reads\": 0\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"freshness\": \"current\",\n",
      "      \"cases\": [\n",
      "        \"F250-00\",\n",
      "        \"F251-00\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"stale_errors\": 0,\n",
      "      \"completed_reads\": 2\n",
      "    },\n",
      "    {\n",
      "      \"policy\": \"model\",\n",
      "      \"recovery\": \"resume\",\n",
      "      \"freshness\": \"stale\",\n",
      "      \"cases\": [\n",
      "        \"F250-00-stale\",\n",
      "        \"F251-00-stale\"\n",
      "      ],\n",
      "      \"n\": 2,\n",
      "      \"strict_passes\": 0,\n",
      "      \"stale_errors\": 2,\n",
      "      \"completed_reads\": 0\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "Recorded timeout and resume: {\"case_id\": \"F220-01\", \"family\": \"F220\", \"slice\": \"multi_source\", \"question\": \"Please help. For F-220, which system supports it and when was its most recent inspection?\", \"expected\": {\"decision\": \"answer\", \"value\": \"2025-05-05 | S-620\", \"evidence\": [\"inventory-F-220-r3\", \"graph-F-220-r3\"]}, \"response\": {\"decision\": \"answer\", \"value\": \"2025-05-05 | S-620\", \"evidence\": [\"inventory-F-220-r3\", \"graph-F-220-r3\"]}, \"scope\": {\"role\": \"operator\", \"tenant\": \"north-yard\", \"asset\": \"F-220\", \"previous_asset\": \"\", \"previous_version\": \"\", \"stale_memory\": false}, \"pass_\": 1, \"unsupported_answer\": false, \"stale_error\": false, \"timeout_planned\": true, \"timeout_injected\": true, \"recovered\": true, \"tool_attempts\": 3, \"decision_calls\": 3, \"stop_reason\": \"submitted\", \"latency_ms\": 0.11423900014051469, \"events\": [{\"turn\": 0, \"action\": \"inventory\", \"kind\": \"choice\", \"raw\": null}, {\"turn\": 0, \"action\": \"inventory\", \"kind\": \"read\", \"evidence_id\": \"inventory-F-220-r3\"}, {\"turn\": 1, \"action\": \"graph\", \"kind\": \"choice\", \"raw\": null}, {\"turn\": 1, \"action\": \"graph\", \"kind\": \"timeout\", \"checkpoint\": \"{\\\"case_id\\\": \\\"F220-01\\\", \\\"turn\\\": 1, \\\"pending_action\\\": \\\"graph\\\", \\\"observations\\\": {\\\"inventory\\\": [\\\"2025-05-05\\\", \\\"inventory-F-220-r3\\\"]}, \\\"tool_attempts\\\": 2, \\\"decision_calls\\\": 2}\"}, {\"turn\": 1, \"action\": \"graph\", \"kind\": \"resume\"}, {\"turn\": 1, \"action\": \"graph\", \"kind\": \"read\", \"evidence_id\": \"graph-F-220-r3\"}, {\"turn\": 2, \"action\": \"answer\", \"kind\": \"choice\", \"raw\": null}], \"policy\": \"fixed\", \"recovery\": \"resume\"}\n",
      "Recorded F-250 outcomes: [{\"case_id\": \"F250-00\", \"family\": \"F250\", \"slice\": \"follow_up\", \"question\": \"What is its maximum temperature?\", \"expected\": {\"decision\": \"answer\", \"value\": \"101\", \"evidence\": [\"manual-F-250-r3\"]}, \"response\": {\"decision\": \"answer\", \"value\": \"101\", \"evidence\": [\"manual-F-250-r3\"]}, \"scope\": {\"role\": \"operator\", \"tenant\": \"north-yard\", \"asset\": \"F-250\", \"previous_asset\": \"F-250\", \"previous_version\": \"r3\", \"stale_memory\": false}, \"pass_\": 1, \"unsupported_answer\": false, \"stale_error\": false, \"timeout_planned\": false, \"timeout_injected\": false, \"recovered\": false, \"tool_attempts\": 1, \"decision_calls\": 2, \"stop_reason\": \"submitted\", \"latency_ms\": 0.017330999980913475, \"events\": [{\"turn\": 0, \"action\": \"manual\", \"kind\": \"choice\", \"raw\": null}, {\"turn\": 0, \"action\": \"manual\", \"kind\": \"read\", \"evidence_id\": \"manual-F-250-r3\"}, {\"turn\": 1, \"action\": \"answer\", \"kind\": \"choice\", \"raw\": null}], \"policy\": \"fixed\", \"recovery\": \"resume\"}, {\"case_id\": \"F250-00-stale\", \"family\": \"F250\", \"slice\": \"follow_up\", \"question\": \"What is its maximum temperature?\", \"expected\": {\"decision\": \"clarify\", \"value\": \"\", \"evidence\": []}, \"response\": {\"decision\": \"clarify\", \"value\": \"\", \"evidence\": []}, \"scope\": {\"role\": \"operator\", \"tenant\": \"north-yard\", \"asset\": null, \"previous_asset\": \"F-250\", \"previous_version\": \"r2\", \"stale_memory\": true}, \"pass_\": 1, \"unsupported_answer\": false, \"stale_error\": false, \"timeout_planned\": false, \"timeout_injected\": false, \"recovered\": false, \"tool_attempts\": 0, \"decision_calls\": 1, \"stop_reason\": \"clarify\", \"latency_ms\": 0.006082000254536979, \"events\": [{\"turn\": 0, \"action\": \"clarify\", \"kind\": \"choice\", \"raw\": null}], \"policy\": \"fixed\", \"recovery\": \"resume\"}, {\"case_id\": \"F250-00\", \"family\": \"F250\", \"slice\": \"follow_up\", \"question\": \"What is its maximum temperature?\", \"expected\": {\"decision\": \"answer\", \"value\": \"101\", \"evidence\": [\"manual-F-250-r3\"]}, \"response\": {}, \"scope\": {\"role\": \"operator\", \"tenant\": \"north-yard\", \"asset\": \"F-250\", \"previous_asset\": \"F-250\", \"previous_version\": \"r3\", \"stale_memory\": false}, \"pass_\": 0, \"unsupported_answer\": false, \"stale_error\": false, \"timeout_planned\": false, \"timeout_injected\": false, \"recovered\": false, \"tool_attempts\": 1, \"decision_calls\": 2, \"stop_reason\": \"invalid_or_out_of_scope\", \"latency_ms\": 139.60964499983675, \"events\": [{\"turn\": 0, \"action\": \"manual\", \"kind\": \"choice\", \"raw\": \"M\"}, {\"turn\": 0, \"action\": \"manual\", \"kind\": \"read\", \"evidence_id\": \"manual-F-250-r3\"}, {\"turn\": 1, \"action\": \"manual\", \"kind\": \"choice\", \"raw\": \"M\"}], \"policy\": \"model\", \"recovery\": \"resume\"}, {\"case_id\": \"F250-00-stale\", \"family\": \"F250\", \"slice\": \"follow_up\", \"question\": \"What is its maximum temperature?\", \"expected\": {\"decision\": \"clarify\", \"value\": \"\", \"evidence\": []}, \"response\": {}, \"scope\": {\"role\": \"operator\", \"tenant\": \"north-yard\", \"asset\": null, \"previous_asset\": \"F-250\", \"previous_version\": \"r2\", \"stale_memory\": true}, \"pass_\": 0, \"unsupported_answer\": false, \"stale_error\": true, \"timeout_planned\": false, \"timeout_injected\": false, \"recovered\": false, \"tool_attempts\": 0, \"decision_calls\": 1, \"stop_reason\": \"invalid_or_out_of_scope\", \"latency_ms\": 80.25469499989413, \"events\": [{\"turn\": 0, \"action\": \"manual\", \"kind\": \"choice\", \"raw\": \"M\"}], \"policy\": \"model\", \"recovery\": \"resume\"}]\n",
      "Evidence saved to evidence/summary.json\n",
      "Evidence saved to evidence/records.json\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"591.59952pt\" height=\"269.03952pt\" viewBox=\"0 0 591.59952 269.03952\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2026-11-27T07:23:12.444555</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.10.0, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 269.03952 \n",
       "L 591.59952 269.03952 \n",
       "L 591.59952 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #f5f7f2\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 90.353125 229.48327 \n",
       "L 584.39952 229.48327 \n",
       "L 584.39952 34.3575 \n",
       "L 90.353125 34.3575 \n",
       "z\n",
       "\" style=\"fill: #f5f7f2\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path d=\"M 90.353125 229.48327 \n",
       "L 90.353125 34.3575 \n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\"/>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(87.171875 242.081707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path d=\"M 174.089802 229.48327 \n",
       "L 174.089802 34.3575 \n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\"/>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 20 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(167.727302 242.081707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 257.826479 229.48327 \n",
       "L 257.826479 34.3575 \n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\"/>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 40 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(251.463979 242.081707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 341.563156 229.48327 \n",
       "L 341.563156 34.3575 \n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\"/>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 60 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(335.200656 242.081707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-36\" d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 425.299833 229.48327 \n",
       "L 425.299833 34.3575 \n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\"/>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 80 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(418.937333 242.081707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-38\" d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 509.036511 229.48327 \n",
       "L 509.036511 34.3575 \n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: none; stroke: #d3ded6; stroke-width: 0.75; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\"/>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 100 -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(499.492761 242.081707) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_7\">\n",
       "     <!-- % of cases -->\n",
       "     <g style=\"fill: #20382f\" transform=\"translate(90.353125 259.759832) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-25\" d=\"M 4653 2053 \n",
       "Q 4381 2053 4226 1822 \n",
       "Q 4072 1591 4072 1178 \n",
       "Q 4072 772 4226 539 \n",
       "Q 4381 306 4653 306 \n",
       "Q 4919 306 5073 539 \n",
       "Q 5228 772 5228 1178 \n",
       "Q 5228 1588 5073 1820 \n",
       "Q 4919 2053 4653 2053 \n",
       "z\n",
       "M 4653 2450 \n",
       "Q 5147 2450 5437 2106 \n",
       "Q 5728 1763 5728 1178 \n",
       "Q 5728 594 5436 251 \n",
       "Q 5144 -91 4653 -91 \n",
       "Q 4153 -91 3862 251 \n",
       "Q 3572 594 3572 1178 \n",
       "Q 3572 1766 3864 2108 \n",
       "Q 4156 2450 4653 2450 \n",
       "z\n",
       "M 1428 4353 \n",
       "Q 1159 4353 1004 4120 \n",
       "Q 850 3888 850 3481 \n",
       "Q 850 3069 1003 2837 \n",
       "Q 1156 2606 1428 2606 \n",
       "Q 1700 2606 1854 2837 \n",
       "Q 2009 3069 2009 3481 \n",
       "Q 2009 3884 1853 4118 \n",
       "Q 1697 4353 1428 4353 \n",
       "z\n",
       "M 4250 4750 \n",
       "L 4750 4750 \n",
       "L 1831 -91 \n",
       "L 1331 -91 \n",
       "L 4250 4750 \n",
       "z\n",
       "M 1428 4750 \n",
       "Q 1922 4750 2215 4408 \n",
       "Q 2509 4066 2509 3481 \n",
       "Q 2509 2891 2217 2550 \n",
       "Q 1925 2209 1428 2209 \n",
       "Q 931 2209 642 2551 \n",
       "Q 353 2894 353 3481 \n",
       "Q 353 4063 643 4406 \n",
       "Q 934 4750 1428 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-20\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6f\" d=\"M 1959 3097 \n",
       "Q 1497 3097 1228 2736 \n",
       "Q 959 2375 959 1747 \n",
       "Q 959 1119 1226 758 \n",
       "Q 1494 397 1959 397 \n",
       "Q 2419 397 2687 759 \n",
       "Q 2956 1122 2956 1747 \n",
       "Q 2956 2369 2687 2733 \n",
       "Q 2419 3097 1959 3097 \n",
       "z\n",
       "M 1959 3584 \n",
       "Q 2709 3584 3137 3096 \n",
       "Q 3566 2609 3566 1747 \n",
       "Q 3566 888 3137 398 \n",
       "Q 2709 -91 1959 -91 \n",
       "Q 1206 -91 779 398 \n",
       "Q 353 888 353 1747 \n",
       "Q 353 2609 779 3096 \n",
       "Q 1206 3584 1959 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-66\" d=\"M 2375 4863 \n",
       "L 2375 4384 \n",
       "L 1825 4384 \n",
       "Q 1516 4384 1395 4259 \n",
       "Q 1275 4134 1275 3809 \n",
       "L 1275 3500 \n",
       "L 2222 3500 \n",
       "L 2222 3053 \n",
       "L 1275 3053 \n",
       "L 1275 0 \n",
       "L 697 0 \n",
       "L 697 3053 \n",
       "L 147 3053 \n",
       "L 147 3500 \n",
       "L 697 3500 \n",
       "L 697 3744 \n",
       "Q 697 4328 969 4595 \n",
       "Q 1241 4863 1831 4863 \n",
       "L 2375 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-63\" d=\"M 3122 3366 \n",
       "L 3122 2828 \n",
       "Q 2878 2963 2633 3030 \n",
       "Q 2388 3097 2138 3097 \n",
       "Q 1578 3097 1268 2742 \n",
       "Q 959 2388 959 1747 \n",
       "Q 959 1106 1268 751 \n",
       "Q 1578 397 2138 397 \n",
       "Q 2388 397 2633 464 \n",
       "Q 2878 531 3122 666 \n",
       "L 3122 134 \n",
       "Q 2881 22 2623 -34 \n",
       "Q 2366 -91 2075 -91 \n",
       "Q 1284 -91 818 406 \n",
       "Q 353 903 353 1747 \n",
       "Q 353 2603 823 3093 \n",
       "Q 1294 3584 2113 3584 \n",
       "Q 2378 3584 2631 3529 \n",
       "Q 2884 3475 3122 3366 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-61\" d=\"M 2194 1759 \n",
       "Q 1497 1759 1228 1600 \n",
       "Q 959 1441 959 1056 \n",
       "Q 959 750 1161 570 \n",
       "Q 1363 391 1709 391 \n",
       "Q 2188 391 2477 730 \n",
       "Q 2766 1069 2766 1631 \n",
       "L 2766 1759 \n",
       "L 2194 1759 \n",
       "z\n",
       "M 3341 1997 \n",
       "L 3341 0 \n",
       "L 2766 0 \n",
       "L 2766 531 \n",
       "Q 2569 213 2275 61 \n",
       "Q 1981 -91 1556 -91 \n",
       "Q 1019 -91 701 211 \n",
       "Q 384 513 384 1019 \n",
       "Q 384 1609 779 1909 \n",
       "Q 1175 2209 1959 2209 \n",
       "L 2766 2209 \n",
       "L 2766 2266 \n",
       "Q 2766 2663 2505 2880 \n",
       "Q 2244 3097 1772 3097 \n",
       "Q 1472 3097 1187 3025 \n",
       "Q 903 2953 641 2809 \n",
       "L 641 3341 \n",
       "Q 956 3463 1253 3523 \n",
       "Q 1550 3584 1831 3584 \n",
       "Q 2591 3584 2966 3190 \n",
       "Q 3341 2797 3341 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \n",
       "L 2834 2853 \n",
       "Q 2591 2978 2328 3040 \n",
       "Q 2066 3103 1784 3103 \n",
       "Q 1356 3103 1142 2972 \n",
       "Q 928 2841 928 2578 \n",
       "Q 928 2378 1081 2264 \n",
       "Q 1234 2150 1697 2047 \n",
       "L 1894 2003 \n",
       "Q 2506 1872 2764 1633 \n",
       "Q 3022 1394 3022 966 \n",
       "Q 3022 478 2636 193 \n",
       "Q 2250 -91 1575 -91 \n",
       "Q 1294 -91 989 -36 \n",
       "Q 684 19 347 128 \n",
       "L 347 722 \n",
       "Q 666 556 975 473 \n",
       "Q 1284 391 1588 391 \n",
       "Q 1994 391 2212 530 \n",
       "Q 2431 669 2431 922 \n",
       "Q 2431 1156 2273 1281 \n",
       "Q 2116 1406 1581 1522 \n",
       "L 1381 1569 \n",
       "Q 847 1681 609 1914 \n",
       "Q 372 2147 372 2553 \n",
       "Q 372 3047 722 3315 \n",
       "Q 1072 3584 1716 3584 \n",
       "Q 2034 3584 2315 3537 \n",
       "Q 2597 3491 2834 3397 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-25\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(95.019531 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(126.806641 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-66\" transform=\"translate(187.988281 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(223.193359 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" transform=\"translate(254.980469 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(309.960938 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(371.240234 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(423.339844 0)\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(484.863281 0)\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_13\"/>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- fixed · abort -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(24.785938 60.767323) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-69\" d=\"M 603 3500 \n",
       "L 1178 3500 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 3500 \n",
       "z\n",
       "M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 4134 \n",
       "L 603 4134 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-78\" d=\"M 3513 3500 \n",
       "L 2247 1797 \n",
       "L 3578 0 \n",
       "L 2900 0 \n",
       "L 1881 1375 \n",
       "L 863 0 \n",
       "L 184 0 \n",
       "L 1544 1831 \n",
       "L 300 3500 \n",
       "L 978 3500 \n",
       "L 1906 2253 \n",
       "L 2834 3500 \n",
       "L 3513 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-64\" d=\"M 2906 2969 \n",
       "L 2906 4863 \n",
       "L 3481 4863 \n",
       "L 3481 0 \n",
       "L 2906 0 \n",
       "L 2906 525 \n",
       "Q 2725 213 2448 61 \n",
       "Q 2172 -91 1784 -91 \n",
       "Q 1150 -91 751 415 \n",
       "Q 353 922 353 1747 \n",
       "Q 353 2572 751 3078 \n",
       "Q 1150 3584 1784 3584 \n",
       "Q 2172 3584 2448 3432 \n",
       "Q 2725 3281 2906 2969 \n",
       "z\n",
       "M 947 1747 \n",
       "Q 947 1113 1208 752 \n",
       "Q 1469 391 1925 391 \n",
       "Q 2381 391 2643 752 \n",
       "Q 2906 1113 2906 1747 \n",
       "Q 2906 2381 2643 2742 \n",
       "Q 2381 3103 1925 3103 \n",
       "Q 1469 3103 1208 2742 \n",
       "Q 947 2381 947 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-b7\" d=\"M 684 2619 \n",
       "L 1344 2619 \n",
       "L 1344 1825 \n",
       "L 684 1825 \n",
       "L 684 2619 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-62\" d=\"M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "M 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2969 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-72\" d=\"M 2631 2963 \n",
       "Q 2534 3019 2420 3045 \n",
       "Q 2306 3072 2169 3072 \n",
       "Q 1681 3072 1420 2755 \n",
       "Q 1159 2438 1159 1844 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1341 3275 1631 3429 \n",
       "Q 1922 3584 2338 3584 \n",
       "Q 2397 3584 2469 3576 \n",
       "Q 2541 3569 2628 3553 \n",
       "L 2631 2963 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-74\" d=\"M 1172 4494 \n",
       "L 1172 3500 \n",
       "L 2356 3500 \n",
       "L 2356 3053 \n",
       "L 1172 3053 \n",
       "L 1172 1153 \n",
       "Q 1172 725 1289 603 \n",
       "Q 1406 481 1766 481 \n",
       "L 2356 481 \n",
       "L 2356 0 \n",
       "L 1766 0 \n",
       "Q 1100 0 847 248 \n",
       "Q 594 497 594 1153 \n",
       "L 594 3053 \n",
       "L 172 3053 \n",
       "L 172 3500 \n",
       "L 594 3500 \n",
       "L 594 4494 \n",
       "L 1172 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-69\" transform=\"translate(35.205078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-78\" transform=\"translate(62.988281 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(119.042969 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(180.566406 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(244.042969 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-b7\" transform=\"translate(275.830078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(307.617188 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(339.404297 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(400.683594 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(464.160156 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(525.341797 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(566.455078 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_14\"/>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- fixed · resume -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(13.932812 110.73551) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-75\" d=\"M 544 1381 \n",
       "L 544 3500 \n",
       "L 1119 3500 \n",
       "L 1119 1403 \n",
       "Q 1119 906 1312 657 \n",
       "Q 1506 409 1894 409 \n",
       "Q 2359 409 2629 706 \n",
       "Q 2900 1003 2900 1516 \n",
       "L 2900 3500 \n",
       "L 3475 3500 \n",
       "L 3475 0 \n",
       "L 2900 0 \n",
       "L 2900 538 \n",
       "Q 2691 219 2414 64 \n",
       "Q 2138 -91 1772 -91 \n",
       "Q 1169 -91 856 284 \n",
       "Q 544 659 544 1381 \n",
       "z\n",
       "M 1991 3584 \n",
       "L 1991 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-6d\" d=\"M 3328 2828 \n",
       "Q 3544 3216 3844 3400 \n",
       "Q 4144 3584 4550 3584 \n",
       "Q 5097 3584 5394 3201 \n",
       "Q 5691 2819 5691 2113 \n",
       "L 5691 0 \n",
       "L 5113 0 \n",
       "L 5113 2094 \n",
       "Q 5113 2597 4934 2840 \n",
       "Q 4756 3084 4391 3084 \n",
       "Q 3944 3084 3684 2787 \n",
       "Q 3425 2491 3425 1978 \n",
       "L 3425 0 \n",
       "L 2847 0 \n",
       "L 2847 2094 \n",
       "Q 2847 2600 2669 2842 \n",
       "Q 2491 3084 2119 3084 \n",
       "Q 1678 3084 1418 2786 \n",
       "Q 1159 2488 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1356 3278 1631 3431 \n",
       "Q 1906 3584 2284 3584 \n",
       "Q 2666 3584 2933 3390 \n",
       "Q 3200 3197 3328 2828 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-66\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-69\" transform=\"translate(35.205078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-78\" transform=\"translate(62.988281 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(119.042969 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(180.566406 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(244.042969 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-b7\" transform=\"translate(275.830078 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(307.617188 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(339.404297 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(378.267578 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(439.791016 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-75\" transform=\"translate(491.890625 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6d\" transform=\"translate(555.269531 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(652.681641 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_15\"/>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- model · abort -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(18.053125 160.703697) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-6d\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(97.412109 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(158.59375 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(222.070312 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6c\" transform=\"translate(283.59375 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(311.376953 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-b7\" transform=\"translate(343.164062 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(374.951172 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-61\" transform=\"translate(406.738281 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-62\" transform=\"translate(468.017578 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(531.494141 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(592.675781 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-74\" transform=\"translate(633.789062 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_16\"/>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- model · resume -->\n",
       "      <g style=\"fill: #20382f\" transform=\"translate(7.2 210.671884) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-6d\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6f\" transform=\"translate(97.412109 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-64\" transform=\"translate(158.59375 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(222.070312 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6c\" transform=\"translate(283.59375 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(311.376953 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-b7\" transform=\"translate(343.164062 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-20\" transform=\"translate(374.951172 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-72\" transform=\"translate(406.738281 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(445.601562 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-73\" transform=\"translate(507.125 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-75\" transform=\"translate(559.224609 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-6d\" transform=\"translate(622.603516 0)\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-65\" transform=\"translate(720.015625 0)\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 90.353125 43.226853 \n",
       "L 462.516134 43.226853 \n",
       "L 462.516134 70.709356 \n",
       "L 90.353125 70.709356 \n",
       "z\n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: #3d6b5b\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 90.353125 93.19504 \n",
       "L 509.036511 93.19504 \n",
       "L 509.036511 120.677543 \n",
       "L 90.353125 120.677543 \n",
       "z\n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: #298876\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 90.353125 143.163227 \n",
       "L 160.133689 143.163227 \n",
       "L 160.133689 170.64573 \n",
       "L 90.353125 170.64573 \n",
       "z\n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: #7b97a2\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 90.353125 193.131414 \n",
       "L 160.133689 193.131414 \n",
       "L 160.133689 220.613917 \n",
       "L 90.353125 220.613917 \n",
       "z\n",
       "\" clip-path=\"url(#p9185bc4d0d)\" style=\"fill: #9c6951\"/>\n",
       "   </g>\n",
       "   <g id=\"text_12\">\n",
       "    <!-- 88.9 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(468.516134 59.72748) scale(0.1 -0.1)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-39\" d=\"M 703 97 \n",
       "L 703 672 \n",
       "Q 941 559 1184 500 \n",
       "Q 1428 441 1663 441 \n",
       "Q 2288 441 2617 861 \n",
       "Q 2947 1281 2994 2138 \n",
       "Q 2813 1869 2534 1725 \n",
       "Q 2256 1581 1919 1581 \n",
       "Q 1219 1581 811 2004 \n",
       "Q 403 2428 403 3163 \n",
       "Q 403 3881 828 4315 \n",
       "Q 1253 4750 1959 4750 \n",
       "Q 2769 4750 3195 4129 \n",
       "Q 3622 3509 3622 2328 \n",
       "Q 3622 1225 3098 567 \n",
       "Q 2575 -91 1691 -91 \n",
       "Q 1453 -91 1209 -44 \n",
       "Q 966 3 703 97 \n",
       "z\n",
       "M 1959 2075 \n",
       "Q 2384 2075 2632 2365 \n",
       "Q 2881 2656 2881 3163 \n",
       "Q 2881 3666 2632 3958 \n",
       "Q 2384 4250 1959 4250 \n",
       "Q 1534 4250 1286 3958 \n",
       "Q 1038 3666 1038 3163 \n",
       "Q 1038 2656 1286 2365 \n",
       "Q 1534 2075 1959 2075 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-38\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(127.246094 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-39\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_13\">\n",
       "    <!-- 100 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(515.036511 109.695667) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-30\" transform=\"translate(127.246094 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_14\">\n",
       "    <!-- 16.7 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(166.133689 159.663853) scale(0.1 -0.1)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(127.246094 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-37\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_15\">\n",
       "    <!-- 16.7 -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(166.133689 209.63204) scale(0.1 -0.1)\">\n",
       "     <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-36\" transform=\"translate(63.623047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" transform=\"translate(127.246094 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-37\" transform=\"translate(159.033203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"text_16\">\n",
       "    <!-- Verified goal completion by workflow -->\n",
       "    <g style=\"fill: #20382f\" transform=\"translate(90.353125 19.3575) scale(0.16 -0.16)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-Bold-56\" d=\"M 31 4666 \n",
       "L 1241 4666 \n",
       "L 2478 1222 \n",
       "L 3713 4666 \n",
       "L 4922 4666 \n",
       "L 3194 0 \n",
       "L 1759 0 \n",
       "L 31 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-65\" d=\"M 4031 1759 \n",
       "L 4031 1441 \n",
       "L 1416 1441 \n",
       "Q 1456 1047 1700 850 \n",
       "Q 1944 653 2381 653 \n",
       "Q 2734 653 3104 758 \n",
       "Q 3475 863 3866 1075 \n",
       "L 3866 213 \n",
       "Q 3469 63 3072 -14 \n",
       "Q 2675 -91 2278 -91 \n",
       "Q 1328 -91 801 392 \n",
       "Q 275 875 275 1747 \n",
       "Q 275 2603 792 3093 \n",
       "Q 1309 3584 2216 3584 \n",
       "Q 3041 3584 3536 3087 \n",
       "Q 4031 2591 4031 1759 \n",
       "z\n",
       "M 2881 2131 \n",
       "Q 2881 2450 2695 2645 \n",
       "Q 2509 2841 2209 2841 \n",
       "Q 1884 2841 1681 2658 \n",
       "Q 1478 2475 1428 2131 \n",
       "L 2881 2131 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-72\" d=\"M 3138 2547 \n",
       "Q 2991 2616 2845 2648 \n",
       "Q 2700 2681 2553 2681 \n",
       "Q 2122 2681 1889 2404 \n",
       "Q 1656 2128 1656 1613 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2925 \n",
       "Q 1872 3269 2151 3426 \n",
       "Q 2431 3584 2822 3584 \n",
       "Q 2878 3584 2943 3579 \n",
       "Q 3009 3575 3134 3559 \n",
       "L 3138 2547 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-69\" d=\"M 538 3500 \n",
       "L 1656 3500 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 3500 \n",
       "z\n",
       "M 538 4863 \n",
       "L 1656 4863 \n",
       "L 1656 3950 \n",
       "L 538 3950 \n",
       "L 538 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-66\" d=\"M 2841 4863 \n",
       "L 2841 4128 \n",
       "L 2222 4128 \n",
       "Q 1984 4128 1890 4042 \n",
       "Q 1797 3956 1797 3744 \n",
       "L 1797 3500 \n",
       "L 2753 3500 \n",
       "L 2753 2700 \n",
       "L 1797 2700 \n",
       "L 1797 0 \n",
       "L 678 0 \n",
       "L 678 2700 \n",
       "L 122 2700 \n",
       "L 122 3500 \n",
       "L 678 3500 \n",
       "L 678 3744 \n",
       "Q 678 4316 997 4589 \n",
       "Q 1316 4863 1984 4863 \n",
       "L 2841 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-64\" d=\"M 2919 2988 \n",
       "L 2919 4863 \n",
       "L 4044 4863 \n",
       "L 4044 0 \n",
       "L 2919 0 \n",
       "L 2919 506 \n",
       "Q 2688 197 2409 53 \n",
       "Q 2131 -91 1766 -91 \n",
       "Q 1119 -91 703 423 \n",
       "Q 288 938 288 1747 \n",
       "Q 288 2556 703 3070 \n",
       "Q 1119 3584 1766 3584 \n",
       "Q 2128 3584 2408 3439 \n",
       "Q 2688 3294 2919 2988 \n",
       "z\n",
       "M 2181 722 \n",
       "Q 2541 722 2730 984 \n",
       "Q 2919 1247 2919 1747 \n",
       "Q 2919 2247 2730 2509 \n",
       "Q 2541 2772 2181 2772 \n",
       "Q 1825 2772 1636 2509 \n",
       "Q 1447 2247 1447 1747 \n",
       "Q 1447 1247 1636 984 \n",
       "Q 1825 722 2181 722 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-20\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-67\" d=\"M 2919 594 \n",
       "Q 2688 288 2409 144 \n",
       "Q 2131 0 1766 0 \n",
       "Q 1125 0 706 504 \n",
       "Q 288 1009 288 1791 \n",
       "Q 288 2575 706 3076 \n",
       "Q 1125 3578 1766 3578 \n",
       "Q 2131 3578 2409 3434 \n",
       "Q 2688 3291 2919 2981 \n",
       "L 2919 3500 \n",
       "L 4044 3500 \n",
       "L 4044 353 \n",
       "Q 4044 -491 3511 -936 \n",
       "Q 2978 -1381 1966 -1381 \n",
       "Q 1638 -1381 1331 -1331 \n",
       "Q 1025 -1281 716 -1178 \n",
       "L 716 -306 \n",
       "Q 1009 -475 1290 -558 \n",
       "Q 1572 -641 1856 -641 \n",
       "Q 2406 -641 2662 -400 \n",
       "Q 2919 -159 2919 353 \n",
       "L 2919 594 \n",
       "z\n",
       "M 2181 2772 \n",
       "Q 1834 2772 1640 2515 \n",
       "Q 1447 2259 1447 1791 \n",
       "Q 1447 1309 1634 1061 \n",
       "Q 1822 813 2181 813 \n",
       "Q 2531 813 2725 1069 \n",
       "Q 2919 1325 2919 1791 \n",
       "Q 2919 2259 2725 2515 \n",
       "Q 2531 2772 2181 2772 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6f\" d=\"M 2203 2784 \n",
       "Q 1831 2784 1636 2517 \n",
       "Q 1441 2250 1441 1747 \n",
       "Q 1441 1244 1636 976 \n",
       "Q 1831 709 2203 709 \n",
       "Q 2569 709 2762 976 \n",
       "Q 2956 1244 2956 1747 \n",
       "Q 2956 2250 2762 2517 \n",
       "Q 2569 2784 2203 2784 \n",
       "z\n",
       "M 2203 3584 \n",
       "Q 3106 3584 3614 3096 \n",
       "Q 4122 2609 4122 1747 \n",
       "Q 4122 884 3614 396 \n",
       "Q 3106 -91 2203 -91 \n",
       "Q 1297 -91 786 396 \n",
       "Q 275 884 275 1747 \n",
       "Q 275 2609 786 3096 \n",
       "Q 1297 3584 2203 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-61\" d=\"M 2106 1575 \n",
       "Q 1756 1575 1579 1456 \n",
       "Q 1403 1338 1403 1106 \n",
       "Q 1403 894 1545 773 \n",
       "Q 1688 653 1941 653 \n",
       "Q 2256 653 2472 879 \n",
       "Q 2688 1106 2688 1447 \n",
       "L 2688 1575 \n",
       "L 2106 1575 \n",
       "z\n",
       "M 3816 1997 \n",
       "L 3816 0 \n",
       "L 2688 0 \n",
       "L 2688 519 \n",
       "Q 2463 200 2181 54 \n",
       "Q 1900 -91 1497 -91 \n",
       "Q 953 -91 614 226 \n",
       "Q 275 544 275 1050 \n",
       "Q 275 1666 698 1953 \n",
       "Q 1122 2241 2028 2241 \n",
       "L 2688 2241 \n",
       "L 2688 2328 \n",
       "Q 2688 2594 2478 2717 \n",
       "Q 2269 2841 1825 2841 \n",
       "Q 1466 2841 1156 2769 \n",
       "Q 847 2697 581 2553 \n",
       "L 581 3406 \n",
       "Q 941 3494 1303 3539 \n",
       "Q 1666 3584 2028 3584 \n",
       "Q 2975 3584 3395 3211 \n",
       "Q 3816 2838 3816 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6c\" d=\"M 538 4863 \n",
       "L 1656 4863 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-63\" d=\"M 3366 3391 \n",
       "L 3366 2478 \n",
       "Q 3138 2634 2908 2709 \n",
       "Q 2678 2784 2431 2784 \n",
       "Q 1963 2784 1702 2511 \n",
       "Q 1441 2238 1441 1747 \n",
       "Q 1441 1256 1702 982 \n",
       "Q 1963 709 2431 709 \n",
       "Q 2694 709 2930 787 \n",
       "Q 3166 866 3366 1019 \n",
       "L 3366 103 \n",
       "Q 3103 6 2833 -42 \n",
       "Q 2563 -91 2291 -91 \n",
       "Q 1344 -91 809 395 \n",
       "Q 275 881 275 1747 \n",
       "Q 275 2613 809 3098 \n",
       "Q 1344 3584 2291 3584 \n",
       "Q 2566 3584 2833 3536 \n",
       "Q 3100 3488 3366 3391 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6d\" d=\"M 3781 2919 \n",
       "Q 3994 3244 4286 3414 \n",
       "Q 4578 3584 4928 3584 \n",
       "Q 5531 3584 5847 3212 \n",
       "Q 6163 2841 6163 2131 \n",
       "L 6163 0 \n",
       "L 5038 0 \n",
       "L 5038 1825 \n",
       "Q 5041 1866 5042 1909 \n",
       "Q 5044 1953 5044 2034 \n",
       "Q 5044 2406 4934 2573 \n",
       "Q 4825 2741 4581 2741 \n",
       "Q 4263 2741 4089 2478 \n",
       "Q 3916 2216 3909 1719 \n",
       "L 3909 0 \n",
       "L 2784 0 \n",
       "L 2784 1825 \n",
       "Q 2784 2406 2684 2573 \n",
       "Q 2584 2741 2328 2741 \n",
       "Q 2006 2741 1831 2477 \n",
       "Q 1656 2213 1656 1722 \n",
       "L 1656 0 \n",
       "L 531 0 \n",
       "L 531 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2988 \n",
       "Q 1863 3284 2130 3434 \n",
       "Q 2397 3584 2719 3584 \n",
       "Q 3081 3584 3359 3409 \n",
       "Q 3638 3234 3781 2919 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-70\" d=\"M 1656 506 \n",
       "L 1656 -1331 \n",
       "L 538 -1331 \n",
       "L 538 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2988 \n",
       "Q 1888 3294 2169 3439 \n",
       "Q 2450 3584 2816 3584 \n",
       "Q 3463 3584 3878 3070 \n",
       "Q 4294 2556 4294 1747 \n",
       "Q 4294 938 3878 423 \n",
       "Q 3463 -91 2816 -91 \n",
       "Q 2450 -91 2169 54 \n",
       "Q 1888 200 1656 506 \n",
       "z\n",
       "M 2400 2772 \n",
       "Q 2041 2772 1848 2508 \n",
       "Q 1656 2244 1656 1747 \n",
       "Q 1656 1250 1848 986 \n",
       "Q 2041 722 2400 722 \n",
       "Q 2759 722 2948 984 \n",
       "Q 3138 1247 3138 1747 \n",
       "Q 3138 2247 2948 2509 \n",
       "Q 2759 2772 2400 2772 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-74\" d=\"M 1759 4494 \n",
       "L 1759 3500 \n",
       "L 2913 3500 \n",
       "L 2913 2700 \n",
       "L 1759 2700 \n",
       "L 1759 1216 \n",
       "Q 1759 972 1856 886 \n",
       "Q 1953 800 2241 800 \n",
       "L 2816 800 \n",
       "L 2816 0 \n",
       "L 1856 0 \n",
       "Q 1194 0 917 276 \n",
       "Q 641 553 641 1216 \n",
       "L 641 2700 \n",
       "L 84 2700 \n",
       "L 84 3500 \n",
       "L 641 3500 \n",
       "L 641 4494 \n",
       "L 1759 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6e\" d=\"M 4056 2131 \n",
       "L 4056 0 \n",
       "L 2931 0 \n",
       "L 2931 347 \n",
       "L 2931 1631 \n",
       "Q 2931 2084 2911 2256 \n",
       "Q 2891 2428 2841 2509 \n",
       "Q 2775 2619 2662 2680 \n",
       "Q 2550 2741 2406 2741 \n",
       "Q 2056 2741 1856 2470 \n",
       "Q 1656 2200 1656 1722 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 3500 \n",
       "L 1656 3500 \n",
       "L 1656 2988 \n",
       "Q 1909 3294 2193 3439 \n",
       "Q 2478 3584 2822 3584 \n",
       "Q 3428 3584 3742 3212 \n",
       "Q 4056 2841 4056 2131 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-62\" d=\"M 2400 722 \n",
       "Q 2759 722 2948 984 \n",
       "Q 3138 1247 3138 1747 \n",
       "Q 3138 2247 2948 2509 \n",
       "Q 2759 2772 2400 2772 \n",
       "Q 2041 2772 1848 2508 \n",
       "Q 1656 2244 1656 1747 \n",
       "Q 1656 1250 1848 986 \n",
       "Q 2041 722 2400 722 \n",
       "z\n",
       "M 1656 2988 \n",
       "Q 1888 3294 2169 3439 \n",
       "Q 2450 3584 2816 3584 \n",
       "Q 3463 3584 3878 3070 \n",
       "Q 4294 2556 4294 1747 \n",
       "Q 4294 938 3878 423 \n",
       "Q 3463 -91 2816 -91 \n",
       "Q 2450 -91 2169 54 \n",
       "Q 1888 200 1656 506 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 4863 \n",
       "L 1656 4863 \n",
       "L 1656 2988 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-79\" d=\"M 78 3500 \n",
       "L 1197 3500 \n",
       "L 2138 1125 \n",
       "L 2938 3500 \n",
       "L 4056 3500 \n",
       "L 2584 -331 \n",
       "Q 2363 -916 2067 -1148 \n",
       "Q 1772 -1381 1288 -1381 \n",
       "L 641 -1381 \n",
       "L 641 -647 \n",
       "L 991 -647 \n",
       "Q 1275 -647 1404 -556 \n",
       "Q 1534 -466 1606 -231 \n",
       "L 1638 -134 \n",
       "L 78 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-77\" d=\"M 225 3500 \n",
       "L 1313 3500 \n",
       "L 1900 1088 \n",
       "L 2491 3500 \n",
       "L 3425 3500 \n",
       "L 4013 1113 \n",
       "L 4603 3500 \n",
       "L 5691 3500 \n",
       "L 4769 0 \n",
       "L 3547 0 \n",
       "L 2956 2406 \n",
       "L 2369 0 \n",
       "L 1147 0 \n",
       "L 225 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-Bold-6b\" d=\"M 538 4863 \n",
       "L 1656 4863 \n",
       "L 1656 2216 \n",
       "L 2944 3500 \n",
       "L 4244 3500 \n",
       "L 2534 1894 \n",
       "L 4378 0 \n",
       "L 3022 0 \n",
       "L 1656 1459 \n",
       "L 1656 0 \n",
       "L 538 0 \n",
       "L 538 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-56\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-65\" transform=\"translate(71.892578 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-72\" transform=\"translate(139.714844 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-69\" transform=\"translate(189.03125 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-66\" transform=\"translate(223.308594 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-69\" transform=\"translate(266.814453 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-65\" transform=\"translate(301.091797 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-64\" transform=\"translate(368.914062 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(440.496094 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-67\" transform=\"translate(475.310547 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(546.892578 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-61\" transform=\"translate(615.59375 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6c\" transform=\"translate(683.074219 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(717.351562 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-63\" transform=\"translate(752.166016 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(811.443359 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6d\" transform=\"translate(880.144531 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-70\" transform=\"translate(984.34375 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6c\" transform=\"translate(1055.925781 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-65\" transform=\"translate(1090.203125 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-74\" transform=\"translate(1158.025391 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-69\" transform=\"translate(1205.828125 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(1240.105469 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6e\" transform=\"translate(1308.806641 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(1379.998047 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-62\" transform=\"translate(1414.8125 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-79\" transform=\"translate(1486.394531 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-20\" transform=\"translate(1551.580078 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-77\" transform=\"translate(1586.394531 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(1678.777344 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-72\" transform=\"translate(1747.478516 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6b\" transform=\"translate(1796.794922 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-66\" transform=\"translate(1863.298828 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6c\" transform=\"translate(1906.804688 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-6f\" transform=\"translate(1941.082031 0)\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-Bold-77\" transform=\"translate(2009.783203 0)\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p9185bc4d0d\">\n",
       "   <rect x=\"90.353125\" y=\"34.3575\" width=\"494.046395\" height=\"195.12577\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 810x362 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "if COURSE_SMOKE:\n",
    "    def choose_model(case, scope, observations):\n",
    "        fixture_label = next(key for key, action in ACTIONS.items() if action == fixed_graph(case, scope, observations))\n",
    "        return model_action(case, scope, observations, lambda _prompt: fixture_label)\n",
    "\n",
    "    load_seconds = None\n",
    "else:\n",
    "    load_started = perf_counter()\n",
    "    action_tokenizer, action_model = load_text()\n",
    "    sync()\n",
    "    load_seconds = perf_counter() - load_started\n",
    "    def infer_action(prompt):\n",
    "        sync()\n",
    "        raw = generate(action_tokenizer, action_model, [prompt], max_new_tokens=TOKEN_LIMIT)[0]\n",
    "        sync()\n",
    "        return raw\n",
    "\n",
    "    def choose_model(case, scope, observations):\n",
    "        return model_action(case, scope, observations, infer_action)\n",
    "\n",
    "rows = compare_workflows({\"fixed\": fixed_choice, \"model\": choose_model}, workflow_cases)\n",
    "outcomes, paired_strict, follow_ups = workflow_summary(rows)\n",
    "assert not any(row[\"tool_attempts\"] or row[\"decision_calls\"] for row in rows if row[\"slice\"] == \"boundary\")\n",
    "assert all(row[\"tool_attempts\"] <= CALL_LIMIT and row[\"decision_calls\"] <= TURN_LIMIT for row in rows)\n",
    "summary = dict(\n",
    "    mode=\"fixture\" if COURSE_SMOKE else \"measured\",\n",
    "    settings=dict(\n",
    "        development_sha256=SPLIT_MANIFEST[\"dev\"][\"sha256\"], selected_variants=sorted(VARIANTS),\n",
    "        base_case_count=len(primary_cases), stale_pair_count=len(follow_up_pairs),\n",
    "        turn_limit=TURN_LIMIT, tool_call_limit=CALL_LIMIT, max_new_tokens_per_choice=TOKEN_LIMIT,\n",
    "        checkpoint=MODEL_IDS[\"text\"], model_load_s=load_seconds,\n",
    "    ),\n",
    "    outcomes=outcomes, paired_strict=paired_strict, follow_ups=follow_ups,\n",
    ")\n",
    "trace_case = next(row for row in rows if row[\"policy\"] == \"fixed\" and row[\"recovered\"] and row[\"slice\"] == \"multi_source\")\n",
    "print(\"Paired completion and costs:\", json.dumps(summary, indent=2))\n",
    "print(\"Recorded timeout and resume:\", json.dumps(trace_case, ensure_ascii=False))\n",
    "print(\"Recorded F-250 outcomes:\", json.dumps([\n",
    "    row for row in rows if row[\"case_id\"] in {current[\"id\"], stale[\"id\"]} and row[\"recovery\"] == \"resume\"\n",
    "], ensure_ascii=False))\n",
    "save(\"summary\", summary)\n",
    "save(\"records\", {\n",
    "    \"opening\": opening,\n",
    "    \"decisions\": rows,\n",
    "    \"scope_probe\": {\n",
    "        \"case_id\": example[\"id\"], \"question\": example[\"question\"], \"asset\": example[\"asset\"],\n",
    "        \"tenant\": example[\"tenant\"], \"other_tenant\": other_tenant, \"read_allowed\": scope_checks,\n",
    "    },\n",
    "    \"invalid_enum\": invalid,\n",
    "})\n",
    "\n",
    "if COURSE_SMOKE:\n",
    "    assert all(row[\"latency_ms\"] is None for row in rows)\n",
    "    assert all(row[\"pass_\"] for row in rows if row[\"scope\"][\"stale_memory\"])\n",
    "    assert [event[\"kind\"] for event in trace_case[\"events\"]] == [\n",
    "        \"choice\", \"read\", \"choice\", \"timeout\", \"resume\", \"read\", \"choice\",\n",
    "    ]\n",
    "    assert trace_case[\"tool_attempts\"] == 3 and trace_case[\"decision_calls\"] == 3\n",
    "    print(\"SMOKE OK\")\n",
    "else:\n",
    "    headline = [row for row in outcomes if row[\"cohort\"] == \"selected_dev\"]\n",
    "    chart(\n",
    "        \"Verified goal completion by workflow\",\n",
    "        [f\"{row['policy']} · {row['recovery']}\" for row in headline],\n",
    "        [100 * row[\"strict_passes\"] / row[\"n\"] for row in headline],\n",
    "        \"% of cases\",\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-25",
   "metadata": {},
   "source": [
    "### Read the result\n",
    "\n",
    "Select the policy for the case slices where it helps. Extend the experiment\n",
    "with two timeouts in one request, and state which budget you would change\n",
    "before running it. Verify that the authority rules stay identical. Return to\n",
    "the [lesson](https://docs.recohut.com/courses/advanced-ai-systems-engineering/3-connect-tools-and-inputs/08-bound-a-model-led-workflow)\n",
    "for the measured comparison."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lab-08-26",
   "metadata": {},
   "source": [
    "## Read the result\n",
    "\n",
    "Inspect the per-case records in `evidence/` before drawing a conclusion from an aggregate. Use the printed sample size, split and hardware when comparing it with another run.\n",
    "\n",
    "- [ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629)\n",
    "- [MemGPT: Towards LLMs as Operating Systems](https://arxiv.org/abs/2310.08560)"
   ]
  }
 ],
 "metadata": {
  "course": {
   "lab": 8,
   "slug": "08-bound-a-model-led-workflow"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
