{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "175472c63ff4",
   "metadata": {},
   "source": [
    "# Chapter 18: When an Action Has Coordinates\n",
    "\n",
    "A release button moves after the controller observes the page. The old coordinates now point to delete. The controller can still issue a perfectly formed click, but the effect boundary has changed. The mistake is not explained by text prediction alone; it belongs to observation age, layout state, and action targeting.\n",
    "\n",
    "This notebook represents three interfaces. Coordinate action uses the current object at an old location. Semantic action uses the resolved object identifier. Version-bound action also checks that the observed and current layouts match. All three still require freshness and current permission. The experiment distinguishes issuing an action, hitting the intended target, and confirming completion.\n",
    "\n",
    "**Outcome:** Compare coordinate, semantic, and version-bound action contracts.\n",
    "\n",
    "- Inspect the declared input contract\n",
    "- Predict the hand-checkable case\n",
    "- Run the shared computation\n",
    "- Change the critical assumption\n",
    "- Apply the method to the transfer data\n",
    "\n",
    "**Guided route:** Run the worked calculation, inspect its figure, change the stated assumption, and try the transfer case. Read the explanations beside each result before opening the answers.\n",
    "\n",
    "**Deeper route:** First read the mathematics and canonical equation reference. Audit the input contract, predict the changed result, then inspect the shared chapter implementation and solve the questions independently. Both routes use the same calculations and preserve the equations."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7781f3ee7dc",
   "metadata": {},
   "source": [
    "## Technical Requirements\n",
    "\n",
    "Python 3.11 or later, the complete laboratory folder, and the notebook dependencies listed in `requirements-notebooks.txt` (the launcher's **Install notebook tools** choice installs them; see START-HERE). Standard-library chapter commands also support Python 3.10. No API key, model account or network call is used by this experiment.\n",
    "\n",
    "Prior knowledge:\n",
    "\n",
    "- Python lists and dictionaries\n",
    "- The mapped chapter and its notation"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9cd9cae5414",
   "metadata": {},
   "source": [
    "## The question and its mathematics\n",
    "\n",
    "Let age be observation age and tau the maximum permitted age. Freshness is F=1{age<=tau}. Current authorization is A. Target correctness is T=1{resolved target=wanted target}. Version validity is V=1{observed version=current version} for the version-bound interface.\n",
    "\n",
    "For coordinate and semantic methods, issuance is F and A under this simplified contract. For version-bound action it is F and A and V. Authorized confirmed completion additionally requires target correctness and an effect-confirmation flag. Those predicates represent different evidence: an issued request can be wrong, and a correct target can still lack confirmation.\n",
    "\n",
    "The coordinate method deliberately has no semantic identity check before issuance. The semantic method avoids the particular moved-location failure but can still resolve the wrong object. Version binding rejects a changed layout rather than guessing whether the old observation remains sufficient. Age and version are separate: a recent observation can already be obsolete, and an old observation may describe an unchanged layout."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c16c2a5853bb",
   "metadata": {},
   "source": [
    "## A calculation you can run\n",
    "\n",
    "Supply age, freshness limit, observed and current versions, current permission, effect confirmation, and target identifiers. Exact boolean checks keep authorization and confirmation distinct from truthy strings. The function emits one row per interface with freshness, version match, authorization, issuance, target correctness, and confirmed completion.\n",
    "\n",
    "Two figures compare issued actions and confirmed completions. Their difference is operationally important; a higher issuance bar does not imply better behavior. Run the default layout-change case, then increase only observation age beyond the limit. Predict which interfaces will refuse issuance. The transfer case removes permission while preserving fresh, matching observations, checking that a stable interface cannot manufacture authority.\n",
    "\n",
    "For a visual version of the stale-coordinate example, open the [release console](../Companion/release-console.html) in a browser. It is a local mock-up whose effects stay inside the page.\n",
    "\n",
    "The next cell finds the bundle and imports the same computation used by the chapter skill. It does not change your system Python."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "42ebefc0e5c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path\n",
    "import sys, json\n",
    "LAB_ROOT = next((p for p in [Path.cwd(), *Path.cwd().parents] if (p / \"lab-manifest.json\").is_file()), None)\n",
    "if LAB_ROOT is None:\n",
    "    raise RuntimeError(\"Open this notebook from the complete extracted laboratory folder.\")\n",
    "sys.path.insert(0, str(LAB_ROOT / \"src\"))\n",
    "from math_ai_agents.core import analyze, report_text\n",
    "from math_ai_agents.plotting import figure_svg\n",
    "from IPython.display import SVG, display\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7fffde8c0edb",
   "metadata": {},
   "source": [
    "Set the declared inputs below. These are constructed teaching values, not measurements from a production agent. Change a value only after predicting what it should change."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d1a364d9b4f8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Chapter 18: interface-freshness\n",
      "Does an observed interface still support an authorized action at the intended target?\n",
      "Evidence: constructed teaching example\n",
      "\n",
      "Calculated quantities:\n",
      "{\n",
      "  \"methods\": [\n",
      "    {\n",
      "      \"method\": \"coordinate\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": true,\n",
      "      \"issued\": true,\n",
      "      \"correct_target\": false,\n",
      "      \"confirmed_completion\": false\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"semantic\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": true,\n",
      "      \"issued\": true,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": true\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"version-bound\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": false,\n",
      "      \"authorized\": true,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    }\n",
      "  ],\n",
      "  \"stale_observation\": false,\n",
      "  \"layout_changed\": true,\n",
      "  \"change_rate\": 0.02,\n",
      "  \"freshness_probability_at_age\": 0.9801986733,\n",
      "  \"freshness_probability_at_max_age\": 0.9607894392,\n",
      "  \"freshness_by_delay\": [\n",
      "    {\n",
      "      \"delay\": 5.0,\n",
      "      \"freshness_probability\": 0.904837418\n",
      "    },\n",
      "    {\n",
      "      \"delay\": 15.0,\n",
      "      \"freshness_probability\": 0.7408182207\n",
      "    },\n",
      "    {\n",
      "      \"delay\": 30.0,\n",
      "      \"freshness_probability\": 0.5488116361\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "Interpretation:\n",
      "Coordinates name a location; semantic targets name an object; a version-bound action also refuses a changed observation boundary. Current permission is checked at issuance.\n",
      "\n",
      "Assumptions:\n",
      "- Targets and current permission are supplied observations.\n",
      "- Freshness uses the declared age limit.\n",
      "- If change_rate is supplied, Fresh(delay)=exp(-change_rate*delay) assumes invalidating changes arrive at a constant rate; it is reported beside, and does not replace, the age-limit rule.\n",
      "\n",
      "Limitations:\n",
      "- Semantic resolution can itself be wrong.\n",
      "- A click or issued request is not confirmation of its effect.\n",
      "\n",
      "Execution: completed locally; constructed inputs are not deployment measurements.\n"
     ]
    }
   ],
   "source": [
    "chapter = 18\n",
    "inputs = {'observation_age': 1,\n",
    " 'max_age': 2,\n",
    " 'observed_version': 'layout-1',\n",
    " 'current_version': 'layout-2',\n",
    " 'current_permission': True,\n",
    " 'effect_confirmed': True,\n",
    " 'coordinate_target': 'delete',\n",
    " 'semantic_target': 'release',\n",
    " 'wanted_target': 'release',\n",
    " 'change_rate': 0.02,\n",
    " 'delays': [5, 15, 30]}\n",
    "report = analyze(chapter, inputs)\n",
    "# This input was explicitly taken from the teaching fixture.\n",
    "report['evidence_kind'] = 'constructed teaching example'\n",
    "print(report_text(report))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fa977cee7c0",
   "metadata": {},
   "source": [
    "The default coordinate action is issued at a fresh observation age but points to delete, so confirmed completion is false. Semantic targeting points to release and is issued, giving confirmed completion true under the supplied receipt flag. Version-bound action refuses issuance because layout-1 differs from layout-2.\n",
    "\n",
    "In the changed case age 3 exceeds max_age 2. All interfaces refuse issuance, including the semantic one. Freshness policy changes the action set before any claim of completion. The result does not say the page was unusable; it says this declared contract requires a renewed observation before acting.\n",
    "\n",
    "Equation 18.3 is also computed when change_rate is supplied. With rate 0.02 changes per second, delays of 5, 15 and 30 seconds give freshness probabilities 0.9048, 0.7408 and 0.5488, which reproduces the chapter's second exercise. This is a constant-rate model of how likely no invalidating change has occurred. It is reported beside the age-limit rule, not in place of it, and a bursty update pattern would make it unsuitable.\n",
    "\n",
    "The plot below uses the calculated quantities. Read each panel's units before comparing its values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "590f57e74048",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Matplotlib is building the font cache; this may take a moment.\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\" width=\"576pt\" height=\"417.6pt\" viewBox=\"0 0 576 417.6\" version=\"1.1\"><title>Calculated chapter experiment</title><desc>Labeled plot of the explicitly supplied chapter inputs. See the adjacent explanation for assumptions.</desc>\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:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Mathematics of AI Agents Laboratory</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 417.6  L 576 417.6  L 576 0  L 0 0  z \" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 47.962344 194.361406  L 565.2 194.361406  L 565.2 69.080234  L 47.962344 69.080234  z \" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"m2bc73d5542\" d=\"M 0 0  L 0 3.5  \" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2bc73d5542\" x=\"71.473146\" y=\"194.361406\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"71.473146\" y=\"208.959062\" transform=\"rotate(-0 71.473146 208.959062)\">0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2bc73d5542\" x=\"306.581172\" y=\"194.361406\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"306.581172\" y=\"208.959062\" transform=\"rotate(-0 306.581172 208.959062)\">1</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2bc73d5542\" x=\"541.689197\" y=\"194.361406\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"541.689197\" y=\"208.959062\" transform=\"rotate(-0 541.689197 208.959062)\">2</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_4\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"306.581172\" y=\"222.959062\" transform=\"rotate(-0 306.581172 222.959062)\">case</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <path d=\"M 47.962344 188.666808  L 565.2 188.666808  \" clip-path=\"url(#pb994ea2930)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_5\">\n",
       "      <defs>\n",
       "       <path id=\"m56adfe50fc\" d=\"M 0 0  L -3.5 0  \" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"188.666808\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"192.465636\" transform=\"rotate(-0 40.962344 192.465636)\">0.0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <path d=\"M 47.962344 165.888413  L 565.2 165.888413  \" clip-path=\"url(#pb994ea2930)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"165.888413\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"169.687241\" transform=\"rotate(-0 40.962344 169.687241)\">0.2</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <path d=\"M 47.962344 143.110018  L 565.2 143.110018  \" clip-path=\"url(#pb994ea2930)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"143.110018\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"146.908846\" transform=\"rotate(-0 40.962344 146.908846)\">0.4</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <path d=\"M 47.962344 120.331623  L 565.2 120.331623  \" clip-path=\"url(#pb994ea2930)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"120.331623\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"124.130451\" transform=\"rotate(-0 40.962344 124.130451)\">0.6</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <path d=\"M 47.962344 97.553228  L 565.2 97.553228  \" clip-path=\"url(#pb994ea2930)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"97.553228\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"101.352056\" transform=\"rotate(-0 40.962344 101.352056)\">0.8</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_14\">\n",
       "      <path d=\"M 47.962344 74.774833  L 565.2 74.774833  \" clip-path=\"url(#pb994ea2930)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_15\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"74.774833\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"78.573661\" transform=\"rotate(-0 40.962344 78.573661)\">1.0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_11\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"18.656875\" y=\"131.72082\" transform=\"rotate(-90 18.656875 131.72082)\">issued flag</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_16\">\n",
       "    <path d=\"M 71.473146 74.774833  L 306.581172 74.774833  L 541.689197 188.666808  \" clip-path=\"url(#pb994ea2930)\" style=\"fill: none; stroke: #31586b; stroke-width: 1.8; stroke-linecap: square\"/>\n",
       "    <defs>\n",
       "     <path id=\"m132ba521c8\" d=\"M 0 2  C 0.530406 2 1.03916 1.789267 1.414214 1.414214  C 1.789267 1.03916 2 0.530406 2 0  C 2 -0.530406 1.789267 -1.03916 1.414214 -1.414214  C 1.03916 -1.789267 0.530406 -2 0 -2  C -0.530406 -2 -1.03916 -1.789267 -1.414214 -1.414214  C -1.789267 -1.03916 -2 -0.530406 -2 0  C -2 0.530406 -1.789267 1.03916 -1.414214 1.414214  C -1.03916 1.789267 -0.530406 2 0 2  z \" style=\"stroke: #31586b\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#pb994ea2930)\">\n",
       "     <use xlink:href=\"#m132ba521c8\" x=\"71.473146\" y=\"74.774833\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#m132ba521c8\" x=\"306.581172\" y=\"74.774833\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#m132ba521c8\" x=\"541.689197\" y=\"188.666808\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 47.962344 194.361406  L 47.962344 69.080234  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 47.962344 194.361406  L 565.2 194.361406  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_12\">\n",
       "    <text style=\"font-size: 11px; font-family: 'DejaVu Sans'; text-anchor: start\" x=\"47.962344\" y=\"63.080234\" transform=\"rotate(-0 47.962344 63.080234)\">issued action</text>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_2\">\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 47.962344 375.8  L 565.2 375.8  L 565.2 250.518828  L 47.962344 250.518828  z \" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_3\">\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2bc73d5542\" x=\"71.473146\" y=\"375.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"71.473146\" y=\"390.397656\" transform=\"rotate(-0 71.473146 390.397656)\">0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2bc73d5542\" x=\"306.581172\" y=\"375.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_14\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"306.581172\" y=\"390.397656\" transform=\"rotate(-0 306.581172 390.397656)\">1</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m2bc73d5542\" x=\"541.689197\" y=\"375.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_15\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"541.689197\" y=\"390.397656\" transform=\"rotate(-0 541.689197 390.397656)\">2</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_16\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"306.581172\" y=\"404.397656\" transform=\"rotate(-0 306.581172 404.397656)\">case</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_4\">\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_20\">\n",
       "      <path d=\"M 47.962344 370.105401  L 565.2 370.105401  \" clip-path=\"url(#p0c7b9ada24)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_21\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"370.105401\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_17\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"373.904229\" transform=\"rotate(-0 40.962344 373.904229)\">0.0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"line2d_22\">\n",
       "      <path d=\"M 47.962344 347.327006  L 565.2 347.327006  \" clip-path=\"url(#p0c7b9ada24)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_23\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"347.327006\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_18\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"351.125835\" transform=\"rotate(-0 40.962344 351.125835)\">0.2</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_9\">\n",
       "     <g id=\"line2d_24\">\n",
       "      <path d=\"M 47.962344 324.548612  L 565.2 324.548612  \" clip-path=\"url(#p0c7b9ada24)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_25\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"324.548612\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_19\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"328.34744\" transform=\"rotate(-0 40.962344 328.34744)\">0.4</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_10\">\n",
       "     <g id=\"line2d_26\">\n",
       "      <path d=\"M 47.962344 301.770217  L 565.2 301.770217  \" clip-path=\"url(#p0c7b9ada24)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_27\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"301.770217\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_20\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"305.569045\" transform=\"rotate(-0 40.962344 305.569045)\">0.6</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_11\">\n",
       "     <g id=\"line2d_28\">\n",
       "      <path d=\"M 47.962344 278.991822  L 565.2 278.991822  \" clip-path=\"url(#p0c7b9ada24)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_29\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"278.991822\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_21\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"282.79065\" transform=\"rotate(-0 40.962344 282.79065)\">0.8</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_12\">\n",
       "     <g id=\"line2d_30\">\n",
       "      <path d=\"M 47.962344 256.213427  L 565.2 256.213427  \" clip-path=\"url(#p0c7b9ada24)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_31\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m56adfe50fc\" x=\"47.962344\" y=\"256.213427\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_22\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"40.962344\" y=\"260.012255\" transform=\"rotate(-0 40.962344 260.012255)\">1.0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_23\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"18.656875\" y=\"313.159414\" transform=\"rotate(-90 18.656875 313.159414)\">completion flag</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_32\">\n",
       "    <path d=\"M 71.473146 370.105401  L 306.581172 256.213427  L 541.689197 370.105401  \" clip-path=\"url(#p0c7b9ada24)\" style=\"fill: none; stroke: #31586b; stroke-width: 1.8; stroke-linecap: square\"/>\n",
       "    <g clip-path=\"url(#p0c7b9ada24)\">\n",
       "     <use xlink:href=\"#m132ba521c8\" x=\"71.473146\" y=\"370.105401\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#m132ba521c8\" x=\"306.581172\" y=\"256.213427\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#m132ba521c8\" x=\"541.689197\" y=\"370.105401\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 47.962344 375.8  L 47.962344 250.518828  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_7\">\n",
       "    <path d=\"M 47.962344 375.8  L 565.2 375.8  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_24\">\n",
       "    <text style=\"font-size: 11px; font-family: 'DejaVu Sans'; text-anchor: start\" x=\"47.962344\" y=\"244.518828\" transform=\"rotate(-0 47.962344 244.518828)\">authorized confirmed completion</text>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"text_25\">\n",
       "   <text style=\"font-size: 12px; font-family: 'DejaVu Sans'; text-anchor: start\" x=\"46.08\" y=\"17.470125\" transform=\"rotate(-0 46.08 17.470125)\">Chapter 18: interface freshness</text>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pb994ea2930\">\n",
       "   <rect x=\"47.962344\" y=\"69.080234\" width=\"517.237656\" height=\"125.281172\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"p0c7b9ada24\">\n",
       "   <rect x=\"47.962344\" y=\"250.518828\" width=\"517.237656\" height=\"125.281172\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(SVG(figure_svg(report)))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "22722681fd1c",
   "metadata": {},
   "source": [
    "**Figure 18.L1:** Calculated chapter experiment. Each panel labels its input and output units; interpret it under the assumptions printed in the report."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11ea3c05641a",
   "metadata": {},
   "source": [
    "## Change the assumption\n",
    "\n",
    "Semantic targeting is not a universal repair for computer-use errors. Labels can be duplicated, accessibility trees can be stale, and resolver rules can name the wrong object. The runtime accepts a declared semantic target so that this boundary stays visible rather than assuming semantics equals correctness.\n",
    "\n",
    "A second failure treats historical permission as current authority. The controller must check permission at issuance, not merely remember that a similar action was allowed earlier. The transfer case blocks every method despite correct targets and matching versions.\n",
    "\n",
    "Finally, a click receipt is not necessarily an effect receipt. This experiment's confirmation flag refers to the desired completed effect. Real interfaces may need a state query, durable operation identifier, or verification page. Do not translate a low-level input event into terminal completion without that evidence."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7ae0e204bcc8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Chapter 18: interface-freshness\n",
      "Does an observed interface still support an authorized action at the intended target?\n",
      "Evidence: constructed changed-assumption example\n",
      "\n",
      "Calculated quantities:\n",
      "{\n",
      "  \"methods\": [\n",
      "    {\n",
      "      \"method\": \"coordinate\",\n",
      "      \"fresh\": false,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": true,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": false,\n",
      "      \"confirmed_completion\": false\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"semantic\",\n",
      "      \"fresh\": false,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": true,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"version-bound\",\n",
      "      \"fresh\": false,\n",
      "      \"version_matches\": false,\n",
      "      \"authorized\": true,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    }\n",
      "  ],\n",
      "  \"stale_observation\": true,\n",
      "  \"layout_changed\": true,\n",
      "  \"change_rate\": 0.02,\n",
      "  \"freshness_probability_at_age\": 0.9417645336,\n",
      "  \"freshness_probability_at_max_age\": 0.9607894392,\n",
      "  \"freshness_by_delay\": [\n",
      "    {\n",
      "      \"delay\": 5.0,\n",
      "      \"freshness_probability\": 0.904837418\n",
      "    },\n",
      "    {\n",
      "      \"delay\": 15.0,\n",
      "      \"freshness_probability\": 0.7408182207\n",
      "    },\n",
      "    {\n",
      "      \"delay\": 30.0,\n",
      "      \"freshness_probability\": 0.5488116361\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "Interpretation:\n",
      "Coordinates name a location; semantic targets name an object; a version-bound action also refuses a changed observation boundary. Current permission is checked at issuance.\n",
      "\n",
      "Assumptions:\n",
      "- Targets and current permission are supplied observations.\n",
      "- Freshness uses the declared age limit.\n",
      "- If change_rate is supplied, Fresh(delay)=exp(-change_rate*delay) assumes invalidating changes arrive at a constant rate; it is reported beside, and does not replace, the age-limit rule.\n",
      "\n",
      "Limitations:\n",
      "- Semantic resolution can itself be wrong.\n",
      "- A click or issued request is not confirmation of its effect.\n",
      "\n",
      "Execution: completed locally; constructed inputs are not deployment measurements.\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\" width=\"576pt\" height=\"417.6pt\" viewBox=\"0 0 576 417.6\" version=\"1.1\"><title>Calculated chapter experiment</title><desc>Labeled plot of the explicitly supplied chapter inputs. See the adjacent explanation for assumptions.</desc>\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:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Mathematics of AI Agents Laboratory</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 417.6  L 576 417.6  L 576 0  L 0 0  z \" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 63.082344 194.361406  L 565.2 194.361406  L 565.2 69.080234  L 63.082344 69.080234  z \" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"me39391c295\" d=\"M 0 0  L 0 3.5  \" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#me39391c295\" x=\"85.905874\" y=\"194.361406\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"85.905874\" y=\"208.959062\" transform=\"rotate(-0 85.905874 208.959062)\">0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me39391c295\" x=\"314.141172\" y=\"194.361406\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"314.141172\" y=\"208.959062\" transform=\"rotate(-0 314.141172 208.959062)\">1</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me39391c295\" x=\"542.37647\" y=\"194.361406\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"542.37647\" y=\"208.959062\" transform=\"rotate(-0 542.37647 208.959062)\">2</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_4\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"314.141172\" y=\"222.959062\" transform=\"rotate(-0 314.141172 222.959062)\">case</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <path d=\"M 63.082344 177.27761  L 565.2 177.27761  \" clip-path=\"url(#p0d3a2c006d)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_5\">\n",
       "      <defs>\n",
       "       <path id=\"m03b7be050c\" d=\"M 0 0  L -3.5 0  \" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"177.27761\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"181.076438\" transform=\"rotate(-0 56.082344 181.076438)\">−0.04</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <path d=\"M 63.082344 154.499215  L 565.2 154.499215  \" clip-path=\"url(#p0d3a2c006d)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"154.499215\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"158.298043\" transform=\"rotate(-0 56.082344 158.298043)\">−0.02</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <path d=\"M 63.082344 131.72082  L 565.2 131.72082  \" clip-path=\"url(#p0d3a2c006d)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"131.72082\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"135.519648\" transform=\"rotate(-0 56.082344 135.519648)\">0.00</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <path d=\"M 63.082344 108.942425  L 565.2 108.942425  \" clip-path=\"url(#p0d3a2c006d)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"108.942425\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"112.741254\" transform=\"rotate(-0 56.082344 112.741254)\">0.02</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <path d=\"M 63.082344 86.164031  L 565.2 86.164031  \" clip-path=\"url(#p0d3a2c006d)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"86.164031\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"89.962859\" transform=\"rotate(-0 56.082344 89.962859)\">0.04</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_10\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"19.034688\" y=\"131.72082\" transform=\"rotate(-90 19.034688 131.72082)\">issued flag</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_14\">\n",
       "    <path d=\"M 85.905874 131.72082  L 314.141172 131.72082  L 542.37647 131.72082  \" clip-path=\"url(#p0d3a2c006d)\" style=\"fill: none; stroke: #31586b; stroke-width: 1.8; stroke-linecap: square\"/>\n",
       "    <defs>\n",
       "     <path id=\"me1cbd137db\" d=\"M 0 2  C 0.530406 2 1.03916 1.789267 1.414214 1.414214  C 1.789267 1.03916 2 0.530406 2 0  C 2 -0.530406 1.789267 -1.03916 1.414214 -1.414214  C 1.03916 -1.789267 0.530406 -2 0 -2  C -0.530406 -2 -1.03916 -1.789267 -1.414214 -1.414214  C -1.789267 -1.03916 -2 -0.530406 -2 0  C -2 0.530406 -1.789267 1.03916 -1.414214 1.414214  C -1.03916 1.789267 -0.530406 2 0 2  z \" style=\"stroke: #31586b\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p0d3a2c006d)\">\n",
       "     <use xlink:href=\"#me1cbd137db\" x=\"85.905874\" y=\"131.72082\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#me1cbd137db\" x=\"314.141172\" y=\"131.72082\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#me1cbd137db\" x=\"542.37647\" y=\"131.72082\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 63.082344 194.361406  L 63.082344 69.080234  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 63.082344 194.361406  L 565.2 194.361406  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_11\">\n",
       "    <text style=\"font-size: 11px; font-family: 'DejaVu Sans'; text-anchor: start\" x=\"63.082344\" y=\"63.080234\" transform=\"rotate(-0 63.082344 63.080234)\">issued action</text>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_2\">\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 63.082344 375.8  L 565.2 375.8  L 565.2 250.518828  L 63.082344 250.518828  z \" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_3\">\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me39391c295\" x=\"85.905874\" y=\"375.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"85.905874\" y=\"390.397656\" transform=\"rotate(-0 85.905874 390.397656)\">0</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me39391c295\" x=\"314.141172\" y=\"375.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"314.141172\" y=\"390.397656\" transform=\"rotate(-0 314.141172 390.397656)\">1</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#me39391c295\" x=\"542.37647\" y=\"375.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_14\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"542.37647\" y=\"390.397656\" transform=\"rotate(-0 542.37647 390.397656)\">2</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_15\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"314.141172\" y=\"404.397656\" transform=\"rotate(-0 314.141172 404.397656)\">case</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_4\">\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_18\">\n",
       "      <path d=\"M 63.082344 358.716204  L 565.2 358.716204  \" clip-path=\"url(#pf2ddecdb2e)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_19\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"358.716204\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_16\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"362.515032\" transform=\"rotate(-0 56.082344 362.515032)\">−0.04</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_20\">\n",
       "      <path d=\"M 63.082344 335.937809  L 565.2 335.937809  \" clip-path=\"url(#pf2ddecdb2e)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_21\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"335.937809\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_17\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"339.736637\" transform=\"rotate(-0 56.082344 339.736637)\">−0.02</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"line2d_22\">\n",
       "      <path d=\"M 63.082344 313.159414  L 565.2 313.159414  \" clip-path=\"url(#pf2ddecdb2e)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_23\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"313.159414\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_18\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"316.958242\" transform=\"rotate(-0 56.082344 316.958242)\">0.00</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_9\">\n",
       "     <g id=\"line2d_24\">\n",
       "      <path d=\"M 63.082344 290.381019  L 565.2 290.381019  \" clip-path=\"url(#pf2ddecdb2e)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_25\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"290.381019\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_19\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"294.179847\" transform=\"rotate(-0 56.082344 294.179847)\">0.02</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_10\">\n",
       "     <g id=\"line2d_26\">\n",
       "      <path d=\"M 63.082344 267.602624  L 565.2 267.602624  \" clip-path=\"url(#pf2ddecdb2e)\" style=\"fill: none; stroke: #d4d8da; stroke-width: 0.6; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_27\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m03b7be050c\" x=\"63.082344\" y=\"267.602624\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_20\">\n",
       "      <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: end\" x=\"56.082344\" y=\"271.401452\" transform=\"rotate(-0 56.082344 271.401452)\">0.04</text>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_21\">\n",
       "     <text style=\"font-size: 10px; font-family: 'DejaVu Sans'; text-anchor: middle\" x=\"19.034688\" y=\"313.159414\" transform=\"rotate(-90 19.034688 313.159414)\">completion flag</text>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_28\">\n",
       "    <path d=\"M 85.905874 313.159414  L 314.141172 313.159414  L 542.37647 313.159414  \" clip-path=\"url(#pf2ddecdb2e)\" style=\"fill: none; stroke: #31586b; stroke-width: 1.8; stroke-linecap: square\"/>\n",
       "    <g clip-path=\"url(#pf2ddecdb2e)\">\n",
       "     <use xlink:href=\"#me1cbd137db\" x=\"85.905874\" y=\"313.159414\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#me1cbd137db\" x=\"314.141172\" y=\"313.159414\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "     <use xlink:href=\"#me1cbd137db\" x=\"542.37647\" y=\"313.159414\" style=\"fill: #31586b; stroke: #31586b\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 63.082344 375.8  L 63.082344 250.518828  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_7\">\n",
       "    <path d=\"M 63.082344 375.8  L 565.2 375.8  \" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_22\">\n",
       "    <text style=\"font-size: 11px; font-family: 'DejaVu Sans'; text-anchor: start\" x=\"63.082344\" y=\"244.518828\" transform=\"rotate(-0 63.082344 244.518828)\">authorized confirmed completion</text>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"text_23\">\n",
       "   <text style=\"font-size: 12px; font-family: 'DejaVu Sans'; text-anchor: start\" x=\"46.08\" y=\"17.470125\" transform=\"rotate(-0 46.08 17.470125)\">Chapter 18: interface freshness</text>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p0d3a2c006d\">\n",
       "   <rect x=\"63.082344\" y=\"69.080234\" width=\"502.117656\" height=\"125.281172\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"pf2ddecdb2e\">\n",
       "   <rect x=\"63.082344\" y=\"250.518828\" width=\"502.117656\" height=\"125.281172\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "changed_inputs = {'observation_age': 3,\n",
    " 'max_age': 2,\n",
    " 'observed_version': 'layout-1',\n",
    " 'current_version': 'layout-2',\n",
    " 'current_permission': True,\n",
    " 'effect_confirmed': True,\n",
    " 'coordinate_target': 'delete',\n",
    " 'semantic_target': 'release',\n",
    " 'wanted_target': 'release',\n",
    " 'change_rate': 0.02,\n",
    " 'delays': [5, 15, 30]}\n",
    "changed = analyze(chapter, changed_inputs)\n",
    "changed['evidence_kind'] = 'constructed changed-assumption example'\n",
    "print(report_text(changed))\n",
    "display(SVG(figure_svg(changed)))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9d43522c6d7e",
   "metadata": {},
   "source": [
    "**Figure 18.L2:** The changed-assumption result. Compare the printed quantities and the stated assumptions with the first run. A different input need not imply a causal effect in a deployed agent."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "018975c0891f",
   "metadata": {},
   "source": [
    "## Try a new case\n",
    "\n",
    "The transfer observation is fresh, versions match, and both target methods resolve submit correctly. Current permission is false, so every issuance flag is false. This is an authority boundary independent of perception accuracy.\n",
    "\n",
    "For local use, preserve the observed target, action-time target, layout version, and timestamp. If a field is unavailable, specify the observation needed instead of guessing it. Compare interfaces under the same task and permission contract. Use uncertain-effect tracing after issuance when the real question is whether the remote action happened despite a missing acknowledgement."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7b5cd99e6a8b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Chapter 18: interface-freshness\n",
      "Does an observed interface still support an authorized action at the intended target?\n",
      "Evidence: constructed transfer example\n",
      "\n",
      "Calculated quantities:\n",
      "{\n",
      "  \"methods\": [\n",
      "    {\n",
      "      \"method\": \"coordinate\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": false,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"semantic\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": false,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"version-bound\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": false,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    }\n",
      "  ],\n",
      "  \"stale_observation\": false,\n",
      "  \"layout_changed\": false,\n",
      "  \"change_rate\": 0.05,\n",
      "  \"freshness_probability_at_age\": 1.0,\n",
      "  \"freshness_probability_at_max_age\": 0.9512294245,\n",
      "  \"freshness_by_delay\": [\n",
      "    {\n",
      "      \"delay\": 2.0,\n",
      "      \"freshness_probability\": 0.904837418\n",
      "    },\n",
      "    {\n",
      "      \"delay\": 10.0,\n",
      "      \"freshness_probability\": 0.6065306597\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "Interpretation:\n",
      "Coordinates name a location; semantic targets name an object; a version-bound action also refuses a changed observation boundary. Current permission is checked at issuance.\n",
      "\n",
      "Assumptions:\n",
      "- Targets and current permission are supplied observations.\n",
      "- Freshness uses the declared age limit.\n",
      "- If change_rate is supplied, Fresh(delay)=exp(-change_rate*delay) assumes invalidating changes arrive at a constant rate; it is reported beside, and does not replace, the age-limit rule.\n",
      "\n",
      "Limitations:\n",
      "- Semantic resolution can itself be wrong.\n",
      "- A click or issued request is not confirmation of its effect.\n",
      "\n",
      "Execution: completed locally; constructed inputs are not deployment measurements.\n"
     ]
    }
   ],
   "source": [
    "transfer_inputs = {'observation_age': 0,\n",
    " 'max_age': 1,\n",
    " 'observed_version': 'page-C',\n",
    " 'current_version': 'page-C',\n",
    " 'current_permission': False,\n",
    " 'effect_confirmed': False,\n",
    " 'coordinate_target': 'submit',\n",
    " 'semantic_target': 'submit',\n",
    " 'wanted_target': 'submit',\n",
    " 'change_rate': 0.05,\n",
    " 'delays': [2, 10]}\n",
    "transfer = analyze(chapter, transfer_inputs)\n",
    "transfer['evidence_kind'] = 'constructed transfer example'\n",
    "print(report_text(transfer))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be408845a433",
   "metadata": {},
   "source": [
    "## Apply the method to your inputs\n",
    "\n",
    "The example file below has the exact input shape the method accepts. Copy it to a new file, replace its values, then point `reader_file` at your copy. Run the cell again. Supplied inputs retain their stated provenance; the program cannot establish that they are representative observations.\n",
    "\n",
    "- **observation_age:** Nonnegative elapsed time since observation.\n",
    "- **max_age:** Nonnegative freshness limit in the same time unit.\n",
    "- **observed_version:** Version seen in the observation.\n",
    "- **current_version:** Version at action time.\n",
    "- **current_permission:** Exact boolean current authorization.\n",
    "- **effect_confirmed:** Exact boolean receipt of desired effect confirmation.\n",
    "- **coordinate_target:** Current object located at previously observed coordinates.\n",
    "- **semantic_target:** Current object resolved by semantic interface.\n",
    "- **wanted_target:** Intended object identifier.\n",
    "- **change_rate:** Optional nonnegative rate of invalidating interface changes per unit time. When given, Fresh(delay)=exp(-rate*delay) from Equation 18.3 is reported.\n",
    "- **delays:** Optional list of nonnegative delays in the same time unit; requires change_rate."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c8e3351940eb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Chapter 18: interface-freshness\n",
      "Does an observed interface still support an authorized action at the intended target?\n",
      "Evidence: supplied local inputs; provenance not independently verified\n",
      "\n",
      "Calculated quantities:\n",
      "{\n",
      "  \"methods\": [\n",
      "    {\n",
      "      \"method\": \"coordinate\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": false,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"semantic\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": false,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    },\n",
      "    {\n",
      "      \"method\": \"version-bound\",\n",
      "      \"fresh\": true,\n",
      "      \"version_matches\": true,\n",
      "      \"authorized\": false,\n",
      "      \"issued\": false,\n",
      "      \"correct_target\": true,\n",
      "      \"confirmed_completion\": false\n",
      "    }\n",
      "  ],\n",
      "  \"stale_observation\": false,\n",
      "  \"layout_changed\": false,\n",
      "  \"change_rate\": 0.05,\n",
      "  \"freshness_probability_at_age\": 1.0,\n",
      "  \"freshness_probability_at_max_age\": 0.9512294245,\n",
      "  \"freshness_by_delay\": [\n",
      "    {\n",
      "      \"delay\": 2.0,\n",
      "      \"freshness_probability\": 0.904837418\n",
      "    },\n",
      "    {\n",
      "      \"delay\": 10.0,\n",
      "      \"freshness_probability\": 0.6065306597\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "Interpretation:\n",
      "Coordinates name a location; semantic targets name an object; a version-bound action also refuses a changed observation boundary. Current permission is checked at issuance.\n",
      "\n",
      "Assumptions:\n",
      "- Targets and current permission are supplied observations.\n",
      "- Freshness uses the declared age limit.\n",
      "- If change_rate is supplied, Fresh(delay)=exp(-change_rate*delay) assumes invalidating changes arrive at a constant rate; it is reported beside, and does not replace, the age-limit rule.\n",
      "\n",
      "Limitations:\n",
      "- Semantic resolution can itself be wrong.\n",
      "- A click or issued request is not confirmation of its effect.\n",
      "\n",
      "Execution: completed locally; constructed inputs are not deployment measurements.\n"
     ]
    }
   ],
   "source": [
    "reader_file = LAB_ROOT / 'data/examples/ch18.json'\n",
    "reader_inputs = json.loads(reader_file.read_text())\n",
    "reader_report = analyze(chapter, reader_inputs)\n",
    "print(report_text(reader_report))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "acd93f485688",
   "metadata": {},
   "source": [
    "## Questions\n",
    "\n",
    "1. Why does default coordinate completion fail?\n",
    "\n",
    "2. Can matching versions replace current permission?\n",
    "\n",
    "3. What does observation age 3 do under max_age = 2?\n",
    "\n",
    "4. With change_rate 0.02 per second, compute the no-invalidating-change probability for delays of 5, 15 and 30 seconds.\n",
    "\n",
    "Answers: [separate solutions](../solutions/ch18.md). Try the calculation before opening them."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "acad303ecd85",
   "metadata": {},
   "source": [
    "## Summary\n",
    "\n",
    "Actions with coordinates depend on a changing interface. Freshness, version binding, current permission, target correctness, and effect confirmation are separate predicates. The moved-layout example exposes a coordinate failure; the stale-observation case blocks issuance; the transfer case blocks action for missing authority. Semantic targeting helps only within its resolver contract. The calculation reports declared interface behavior without claiming that any live page was observed or controlled.\n",
    "\n",
    "Limits of this experiment:\n",
    "\n",
    "- This is a local calculation under declared inputs, not an empirical claim about a deployed agent.\n",
    "- Read the returned assumptions and limitations before applying the numerical result.\n",
    "\n",
    "The assistant skill is [`maa-18-interface-freshness`](../skills/maa-18-interface-freshness/SKILL.md). It uses this notebook's tested computation and input contract."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9cc9f25ba898",
   "metadata": {},
   "source": [
    "## Equations from the chapter\n",
    "\n",
    "These are the unchanged display equations and their explanations from the canonical chapter. They are a reference for the experiment, not a claim that every equation is numerically implemented by this one method."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7602c68ba6d9",
   "metadata": {},
   "source": [
    "### Equation 18.1\n",
    "\n",
    "![Equation 18.1](../assets/math/755fe6a5928a4b2e29ce.svg)\n",
    "\n",
    "Equation (18.1) composes an interface's execution law with the world transitions caused by its realized operations.\n",
    "\n",
    "For each operation the command might realize in the current state, multiply its execution probability by its next-state law, then add those possibilities.\n",
    "\n",
    "LaTeX source, preserved for inspection:\n",
    "\n",
    "```latex\n",
    "P_{\\mathrm{ui}}(x'\\mid x,a)\n",
    "=\n",
    "\\sum_{\\tilde a\\in\\operatorname{Act}_{\\mathrm{ui}}}\n",
    "\\operatorname{Exec}_{\\mathrm{ui}}(\\tilde a\\mid x,a)\n",
    "P(x'\\mid x,\\tilde a).\n",
    "\\tag{18.1}\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "82e499bb2367",
   "metadata": {},
   "source": [
    "### Equation 18.2\n",
    "\n",
    "![Equation 18.2](../assets/math/4b0b524edbcf02f6262f.svg)\n",
    "\n",
    "Equation (18.2) retains actions authorized in every state still considered possible.\n",
    "\n",
    "An action survives only if each state with positive belief weight permits it.\n",
    "\n",
    "LaTeX source, preserved for inspection:\n",
    "\n",
    "```latex\n",
    "\\mathcal A_{\\mathrm{rob}}(\\mathbf b)\n",
    "=\n",
    "\\bigcap_{x:\\,\\mathbf b(x)>0}\\mathcal A_{\\mathrm{auth}}(x).\n",
    "\\tag{18.2}\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "733529fb3b10",
   "metadata": {},
   "source": [
    "### Equation 18.3\n",
    "\n",
    "![Equation 18.3](../assets/math/2f33e21b021d2dab73fc.svg)\n",
    "\n",
    "Equation (18.3) gives the chance that a coordinate binding remains valid over a delay in the stated constant-rate construction.\n",
    "\n",
    "Longer delay and a higher material-change rate both lower the chance that no invalidating change has occurred.\n",
    "\n",
    "LaTeX source, preserved for inspection:\n",
    "\n",
    "```latex\n",
    "\\operatorname{Fresh}(\\Delta)\n",
    "=\n",
    "\\exp(-\\lambda_{\\mathrm{ui}}\\Delta).\n",
    "\\tag{18.3}\n",
    "```"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Mathematics of AI Agents",
   "language": "python",
   "name": "maa-lab"
  },
  "lab_chapter": 18,
  "lab_execution": {
   "code_cells": 6,
   "created_utc": "2026-10-02T05:15:37.686697+00:00",
   "elapsed_seconds": 8.967424959060736,
   "method": "fresh process; new ipykernel InProcessKernelManager; cells submitted as Jupyter execute requests",
   "network_transport_tested": false,
   "python": "3.11.15",
   "source_sha256": "34988385315cf0f452f1e483d84ad73163fead7f4f2140707edffa07b4358532"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
