{"id":23702,"date":"2026-09-04T02:26:13","date_gmt":"2026-09-04T02:26:13","guid":{"rendered":"https:\/\/scannn.com\/the-harness-playbook-stencil\/"},"modified":"2026-09-04T02:26:13","modified_gmt":"2026-09-04T02:26:13","slug":"the-harness-playbook-stencil","status":"publish","type":"post","link":"https:\/\/scannn.com\/lv\/the-harness-playbook-stencil\/","title":{"rendered":"The Harness Playbook \u2014 Stencil"},"content":{"rendered":"\n<div>\n<p data-hk=\"000000010000000000004000010a1100\"><em data-hk=\"000000010000000000004000010a110100\">Before anything else: a thank you. Hundreds of thousands of you have used omp, reported what broke, suggested what was missing, and shaped what it became. This post and omp\u00b2 itself exist because of you.<\/em><\/p>\n<p data-hk=\"000000010000000000004000010a1200\">Upon hearing about omp\u00b2, many of you jumped to ask, &#8220;but why?&#8221;<\/p>\n<p data-hk=\"000000010000000000004000010a1300\">A while loop around a fetch sounds simple, but there&#8217;s a reason OpenCode, Pi, OpenClaw and omp are all<br \/>\nconcurrently working on a complete refactor: this class of software did not exist before, and only by starting<br \/>\nwith the simple version, we could see the cracks to work towards a better one.<\/p>\n<p data-hk=\"000000010000000000004000010a1400\">Unavoidable complexity needs an owner. At the moment, the <a data-hk=\"000000010000000000004000010a140100\" href=\"https:\/\/en.wikipedia.org\/wiki\/Law_of_conservation_of_complexity\">conservation of complexity<\/a><br \/>\ntips toward extensions and users, making it impossible to write reliable software on top of omp or Pi. I can already hear<br \/>\nthe <em data-hk=\"000000010000000000004000010a140200\">&#8220;whaaat, it is so simple and pleasant to extend.&#8221;<\/em> Give me a few chapters to change your mind.<\/p>\n<p data-hk=\"000000010000000000004000010a1500\">Dijkstra wrote that <a data-hk=\"000000010000000000004000010a150100\" href=\"https:\/\/www.cs.virginia.edu\/~evans\/cs655\/readings\/ewd498.html\">&#8220;simplicity is prerequisite for<br \/>\nreliability&#8221;<\/a>, and yet he is known for<br \/>\nalgorithmically solving pathfinding. Why not just brute force? He was not, at all, making the claim<br \/>\nwe now repeat as <strong data-hk=\"000000010000000000004000010a150200\">simple good, complex bad<\/strong>. The advice was to help implementers reason. We<br \/>\nshamefully use it to excuse the implementer from reasoning.<\/p>\n<p data-hk=\"000000010000000000004000010a1600\">Ousterhout gives the missing half in the notes of his Stanford lectures. He tells module writers to<br \/>\n<a data-hk=\"000000010000000000004000010a160100\" href=\"https:\/\/web.stanford.edu\/~ouster\/cgi-bin\/cs190-spring16\/lecture.php?topic=modularDesign\">&#8220;embrace<br \/>\nsuffering&#8221;<\/a>.<br \/>\nTake on hard problems, solve them completely, and make the result easy for everybody else to use.<br \/>\nPush complexity down into the module. Let a few implementers carry it instead of making every caller<br \/>\ncarry a smaller, slightly different copy.<\/p>\n<hr data-hk=\"000000010000000000004000010a1700\"\/>\n<p data-hk=\"000000010000000000004000010a1800\">I am sure many readers remember the wave of memes from the tweet comparing Claude Code to a game<br \/>\nengine. The comparison sounds far-fetched, but if you list the responsibilities of a harness, putting rendering aside, it does match quite well.<\/p>\n<p data-hk=\"000000010000000000004000010a1900\">It maintains an authoritative world, journals changes, runs untrusted actions, replicates state to<br \/>\nmultiple views, schedules actors, interprets commands, adapts incompatible protocols, and renders a<br \/>\nreal-time interface.<\/p>\n<p data-hk=\"000000010000000000004000010a2000\">Sounds familiar? It seems game engines have spent decades owning the same categories of complexity.<\/p>\n<p data-hk=\"000000010000000000004000010a2100\">What follows is both a postmortem and a playbook:<\/p>\n<ul data-hk=\"000000010000000000004000010a2200\">\n<li data-hk=\"000000010000000000004000010a220100\"><strong data-hk=\"000000010000000000004000010a22010100\">What omp taught us<\/strong> names failures we met in a system people actually used.<\/li>\n<li data-hk=\"000000010000000000004000010a220200\"><strong data-hk=\"000000010000000000004000010a22020100\">What omp\u00b2 changes<\/strong> describes the replacement architecture\u2014some of it already built, some still<br \/>\nbeing worked through.<\/li>\n<\/ul>\n<nav data-hk=\"000000010000000000004000010a23\" class=\"inline-toc\" aria-labelledby=\"playbook-contents\">\n<ol>\n<li><a href=\"#the-design-envelope\"><span class=\"inline-toc-index\" aria-hidden=\"true\">01<\/span><span class=\"inline-toc-title\">The design envelope<\/span><\/a><\/li>\n<li><a href=\"#the-state\"><span class=\"inline-toc-index\" aria-hidden=\"true\">02<\/span><span class=\"inline-toc-title\">The state<\/span><\/a><\/li>\n<li><a href=\"#the-runtime\"><span class=\"inline-toc-index\" aria-hidden=\"true\">03<\/span><span class=\"inline-toc-title\">The runtime<\/span><\/a><\/li>\n<li><a href=\"#the-control-plane\"><span class=\"inline-toc-index\" aria-hidden=\"true\">04<\/span><span class=\"inline-toc-title\">The control plane<\/span><\/a><\/li>\n<li><a href=\"#the-inference\"><span class=\"inline-toc-index\" aria-hidden=\"true\">05<\/span><span class=\"inline-toc-title\">The inference<\/span><\/a><\/li>\n<li><a href=\"#the-tool-surface\"><span class=\"inline-toc-index\" aria-hidden=\"true\">06<\/span><span class=\"inline-toc-title\">The tool surface<\/span><\/a><\/li>\n<li><a href=\"#the-interface\"><span class=\"inline-toc-index\" aria-hidden=\"true\">07<\/span><span class=\"inline-toc-title\">The interface<\/span><\/a><\/li>\n<li><a href=\"#the-stack\"><span class=\"inline-toc-index\" aria-hidden=\"true\">08<\/span><span class=\"inline-toc-title\">The stack<\/span><\/a><\/li>\n<li><a href=\"#closing-notes\"><span class=\"inline-toc-index\" aria-hidden=\"true\">09<\/span><span class=\"inline-toc-title\">Closing notes<\/span><\/a><\/li>\n<li><a href=\"#appendix-a-state-failures-in-the-official-examples\"><span class=\"inline-toc-index\" aria-hidden=\"true\">A<\/span><span class=\"inline-toc-title\">State failures in the official examples<\/span><\/a><\/li>\n<li><a href=\"#appendix-b-elastic-speculative-slots\"><span class=\"inline-toc-index\" aria-hidden=\"true\">B<\/span><span class=\"inline-toc-title\">Elastic Speculative Slots<\/span><\/a><\/li>\n<\/ol>\n<\/nav>\n<h2 data-hk=\"000000010000000000004000010a2400\" id=\"the-design-envelope\">The design envelope<\/h2>\n<aside data-hk=\"000000010000000000004000010a250\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Choose the operating modes first; every subsystem must survive all of them.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010a2510\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010a2600\">Before discussing any subsystem of an agentic harness, imagine that four very different products<br \/>\nwill depend on it:<\/p>\n<ul data-hk=\"000000010000000000004000010a2700\">\n<li data-hk=\"000000010000000000004000010a270100\"><strong data-hk=\"000000010000000000004000010a27010100\">Multiplexed workspace<\/strong><br \/>\n<em data-hk=\"000000010000000000004000010a27010200\">A local environment with multiple agents and subagents in the same folder.<\/em><\/li>\n<li data-hk=\"000000010000000000004000010a270200\"><strong data-hk=\"000000010000000000004000010a27020100\">Remote driver<\/strong><br \/>\n<em data-hk=\"000000010000000000004000010a27020200\">A remote client driving a cloud agent\u2014or the machine under their desk\u2014from a phone.<\/em><\/li>\n<li data-hk=\"000000010000000000004000010a270300\"><strong data-hk=\"000000010000000000004000010a27030100\">Spectator<\/strong><br \/>\n<em data-hk=\"000000010000000000004000010a27030200\">A web client watching a Claude agent work.<\/em><\/li>\n<li data-hk=\"000000010000000000004000010a270400\"><strong data-hk=\"000000010000000000004000010a27040100\">Factorio<\/strong><br \/>\n<em data-hk=\"000000010000000000004000010a27040200\">An automated software factory using the SDK against untrusted input.<\/em><\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010a2800\">These are not market personas. They are architecture tests. Together they vary the dimensions that<br \/>\nmake a harness stop being a chat loop:<\/p>\n<p data-hk=\"000000010000000000004000010a3000\">A design that only works for the first case tends to smuggle the controller into the TUI, keep<br \/>\nstate in closures, let extensions execute in the engine process, and assume a human can recover from<br \/>\nan unbounded call. A design that survives all four is forced into better boundaries.<\/p>\n<p data-hk=\"000000010000000000004000010a3100\">The rest of the book follows five consequences:<\/p>\n<ol data-hk=\"000000010000000000004000010a3200\">\n<li data-hk=\"000000010000000000004000010a320100\"><strong data-hk=\"000000010000000000004000010a32010100\">One authoritative session.<\/strong> Rewind, fork, resume, replication, and inspection must all derive<br \/>\nfrom the same journaled state.<\/li>\n<li data-hk=\"000000010000000000004000010a320200\"><strong data-hk=\"000000010000000000004000010a32020100\">A trusted control plane.<\/strong> Policy and session ownership stay on the host; sandboxes receive only<br \/>\nbounded execution requests.<\/li>\n<li data-hk=\"000000010000000000004000010a320300\"><strong data-hk=\"000000010000000000004000010a32030100\">Bounded work.<\/strong> Tool calls, subagents, and background jobs are all cancellable streams with<br \/>\ncentral limits and observability.<\/li>\n<li data-hk=\"000000010000000000004000010a320400\"><strong data-hk=\"000000010000000000004000010a32040100\">Explicit compatibility.<\/strong> Model and provider quirks are structured knowledge, not branches<br \/>\nscattered through call sites.<\/li>\n<li data-hk=\"000000010000000000004000010a320500\"><strong data-hk=\"000000010000000000004000010a32050100\">Views are projections.<\/strong> The TUI, web client, remote client, and subagent inspector render the<br \/>\nsame state instead of becoming additional authorities.<\/li>\n<\/ol>\n<p data-hk=\"000000010000000000004000010a3300\">Those constraints are connective tissue for everything that follows. When a later section proposes<br \/>\na DOM, a convar, a Director, a tiny VM stub, or a component renderer, it is solving one of these<br \/>\nfive requirements\u2014not introducing a clever subsystem for its own sake.<\/p>\n<p data-hk=\"000000010000000000004000010a3400\">The first requirement is the foundation: before deciding where code runs or how it is rendered, the<br \/>\nharness needs to know what is true.<\/p>\n<h2 data-hk=\"000000010000000000004000010a3500\" id=\"the-state\">The state<\/h2>\n<aside data-hk=\"000000010000000000004000010a360\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>If authoritative state cannot be derived from the journal, rewind, fork, and resume are lies.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010a3610\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<h3 data-hk=\"000000010000000000004000010a3700\" id=\"what-must-survive\">What must survive<\/h3>\n<p data-hk=\"000000010000000000004000010a3800\">If you want something to be durable, rewindable, crash-tolerant, and forkable, you have three<br \/>\nchoices:<\/p>\n<ol data-hk=\"000000010000000000004000010a3900\">\n<li data-hk=\"000000010000000000004000010a390100\">Preserve the history that produces it.<\/li>\n<li data-hk=\"000000010000000000004000010a390200\">Preserve the changes in the properties you care about.<\/li>\n<li data-hk=\"000000010000000000004000010a390300\">Preserve the machine itself.<\/li>\n<\/ol>\n<figure data-hk=\"000000010000000000004000010a40\"><\/figure>\n<p data-hk=\"000000010000000000004000010a4100\">The Source Engine uses a variant of the second option for networking. omp and Pi currently use&#8230;<br \/>\nnone of them consistently. There are events, but state is not really sourced from those events,<br \/>\nviolating the first principle of event sourcing: <strong data-hk=\"000000010000000000004000010a410100\">state must be derivable from the events alone<\/strong>.<\/p>\n<h3 data-hk=\"000000010000000000004000010a4200\" id=\"what-omp-taught-us-two-authorities\">What omp taught us: two authorities<\/h3>\n<figure data-hk=\"000000010000000000004000010a43\"><!--$--><\/p>\n<div data-hk=\"000000010000000000004000010a440\" class=\"st-mermaid \" role=\"img\" aria-label=\"Side-by-side comparison: CS:GO's Source Engine has one authority \u2014 the entity list \u2014 whose deltas cover every field, so replaying the .dem file reproduces the original session. Pi has two authorities: the journaled message tree, and a pile of authoritative-but-underived state (todo, retry counters, subagent registry, extension closures) that no delta covers, so replaying the .jsonl does not reproduce the session.\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" id=\"state-authorities-0\" width=\"100%\" class=\"flowchart\" style=\"max-width: 679.64453125px;\" viewbox=\"0 0 679.64453125 1778.4000244140625\" role=\"graphics-document document\" aria-roledescription=\"flowchart-v2\"><g><marker id=\"state-authorities-0_flowchart-v2-pointEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-pointStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"4.5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-pointEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"11.5\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"10.5\" markerheight=\"14\" orient=\"auto\"><path d=\"M 0 0 L 11.5 7 L 0 14 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-pointStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"1\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"11.5\" markerheight=\"14\" orient=\"auto\"><polygon points=\"0,7 11.5,14 11.5,0\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-circleEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"11\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-circleStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-1\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-circleEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refy=\"5\" refx=\"12.25\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-circleStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-2\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-crossEnd\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"12\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-crossStart\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"-1\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-crossEnd-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"17.7\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5;\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-crossStart-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"-3.5\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5; stroke-dasharray: 1, 0;\"\/><\/marker><g class=\"root\"><g class=\"clusters\"\/><g class=\"edgePaths\"><path d=\"M339.822,836.2L339.822,836.2L339.822,862.2L339.822,862.2L339.822,888.2\" id=\"state-authorities-0-L_CSGO_PI_0\" class=\"edge-thickness-invisible edge-pattern-solid\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_CSGO_PI_0\" data-points=\"W3sieCI6MzM5LjgyMjI2NTYyNSwieSI6ODM2LjIwMDAxMjIwNzAzMTJ9LHsieCI6MzM5LjgyMjI2NTYyNSwieSI6ODYyLjIwMDAxMjIwNzAzMTJ9LHsieCI6MzM5LjgyMjI2NTYyNSwieSI6ODg4LjIwMDAxMjIwNzAzMTJ9XQ==\" data-look=\"classic\"\/><\/g><g class=\"edgeLabels\"><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_CSGO_PI_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><\/g><g class=\"nodes\"><g class=\"root\" transform=\"translate(0, 880.2000122070312)\"><g class=\"clusters\"><g class=\"cluster\" id=\"state-authorities-0-PI\" data-look=\"classic\"><rect style=\"\" x=\"8\" y=\"8\" width=\"663.64453125\" height=\"882.2000007629395\"\/><g class=\"cluster-label\" transform=\"translate(271.712890625, 8)\"><g><rect class=\"background\" style=\"stroke: none\"\/><text y=\"-10.1\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">\u03c0<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> \u00b7<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> two<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> authorities<\/tspan><\/tspan><\/text><\/g><\/g><\/g><\/g><g class=\"edgePaths\"><path d=\"M273.908,186.5L328.23,186.5L328.23,240.6L398.495,240.6L398.495,294.7\" id=\"state-authorities-0-L_P_PRIVATE_P_CHANGE_0\" class=\"edge-thickness-normal edge-pattern-dotted edge-thickness-normal edge-pattern-solid flowchart-link\" style=\"stroke:#ef4444;stroke-width:3px;color:#f87171;fill:none;;;stroke:#ef4444;stroke-width:3px;color:#f87171;fill:none\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_P_PRIVATE_P_CHANGE_0\" data-points=\"W3sieCI6MjczLjkwODQxMjIyODU0NTY3LCJ5IjoxODYuNX0seyJ4IjozMjguMjMwNDY4NzUsInkiOjI0MC42MDAwMDAzODE0Njk3M30seyJ4IjozOTguNDk0NTgwODI3MTc0MzMsInkiOjI5NC43MDAwMDA3NjI5Mzk0NX1d\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-crossEnd__ef4444)\"\/><path d=\"M523.844,159.5L523.844,159.5L523.844,240.6L496.279,240.6L496.279,291.188\" id=\"state-authorities-0-L_P_TRUTH_P_CHANGE_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_P_TRUTH_P_CHANGE_0\" data-points=\"W3sieCI6NTIzLjg0Mzc1LCJ5IjoxNTkuNX0seyJ4Ijo1MjMuODQzNzUsInkiOjI0MC42MDAwMDAzODE0Njk3M30seyJ4Ijo0OTQuMzY1MzY4NjU0MDE4NzcsInkiOjI5NC43MDAwMDA3NjI5Mzk0NX1d\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><path d=\"M466.031,398.7L466.031,398.7L466.031,437.2L466.031,437.2L466.031,471.7\" id=\"state-authorities-0-L_P_CHANGE_P_DISK_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_P_CHANGE_P_DISK_0\" data-points=\"W3sieCI6NDY2LjAzMTI1LCJ5IjozOTguNzAwMDAwNzYyOTM5NDV9LHsieCI6NDY2LjAzMTI1LCJ5Ijo0MzcuMjAwMDAwNzYyOTM5NDV9LHsieCI6NDY2LjAzMTI1LCJ5Ijo0NzUuNzAwMDAwNzYyOTM5NDV9XQ==\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><path d=\"M466.031,543.7L466.031,543.7L466.031,582.2L466.031,582.2L466.031,616.7\" id=\"state-authorities-0-L_P_DISK_P_REPLAY_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_P_DISK_P_REPLAY_0\" data-points=\"W3sieCI6NDY2LjAzMTI1LCJ5Ijo1NDMuNzAwMDAwNzYyOTM5NX0seyJ4Ijo0NjYuMDMxMjUsInkiOjU4Mi4yMDAwMDA3NjI5Mzk1fSx7IngiOjQ2Ni4wMzEyNSwieSI6NjIwLjcwMDAwMDc2MjkzOTV9XQ==\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><path d=\"M466.031,688.7L466.031,688.7L466.031,727.2L410.514,727.2L410.514,763.511\" id=\"state-authorities-0-L_P_REPLAY_P_RESULT_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_P_REPLAY_P_RESULT_0\" data-points=\"W3sieCI6NDY2LjAzMTI1LCJ5Ijo2ODguNzAwMDAwNzYyOTM5NX0seyJ4Ijo0NjYuMDMxMjUsInkiOjcyNy4yMDAwMDA3NjI5Mzk1fSx7IngiOjQwNy4xNjY2OTg2MTk2MzE5LCJ5Ijo3NjUuNzAwMDAwNzYyOTM5NX1d\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><path d=\"M171.011,186.5L145.809,186.5L145.809,240.6L145.809,240.6L145.809,346.7L145.809,346.7L145.809,437.2L145.809,437.2L145.809,509.7L145.809,509.7L145.809,582.2L145.809,582.2L145.809,654.7L145.809,654.7L145.809,727.2L234.523,727.2L234.523,764.162\" id=\"state-authorities-0-L_P_PRIVATE_P_RESULT_0\" class=\"edge-thickness-thick edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\"stroke:#ef4444;stroke-width:4px;color:#f87171;fill:none;;;stroke:#ef4444;stroke-width:4px;color:#f87171;fill:none\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_P_PRIVATE_P_RESULT_0\" data-points=\"W3sieCI6MTcxLjAxMTMwMzM1ODY5OTgyLCJ5IjoxODYuNX0seyJ4IjoxNDUuODA4NTkzNzUsInkiOjI0MC42MDAwMDAzODE0Njk3M30seyJ4IjoxNDUuODA4NTkzNzUsInkiOjM0Ni43MDAwMDA3NjI5Mzk0NX0seyJ4IjoxNDUuODA4NTkzNzUsInkiOjQzNy4yMDAwMDA3NjI5Mzk0NX0seyJ4IjoxNDUuODA4NTkzNzUsInkiOjUwOS43MDAwMDA3NjI5Mzk0NX0seyJ4IjoxNDUuODA4NTkzNzUsInkiOjU4Mi4yMDAwMDA3NjI5Mzk1fSx7IngiOjE0NS44MDg1OTM3NSwieSI6NjU0LjcwMDAwMDc2MjkzOTV9LHsieCI6MTQ1LjgwODU5Mzc1LCJ5Ijo3MjcuMjAwMDAwNzYyOTM5NX0seyJ4IjoyMzguMjE0ODY3NzE0NzIzOTQsInkiOjc2NS43MDAwMDA3NjI5Mzk1fV0=\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd__ef4444)\"\/><\/g><g class=\"edgeLabels\"><g class=\"edgeLabel\" transform=\"translate(328.23046875, 240.60000038146973)\"><g class=\"label\" data-id=\"L_P_PRIVATE_P_CHANGE_0\" transform=\"translate(0, -14.600001335144043)\"><g><rect class=\"background\" style=\"color:#f87171 !important\" x=\"-95.625\" y=\"-0.9999990463256836\" width=\"191.25\" height=\"31.200000762939453\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"fill:#f87171 !important\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">1<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> \u00b7<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> never<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> a<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> delta<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> \u2014<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> but<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> it<\/tspan><\/tspan><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">IS<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> state<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_P_TRUTH_P_CHANGE_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_P_CHANGE_P_DISK_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_P_DISK_P_REPLAY_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_P_REPLAY_P_RESULT_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\" transform=\"translate(145.80859375, 509.70000076293945)\"><g class=\"label\" data-id=\"L_P_PRIVATE_P_RESULT_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"color:#f87171 !important\" x=\"-95.6171875\" y=\"-0.9999990463256836\" width=\"191.234375\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"fill:#f87171 !important\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">2<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> \u00b7<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> rewind<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> cannot<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> reach<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> it<\/tspan><\/tspan><\/text><\/g><\/g><\/g><\/g><g class=\"nodes\"><g class=\"node default unsafe\" id=\"state-authorities-0-flowchart-P_PRIVATE-16\" data-look=\"classic\" transform=\"translate(203.62109375, 116.5)\"><rect class=\"basic label-container\" style=\"fill:#ef444440 !important;stroke:#ef4444 !important;stroke-width:2px !important\" x=\"-132\" y=\"-70\" width=\"264\" height=\"140\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -54)\"><rect\/><foreignobject width=\"200\" height=\"108\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>OUTSIDE THE TREE<br \/>todo \u00b7 retry \u00b7 subagents \u00b7 streaming<br \/>closures \u00b7 prompts \u00b7 tools \u00b7 settings \u00b7 MCP<br \/><b>authoritative, not derived<\/b><\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default change\" id=\"state-authorities-0-flowchart-P_CHANGE-18\" data-look=\"classic\" transform=\"translate(466.03125, 346.70000076293945)\"><rect class=\"basic label-container\" style=\"fill:#f59e0b40 !important;stroke:#f59e0b !important;stroke-width:2px !important\" x=\"-132\" y=\"-52\" width=\"264\" height=\"104\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -36)\"><rect\/><foreignobject width=\"200\" height=\"72\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>UNIT OF CHANGE<br \/><b>message \u00b7 custom \u00b7 custom_message<\/b><br \/>covers the tree only<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default truth\" id=\"state-authorities-0-flowchart-P_TRUTH-17\" data-look=\"classic\" transform=\"translate(523.84375, 116.5)\"><rect class=\"basic label-container\" style=\"fill:#2563eb40 !important;stroke:#3b82f6 !important;stroke-width:2px !important\" x=\"-107.6015625\" y=\"-43\" width=\"215.203125\" height=\"86\"\/><g class=\"label\" style=\"\" transform=\"translate(-75.6015625, -27)\"><rect\/><foreignobject width=\"151.203125\" height=\"54\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>SOURCE OF TRUTH<br \/><b>message tree<\/b><br \/>ids and messages only<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default disk\" id=\"state-authorities-0-flowchart-P_DISK-19\" data-look=\"classic\" transform=\"translate(466.03125, 509.70000076293945)\"><rect class=\"basic label-container\" style=\"fill:#8b5cf640 !important;stroke:#8b5cf6 !important;stroke-width:2px !important\" x=\"-125.6015625\" y=\"-34\" width=\"251.203125\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-93.6015625, -18)\"><rect\/><foreignobject width=\"187.203125\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>ON DISK \u00b7 <b>.jsonl<\/b><br \/>the tree, and nothing else<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default replay\" id=\"state-authorities-0-flowchart-P_REPLAY-20\" data-look=\"classic\" transform=\"translate(466.03125, 654.7000007629395)\"><rect class=\"basic label-container\" style=\"fill:#22c55e40 !important;stroke:#22c55e !important;stroke-width:2px !important\" x=\"-93.203125\" y=\"-34\" width=\"186.40625\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-61.203125, -18)\"><rect\/><foreignobject width=\"122.40625\" height=\"36\"\/><\/g><\/g><g class=\"node default bad\" id=\"state-authorities-0-flowchart-P_RESULT-21\" data-look=\"classic\" transform=\"translate(341.421875, 808.7000007629395)\"><rect class=\"basic label-container\" style=\"fill:#ef4444 !important;stroke:#fca5a5 !important;stroke-width:3px !important\" x=\"-132\" y=\"-43\" width=\"264\" height=\"86\"\/><g class=\"label\" style=\"color:#fff !important\" transform=\"translate(-100, -27)\"><rect\/><foreignobject width=\"200\" height=\"54\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"color: rgb(255, 255, 255) !important; display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span style=\"color:#fff !important\" class=\"nodeLabel\"><\/p>\n<p><b>replay(.jsonl) \u2260 original<\/b><br \/>rewind \u00b7 fork \u00b7 resume all lie<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><\/g><\/g><g class=\"root\" transform=\"translate(21.822265625, 0)\"><g class=\"clusters\"><g class=\"cluster\" id=\"state-authorities-0-CSGO\" data-look=\"classic\"><rect style=\"\" x=\"8\" y=\"8\" width=\"620\" height=\"828.2000007629395\"\/><g class=\"cluster-label\" transform=\"translate(202.7890625, 8)\"><g><rect class=\"background\" style=\"stroke: none\"\/><text y=\"-10.1\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Source<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> engine<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> \u00b7<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> single<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> authority<\/tspan><\/tspan><\/text><\/g><\/g><\/g><\/g><g class=\"edgePaths\"><path d=\"M168,150.5L168,150.5L168,204.6L251.574,204.6L251.574,258.7\" id=\"state-authorities-0-L_C_PRED_C_CHANGE_0\" class=\"edge-thickness-normal edge-pattern-dotted edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_PRED_C_CHANGE_0\" data-points=\"W3sieCI6MTY4LCJ5IjoxNTAuNX0seyJ4IjoxNjgsInkiOjIwNC42MDAwMDAzODE0Njk3M30seyJ4IjoyNTEuNTczNjM1Njg4MzU4ODgsInkiOjI1OC43MDAwMDA3NjI5Mzk0NX1d\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-crossEnd)\"\/><path d=\"M468,150.5L468,150.5L468,204.6L387.784,204.6L387.784,256.526\" id=\"state-authorities-0-L_C_TRUTH_C_CHANGE_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_TRUTH_C_CHANGE_0\" data-points=\"W3sieCI6NDY4LCJ5IjoxNTAuNX0seyJ4Ijo0NjgsInkiOjIwNC42MDAwMDAzODE0Njk3M30seyJ4IjozODQuNDI2MzY0MzExNjQxMSwieSI6MjU4LjcwMDAwMDc2MjkzOTQ1fV0=\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><path d=\"M318,344.7L318,344.7L318,383.2L318,383.2L318,417.7\" id=\"state-authorities-0-L_C_CHANGE_C_DISK_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_CHANGE_C_DISK_0\" data-points=\"W3sieCI6MzE4LCJ5IjozNDQuNzAwMDAwNzYyOTM5NDV9LHsieCI6MzE4LCJ5IjozODMuMjAwMDAwNzYyOTM5NDV9LHsieCI6MzE4LCJ5Ijo0MjEuNzAwMDAwNzYyOTM5NDV9XQ==\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><path d=\"M318,489.7L318,489.7L318,528.2L318,528.2L318,562.7\" id=\"state-authorities-0-L_C_DISK_C_REPLAY_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_DISK_C_REPLAY_0\" data-points=\"W3sieCI6MzE4LCJ5Ijo0ODkuNzAwMDAwNzYyOTM5NDV9LHsieCI6MzE4LCJ5Ijo1MjguMjAwMDAwNzYyOTM5NX0seyJ4IjozMTgsInkiOjU2Ni43MDAwMDA3NjI5Mzk1fV0=\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><path d=\"M318,634.7L318,634.7L318,673.2L318,673.2L318,707.7\" id=\"state-authorities-0-L_C_REPLAY_C_RESULT_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_REPLAY_C_RESULT_0\" data-points=\"W3sieCI6MzE4LCJ5Ijo2MzQuNzAwMDAwNzYyOTM5NX0seyJ4IjozMTgsInkiOjY3My4yMDAwMDA3NjI5Mzk1fSx7IngiOjMxOCwieSI6NzExLjcwMDAwMDc2MjkzOTV9XQ==\" data-look=\"classic\" marker-end=\"url(#state-authorities-0_flowchart-v2-pointEnd)\"\/><\/g><g class=\"edgeLabels\"><g class=\"edgeLabel\" transform=\"translate(168, 204.60000038146973)\"><g class=\"label\" data-id=\"L_C_PRED_C_CHANGE_0\" transform=\"translate(0, -14.600001335144043)\"><g><rect class=\"background\" style=\"\" x=\"-99.21875\" y=\"-0.9999990463256836\" width=\"198.4375\" height=\"31.200000762939453\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">never<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> a<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> delta<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> \u2014<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> fine,<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> it<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> is<\/tspan><\/tspan><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">derived<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_C_TRUTH_C_CHANGE_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_C_CHANGE_C_DISK_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_C_DISK_C_REPLAY_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_C_REPLAY_C_RESULT_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><\/g><g class=\"nodes\"><g class=\"node default safe\" id=\"state-authorities-0-flowchart-C_PRED-0\" data-look=\"classic\" transform=\"translate(168, 98.5)\"><rect class=\"basic label-container\" style=\"fill:#64748b40 !important;stroke:#94a3b8 !important\" x=\"-132\" y=\"-52\" width=\"264\" height=\"104\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -36)\"><rect\/><foreignobject width=\"200\" height=\"72\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>OUTSIDE THE ENTITY LIST<br \/>client prediction<br \/><b>derived, never authoritative<\/b><\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default change\" id=\"state-authorities-0-flowchart-C_CHANGE-2\" data-look=\"classic\" transform=\"translate(318, 301.70000076293945)\"><rect class=\"basic label-container\" style=\"fill:#f59e0b40 !important;stroke:#f59e0b !important;stroke-width:2px !important\" x=\"-96.8046875\" y=\"-43\" width=\"193.609375\" height=\"86\"\/><g class=\"label\" style=\"\" transform=\"translate(-64.8046875, -27)\"><rect\/><foreignobject width=\"129.609375\" height=\"54\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>UNIT OF CHANGE<br \/><b>{ \u0394 entity \u2026 }<\/b><br \/>covers every field<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default truth\" id=\"state-authorities-0-flowchart-C_TRUTH-1\" data-look=\"classic\" transform=\"translate(468, 98.5)\"><rect class=\"basic label-container\" style=\"fill:#2563eb40 !important;stroke:#3b82f6 !important;stroke-width:2px !important\" x=\"-132\" y=\"-52\" width=\"264\" height=\"104\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -36)\"><rect\/><foreignobject width=\"200\" height=\"72\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>SOURCE OF TRUTH<br \/><b>entity list<\/b><br \/>rules \u00b7 plugins \u00b7 globals \u2014 all of it<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default disk\" id=\"state-authorities-0-flowchart-C_DISK-3\" data-look=\"classic\" transform=\"translate(318, 455.70000076293945)\"><rect class=\"basic label-container\" style=\"fill:#8b5cf640 !important;stroke:#8b5cf6 !important;stroke-width:2px !important\" x=\"-89.6015625\" y=\"-34\" width=\"179.203125\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-57.6015625, -18)\"><rect\/><foreignobject width=\"115.203125\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>ON DISK \u00b7 <b>.dem<\/b><br \/>all of the state<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default replay\" id=\"state-authorities-0-flowchart-C_REPLAY-4\" data-look=\"classic\" transform=\"translate(318, 600.7000007629395)\"><rect class=\"basic label-container\" style=\"fill:#22c55e40 !important;stroke:#22c55e !important;stroke-width:2px !important\" x=\"-104\" y=\"-34\" width=\"208\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-72, -18)\"><rect\/><foreignobject width=\"144\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>REPLAY<br \/><b>seek tick, re-derive<\/b><\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default ok\" id=\"state-authorities-0-flowchart-C_RESULT-5\" data-look=\"classic\" transform=\"translate(318, 754.7000007629395)\"><rect class=\"basic label-container\" style=\"fill:#22c55e40 !important;stroke:#22c55e !important;stroke-width:2px !important\" x=\"-132\" y=\"-43\" width=\"264\" height=\"86\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -27)\"><rect\/><foreignobject width=\"200\" height=\"54\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p><b>replay(.dem) == original<\/b><br \/>nothing outside left to leak<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><\/g><\/g><\/g><\/g><marker id=\"state-authorities-0_flowchart-v2-crossEnd__ef4444\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"12\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\" stroke=\"#ef4444\"\/><\/marker><marker id=\"state-authorities-0_flowchart-v2-pointEnd__ef4444\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\" stroke=\"#ef4444\" fill=\"#ef4444\"\/><\/marker><\/g><defs><filter id=\"state-authorities-0-drop-shadow\" height=\"130%\" width=\"130%\"><fedropshadow dx=\"4\" dy=\"4\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><defs><filter id=\"state-authorities-0-drop-shadow-small\" height=\"150%\" width=\"150%\"><fedropshadow dx=\"2\" dy=\"2\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><lineargradient id=\"state-authorities-0-gradient\" gradientunits=\"objectBoundingBox\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"><stop offset=\"0%\" stop-color=\"#2A2A35\" stop-opacity=\"1\"\/><stop offset=\"100%\" stop-color=\"#44CFFF\" stop-opacity=\"1\"\/><\/lineargradient><\/svg><\/div>\n<p><!--\/--><figcaption>One authority versus two: everything in Source is an entity delta, so <code>replay(.dem) == original<\/code>. Pi&#8217;s journal covers the message tree only, while authoritative state lives outside it\u2014rewind, fork, and resume all lie.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010a4500\">There were understandable reasons to arrive here. Repeating the system prompt and <code data-hk=\"000000010000000000004000010a450100\">AGENTS.md<\/code> in<br \/>\nevery log would be wasteful; that can be solved by hashing the template and storing its variables.<br \/>\nAnd this style of state modeling is not common in TypeScript, which does not actually have runtime<br \/>\ntypes.<\/p>\n<p data-hk=\"000000010000000000004000010a4600\">The result, however, is still two sources of truth:<\/p>\n<p data-hk=\"000000010000000000004000010a4800\">The globals row is where it gets funny. Source does not have session globals; they are simply<br \/>\nproperties of an entity. Ours have their own hierarchy:<\/p>\n<figure data-hk=\"000000010000000000004000010a49\"><!--$--><\/p>\n<div data-hk=\"000000010000000000004000010a500\" class=\"st-mermaid \" role=\"img\" aria-label=\"Decision tree for where a session-global fact lives in omp: journaled tree entries (three blessed types, replays correctly), journalable custom entries (every extension hand-rolls its own derive, roughly fifteen lifecycle bugs), or not journaled at all (AGENTS.md, extension set, tool roster, settings, provider config, MCP servers \u2014 cannot branch, cannot rewind).\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" id=\"state-globals-0\" width=\"100%\" class=\"flowchart\" style=\"max-width: 1030px;\" viewbox=\"0 0 1030 625.2000122070312\" role=\"graphics-document document\" aria-roledescription=\"flowchart-v2\"><g><marker id=\"state-globals-0_flowchart-v2-pointEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-pointStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"4.5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-pointEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"11.5\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"10.5\" markerheight=\"14\" orient=\"auto\"><path d=\"M 0 0 L 11.5 7 L 0 14 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-pointStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"1\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"11.5\" markerheight=\"14\" orient=\"auto\"><polygon points=\"0,7 11.5,14 11.5,0\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-circleEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"11\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-circleStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-1\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-circleEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refy=\"5\" refx=\"12.25\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-circleStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-2\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-crossEnd\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"12\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-crossStart\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"-1\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-crossEnd-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"17.7\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5;\"\/><\/marker><marker id=\"state-globals-0_flowchart-v2-crossStart-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"-3.5\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5; stroke-dasharray: 1, 0;\"\/><\/marker><g class=\"root\"><g class=\"clusters\"\/><g class=\"edgePaths\"><path d=\"M364.442,162.442L140,162.442L140,279.6L140,279.6L140,317.2\" id=\"state-globals-0-L_Q_A_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_Q_A_0\" data-points=\"W3sieCI6MzY0LjQ0MTUyNDM3MzI0NDE0LCJ5IjoxNjIuNDQxNTI0MzczMjQ0MTR9LHsieCI6MTQwLCJ5IjoyNzkuNjAwMDAwMzgxNDY5N30seyJ4IjoxNDAsInkiOjMyMS4yMDAwMDA3NjI5Mzk0NX1d\" data-look=\"classic\" marker-end=\"url(#state-globals-0_flowchart-v2-pointEnd)\"\/><path d=\"M440,238L440,238L440,279.6L440,279.6L440,317.2\" id=\"state-globals-0-L_Q_B_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_Q_B_0\" data-points=\"W3sieCI6NDQwLCJ5IjoyMzh9LHsieCI6NDQwLCJ5IjoyNzkuNjAwMDAwMzgxNDY5N30seyJ4Ijo0NDAsInkiOjMyMS4yMDAwMDA3NjI5Mzk0NX1d\" data-look=\"classic\" marker-end=\"url(#state-globals-0_flowchart-v2-pointEnd)\"\/><path d=\"M515.558,162.442L740,162.442L740,279.6L740,279.6L740,317.2\" id=\"state-globals-0-L_Q_C_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_Q_C_0\" data-points=\"W3sieCI6NTE1LjU1ODQ3NTYyNjc1NTksInkiOjE2Mi40NDE1MjQzNzMyNDQxNH0seyJ4Ijo3NDAsInkiOjI3OS42MDAwMDAzODE0Njk3fSx7IngiOjc0MCwieSI6MzIxLjIwMDAwMDc2MjkzOTQ1fV0=\" data-look=\"classic\" marker-end=\"url(#state-globals-0_flowchart-v2-pointEnd)\"\/><path d=\"M634.828,443.2L590,443.2L590,469.2L590,469.2L590,500.2\" id=\"state-globals-0-L_C_C1_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_C1_0\" data-points=\"W3sieCI6NjM0LjgyNzU4NjIwNjg5NjUsInkiOjQ0My4yMDAwMDA3NjI5Mzk0NX0seyJ4Ijo1OTAsInkiOjQ2OS4yMDAwMDA3NjI5Mzk0NX0seyJ4Ijo1OTAsInkiOjUwNC4yMDAwMDA3NjI5Mzk0NX1d\" data-look=\"classic\" marker-end=\"url(#state-globals-0_flowchart-v2-pointEnd)\"\/><path d=\"M845.172,443.2L890,443.2L890,469.2L890,469.2L890,491.2\" id=\"state-globals-0-L_C_C2_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_C2_0\" data-points=\"W3sieCI6ODQ1LjE3MjQxMzc5MzEwMzUsInkiOjQ0My4yMDAwMDA3NjI5Mzk0NX0seyJ4Ijo4OTAsInkiOjQ2OS4yMDAwMDA3NjI5Mzk0NX0seyJ4Ijo4OTAsInkiOjQ5NS4yMDAwMDA3NjI5Mzk0NX1d\" data-look=\"classic\" marker-end=\"url(#state-globals-0_flowchart-v2-pointEnd)\"\/><\/g><g class=\"edgeLabels\"><g class=\"edgeLabel\" transform=\"translate(140, 279.6000003814697)\"><g class=\"label\" data-id=\"L_Q_A_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-92.015625\" y=\"-0.9999990463256836\" width=\"184.03125\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">journaled<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> as<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> tree<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> entries<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(440, 279.6000003814697)\"><g class=\"label\" data-id=\"L_Q_B_0\" transform=\"translate(0, -14.600001335144043)\"><g><rect class=\"background\" style=\"\" x=\"-81.2109375\" y=\"-0.9999990463256836\" width=\"162.421875\" height=\"31.200000762939453\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">journalable<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> via<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> custom<\/tspan><\/tspan><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">entries<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(740, 279.6000003814697)\"><g class=\"label\" data-id=\"L_Q_C_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-74.015625\" y=\"-0.9999990463256836\" width=\"148.03125\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">not<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> journaled<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> at<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> all<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_C_C1_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_C_C2_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><\/g><g class=\"nodes\"><g class=\"node default question\" id=\"state-globals-0-flowchart-Q-0\" data-look=\"classic\" transform=\"translate(440, 123)\"><polygon points=\"115,0 230,-115 115,-230 0,-115\" class=\"label-container\" transform=\"translate(-114.5, 115)\" style=\"fill:#2563eb40 !important;stroke:#3b82f6 !important;stroke-width:2px !important\"\/><g class=\"label\" style=\"\" transform=\"translate(-90, -9)\"><rect\/><foreignobject width=\"180\" height=\"18\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>is this fact in the tree?<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default ok\" id=\"state-globals-0-flowchart-A-2\" data-look=\"classic\" transform=\"translate(140, 382.20000076293945)\"><rect class=\"basic label-container\" style=\"fill:#22c55e40 !important;stroke:#22c55e !important;stroke-width:2px !important\" x=\"-132\" y=\"-61\" width=\"264\" height=\"122\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -45)\"><rect\/><foreignobject width=\"200\" height=\"90\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>A \u2713 the blessed ~3<br \/>model_change \u00b7 thinking_level_change<br \/>session_info \u00b7 label<br \/>replays correctly<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default mid\" id=\"state-globals-0-flowchart-B-4\" data-look=\"classic\" transform=\"translate(440, 382.20000076293945)\"><rect class=\"basic label-container\" style=\"fill:#f59e0b40 !important;stroke:#f59e0b !important;stroke-width:2px !important\" x=\"-132\" y=\"-61\" width=\"264\" height=\"122\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -45)\"><rect\/><foreignobject width=\"200\" height=\"90\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>B ~ hand-rolled<br \/>every extension writes its own derive<br \/>\u224815 lifecycle bugs, see below<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default bad\" id=\"state-globals-0-flowchart-C-6\" data-look=\"classic\" transform=\"translate(740, 382.20000076293945)\"><rect class=\"basic label-container\" style=\"fill:#ef444440 !important;stroke:#ef4444 !important;stroke-width:2px !important\" x=\"-132\" y=\"-61\" width=\"264\" height=\"122\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -45)\"><rect\/><foreignobject width=\"200\" height=\"90\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>C \u2717 outside history<br \/>AGENTS.md \u00b7 extension set \u00b7 tool roster<br \/>settings \u00b7 provider config \u00b7 MCP servers<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default bad\" id=\"state-globals-0-flowchart-C1-8\" data-look=\"classic\" transform=\"translate(590, 556.2000007629395)\"><rect class=\"basic label-container\" style=\"fill:#ef444440 !important;stroke:#ef4444 !important;stroke-width:2px !important\" x=\"-132\" y=\"-52\" width=\"264\" height=\"104\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -36)\"><rect\/><foreignobject width=\"200\" height=\"72\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>edit AGENTS.md \u2192 the replay uses today&#8217;s copy.<br \/>the session you recorded is gone.<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default bad\" id=\"state-globals-0-flowchart-C2-10\" data-look=\"classic\" transform=\"translate(890, 556.2000007629395)\"><rect class=\"basic label-container\" style=\"fill:#ef444440 !important;stroke:#ef4444 !important;stroke-width:2px !important\" x=\"-132\" y=\"-61\" width=\"264\" height=\"122\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -45)\"><rect\/><foreignobject width=\"200\" height=\"90\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>header line = (version, id, timestamp, cwd)<br \/>no parentid \u2192 not in the tree \u2192<br \/>can&#8217;t branch, can&#8217;t rewind<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><\/g><\/g><\/g><defs><filter id=\"state-globals-0-drop-shadow\" height=\"130%\" width=\"130%\"><fedropshadow dx=\"4\" dy=\"4\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><defs><filter id=\"state-globals-0-drop-shadow-small\" height=\"150%\" width=\"150%\"><fedropshadow dx=\"2\" dy=\"2\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><lineargradient id=\"state-globals-0-gradient\" gradientunits=\"objectBoundingBox\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"><stop offset=\"0%\" stop-color=\"#2A2A35\" stop-opacity=\"1\"\/><stop offset=\"100%\" stop-color=\"#44CFFF\" stop-opacity=\"1\"\/><\/lineargradient><\/svg><\/div>\n<p><!--\/--><figcaption>The three tiers of session globals, one of which works.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010a5100\">Source did not get its correctness by writing a careful reconciler or excellent documentation. It<br \/>\nmade non-replayable state <em data-hk=\"000000010000000000004000010a510100\">unrepresentable<\/em>. <strong data-hk=\"000000010000000000004000010a510200\">Correctness comes from that constraint<\/strong>, not from<br \/>\nevery extension author remembering to register two hooks and define an update shape.<\/p>\n<h3 data-hk=\"000000010000000000004000010a5200\" id=\"the-evidence-correctness-is-optional-in-the-api\">The evidence: correctness is optional in the API<\/h3>\n<p data-hk=\"000000010000000000004000010a5300\">We looked at the 78 official Pi extension examples. Sixty were stateless; among the 17 with state, only two<br \/>\nwere correct.<\/p>\n<p data-hk=\"000000010000000000004000010a5500\">You can find the details in <a data-hk=\"000000010000000000004000010a550100\" href=\"#appendix-a-state-failures-in-the-official-examples\">Appendix A<\/a>, but the important<br \/>\npoint is that documentation would not repair this distribution of bugs. The engine needs one place<br \/>\nwhere state can exist.<\/p>\n<figure data-hk=\"000000010000000000004000010a56\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/tic-tac-toe.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><figcaption><!--$--><code data-hk=\"000000010000000000004000010a5700\">tic-tac-toe.ts<\/code><!--\/-->: play X, crash before O replies, resume, and X is gone. Live writes and restore reads use different entry types.<\/figcaption><\/figure>\n<h3 data-hk=\"000000010000000000004000010a5800\" id=\"what-omp-changes-one-materialized-session\">What omp\u00b2 changes: one materialized session<\/h3>\n<p data-hk=\"000000010000000000004000010a5900\">What if the whole session materializes as <strong data-hk=\"000000010000000000004000010a590100\">one DOM<\/strong>? Of course you can also use a ECS system with serialization, or any other<br \/>\nrepresentation format you wish, I mainly chose XML as it makes the state very easy to compose, inspect and debug.<\/p>\n<pre data-hk=\"000000010000000000004000010a6000\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010a600100\"><span data-hk=\"000000010000000000004000010a60010100\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001010100\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010a6001010200\" style=\"color:#FF54C0\">meta<\/span><span data-hk=\"000000010000000000004000010a6001010300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010200\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001020100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010a6001020200\" style=\"color:#FF54C0\">todo<\/span><span data-hk=\"000000010000000000004000010a6001020300\" style=\"color:#CFD4DC\">&gt;\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010a6001020400\" style=\"color:#FF54C0\">todo<\/span><span data-hk=\"000000010000000000004000010a6001020500\" style=\"color:#CFD4DC\">&gt;          <\/span><span data-hk=\"000000010000000000004000010a6001020600\" style=\"color:#CFD4DC8F;fontStyle:italic\">&lt;!-- persistent components, journal-derived --&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010300\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001030100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010a6001030200\" style=\"color:#FF54C0\">jobs<\/span><span data-hk=\"000000010000000000004000010a6001030300\" style=\"color:#CFD4DC\">&gt;\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010a6001030400\" style=\"color:#FF54C0\">jobs<\/span><span data-hk=\"000000010000000000004000010a6001030500\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010400\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001040100\" style=\"color:#CFD4DC\">&lt;\/<\/span><span data-hk=\"000000010000000000004000010a6001040200\" style=\"color:#FF54C0\">meta<\/span><span data-hk=\"000000010000000000004000010a6001040300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010500\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001050100\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010a6001050200\" style=\"color:#FF54C0\">body<\/span><span data-hk=\"000000010000000000004000010a6001050300\" style=\"color:#CFD4DC\">&gt;                     <\/span><span data-hk=\"000000010000000000004000010a6001050400\" style=\"color:#CFD4DC8F;fontStyle:italic\">&lt;!-- the live chain, entries as elements --&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010600\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001060100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010a6001060200\" style=\"color:#FF54C0\">user<\/span><span data-hk=\"000000010000000000004000010a6001060300\" style=\"color:#9BE8FF\"> id<\/span><span data-hk=\"000000010000000000004000010a6001060400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010a6001060500\" style=\"color:#B99AFF\">\"e12\"<\/span><span data-hk=\"000000010000000000004000010a6001060600\" style=\"color:#CFD4DC\">&gt;\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010a6001060700\" style=\"color:#FF54C0\">user<\/span><span data-hk=\"000000010000000000004000010a6001060800\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010700\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001070100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010a6001070200\" style=\"color:#FF54C0\">ai<\/span><span data-hk=\"000000010000000000004000010a6001070300\" style=\"color:#9BE8FF\"> id<\/span><span data-hk=\"000000010000000000004000010a6001070400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010a6001070500\" style=\"color:#B99AFF\">\"e13\"<\/span><span data-hk=\"000000010000000000004000010a6001070600\" style=\"color:#CFD4DC\">&gt;\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010a6001070700\" style=\"color:#FF54C0\">ai<\/span><span data-hk=\"000000010000000000004000010a6001070800\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010800\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001080100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010a6001080200\" style=\"color:#FF54C0\">Read<\/span><span data-hk=\"000000010000000000004000010a6001080300\" style=\"color:#9BE8FF\"> id<\/span><span data-hk=\"000000010000000000004000010a6001080400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010a6001080500\" style=\"color:#B99AFF\">\"e14\"<\/span><span data-hk=\"000000010000000000004000010a6001080600\" style=\"color:#9BE8FF\"> status<\/span><span data-hk=\"000000010000000000004000010a6001080700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010a6001080800\" style=\"color:#B99AFF\">\"ok\"<\/span><span data-hk=\"000000010000000000004000010a6001080900\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010900\" class=\"line \"><span data-hk=\"000000010000000000004000010a6001090100\" style=\"color:#CFD4DC\">      &lt;<\/span><span data-hk=\"000000010000000000004000010a6001090200\" style=\"color:#FF54C0\">input<\/span><span data-hk=\"000000010000000000004000010a6001090300\" style=\"color:#9BE8FF\"> path<\/span><span data-hk=\"000000010000000000004000010a6001090400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010a6001090500\" style=\"color:#B99AFF\">\"src\/main.rs:1-80\"<\/span><span data-hk=\"000000010000000000004000010a6001090600\" style=\"color:#CFD4DC\">\/&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010a60010a100100\" style=\"color:#CFD4DC\">      &lt;<\/span><span data-hk=\"000000010000000000004000010a60010a100200\" style=\"color:#FF54C0\">result<\/span><span data-hk=\"000000010000000000004000010a60010a100300\" style=\"color:#9BE8FF\"> lines<\/span><span data-hk=\"000000010000000000004000010a60010a100400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010a60010a100500\" style=\"color:#B99AFF\">\"80\"<\/span><span data-hk=\"000000010000000000004000010a60010a100600\" style=\"color:#CFD4DC\">&gt;\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010a60010a100700\" style=\"color:#FF54C0\">result<\/span><span data-hk=\"000000010000000000004000010a60010a100800\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010a60010a110100\" style=\"color:#CFD4DC\">   &lt;\/<\/span><span data-hk=\"000000010000000000004000010a60010a110200\" style=\"color:#FF54C0\">Read<\/span><span data-hk=\"000000010000000000004000010a60010a110300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010a60010a120100\" style=\"color:#CFD4DC\">&lt;\/<\/span><span data-hk=\"000000010000000000004000010a60010a120200\" style=\"color:#FF54C0\">body<\/span><span data-hk=\"000000010000000000004000010a60010a120300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010a60010a130100\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010a60010a130200\" style=\"color:#FF54C0\">queues<\/span><span data-hk=\"000000010000000000004000010a60010a130300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010a60010a140100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010a60010a140200\" style=\"color:#FF54C0\">steering<\/span><span data-hk=\"000000010000000000004000010a60010a140300\" style=\"color:#CFD4DC\">&gt;...&lt;\/<\/span><span data-hk=\"000000010000000000004000010a60010a140400\" style=\"color:#FF54C0\">steering<\/span><span data-hk=\"000000010000000000004000010a60010a140500\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010a1500\" class=\"line \"><span data-hk=\"000000010000000000004000010a60010a150100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010a60010a150200\" style=\"color:#FF54C0\">prompts<\/span><span data-hk=\"000000010000000000004000010a60010a150300\" style=\"color:#CFD4DC\">&gt;...&lt;\/<\/span><span data-hk=\"000000010000000000004000010a60010a150400\" style=\"color:#FF54C0\">prompts<\/span><span data-hk=\"000000010000000000004000010a60010a150500\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a60010a1600\" class=\"line \"><span data-hk=\"000000010000000000004000010a60010a160100\" style=\"color:#CFD4DC\">&lt;\/<\/span><span data-hk=\"000000010000000000004000010a60010a160200\" style=\"color:#FF54C0\">queues<\/span><span data-hk=\"000000010000000000004000010a60010a160300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010a6100\">Its events are a property-change stream:<\/p>\n<pre data-hk=\"000000010000000000004000010a6200\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010a620100\"><span data-hk=\"000000010000000000004000010a62010100\" class=\"line \"><span data-hk=\"000000010000000000004000010a6201010100\">: todo.done<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a62010200\" class=\"line \"><span data-hk=\"000000010000000000004000010a6201020100\">event: patch@1<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a62010300\" class=\"line \"><span data-hk=\"000000010000000000004000010a6201030100\">by: e41<\/span><\/span>\n<span data-hk=\"000000010000000000004000010a62010400\" class=\"line \"><span data-hk=\"000000010000000000004000010a6201040100\">data: {\"ops\":[[\"set\",412,\"status\",\"completed\"],[\"set\",415,\"status\",\"in_progress\"]]}<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010a6300\">The tree is the authority; the journal stores its incremental changes. Runtime objects may cache or<br \/>\nindex it, but they do not become a second place where truth lives. At any journal point, the harness<br \/>\ncan materialize\u2014and therefore snapshot\u2014the whole session.<\/p>\n<h3 data-hk=\"000000010000000000004000010a6400\" id=\"what-one-authority-buys\">What one authority buys<\/h3>\n<p data-hk=\"000000010000000000004000010a6500\">With state and transcript in one tree, several hard problems reduce to the same operation.<\/p>\n<p data-hk=\"000000010000000000004000010a6600\"><strong data-hk=\"000000010000000000004000010a660100\">Rewind is a DOM diff.<\/strong> Diff the current materialization against the target state. A <code data-hk=\"000000010000000000004000010a660200\">&lt;subagent&gt;<\/code><br \/>\nelement disappeared? Terminate it by destroying the element. One appeared? Resume or spawn it by<br \/>\ncreating the element. The delta itself is the complete lifecycle work list.<\/p>\n<blockquote data-hk=\"000000010000000000004000010a6700\">\n<p data-hk=\"000000010000000000004000010a670100\">Adding a stateful feature never adds a call site to rewind, fork, resume, or replication.<\/p>\n<\/blockquote>\n<p data-hk=\"000000010000000000004000010a6800\"><strong data-hk=\"000000010000000000004000010a680100\">Prompts become projections.<\/strong> There is no 100-line state object passed into every template. The<br \/>\nsystem prompt reads the same tree as everything else:<\/p>\n<pre data-hk=\"000000010000000000004000010a6900\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010a690100\"><span data-hk=\"000000010000000000004000010a69010100\" class=\"line \"><span data-hk=\"000000010000000000004000010a6901010100\">- {{ count(select(\"todo item[status!=completed]\")) }} open items<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010a7000\"><strong data-hk=\"000000010000000000004000010a700100\">Replication becomes subscription.<\/strong> We already have the application and the derivation. A remote<br \/>\nclient consumes the patch stream instead of tailing a file. The remote-driver and spectator cases no<br \/>\nlonger require separate state plumbing.<\/p>\n<p data-hk=\"000000010000000000004000010a7100\"><strong data-hk=\"000000010000000000004000010a710100\">Rendering becomes projection.<\/strong> A component registry can render <code data-hk=\"000000010000000000004000010a710200\">Read<\/code>, <code data-hk=\"000000010000000000004000010a710300\">Bash<\/code>, a message, or a<br \/>\nsubagent from the same element state. Streaming arguments mutate <code data-hk=\"000000010000000000004000010a710400\">&lt;input&gt;<\/code>; streaming output mutates<br \/>\n<code data-hk=\"000000010000000000004000010a710500\">&lt;result&gt;<\/code>. Chapter seven turns this into a typed interface rather than another bespoke renderer.<\/p>\n<h3 data-hk=\"000000010000000000004000010a7200\" id=\"controller-and-actor\">Controller and actor<\/h3>\n<p data-hk=\"000000010000000000004000010a7300\">This separation also makes subagents inspectable. Pi&#8217;s views read live session state directly\u2014the<br \/>\nfooter calls <code data-hk=\"000000010000000000004000010a730100\">sessionManager.getEntries()<\/code>\u2014so adding \u201cinspect subagent\u201d means plumbing controller<br \/>\nstate through UI internals.<\/p>\n<p data-hk=\"000000010000000000004000010a7400\">Keep controller and actor completely separate: the controller owns session state; actors only<br \/>\nrender its snapshot and patch stream. The TUI, remote client, and subagent inspector become peers.<br \/>\nInspecting a child means pointing the same actor at the child&#8217;s state.<\/p>\n<p data-hk=\"000000010000000000004000010a7500\">A truthful state model is the foundation, but it can still be undermined if untrusted code owns the<br \/>\npolicy that mutates it. The next chapter draws the runtime boundary.<\/p>\n<h2 data-hk=\"000000010000000000004000010a7600\" id=\"the-runtime\">The runtime<\/h2>\n<aside data-hk=\"000000010000000000004000010a770\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Keep policy on the trusted host; put only a bandwidth-bounded execution stub inside the sandbox.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010a7710\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010a7800\">The state chapter established what the harness believes. The runtime chapter decides who may change<br \/>\nit, where untrusted work runs, and what a \u201ctool call\u201d means once execution can last hours, stream<br \/>\noutput, or ignore a polite request to stop.<\/p>\n<h3 data-hk=\"000000010000000000004000010a7900\" id=\"the-sandbox-should-execute-not-decide\">The sandbox should execute, not decide<\/h3>\n<p data-hk=\"000000010000000000004000010a8000\">Start with the <em data-hk=\"000000010000000000004000010a800100\">Factorio<\/em> case from the design envelope. Suppose we clone roboomp, ask gpt spark to replace every mention of its name with CodeWhatever,<br \/>\nand start charging people thousands for our magic technique. Who runs the tools? The VM, duh.<br \/>\nYeah, right.<\/p>\n<p data-hk=\"000000010000000000004000010a8100\">Here is what happens when we put the executor in the VM:<\/p>\n<figure data-hk=\"000000010000000000004000010a82\"><svg data-hk=\"000000010000000000004000010a8300\" class=\"st-sketch\" viewbox=\"0 0 1000 560\" role=\"img\" aria-label=\"Hand-drawn sketch titled 'tools are complicated': a trusted driver harness on one side of a trust boundary, an untrusted VM on the other, and four tools \u2014 todo, file read\/write, image-gen, py-eval \u2014 whose state, secrets, and outputs land on conflicting sides once programmatic tool usage enters the picture.\" font-family=\"var(--st-font-sketch)\"><defs><pattern id=\"exec-dots\" width=\"22\" height=\"22\" patternunits=\"userSpaceOnUse\"><circle cx=\"11\" cy=\"11\" r=\"1.1\" fill=\"#2E333C\"\/><\/pattern><\/defs><rect width=\"1000\" height=\"560\" fill=\"#121419\"\/><rect width=\"1000\" height=\"560\" fill=\"url(#exec-dots)\"\/><!--$--><text data-hk=\"000000010000000000004000010a830100\" x=\"305\" y=\"50\" font-size=\"30\" fill=\"#DBD8CF\" text-anchor=\"middle\" letter-spacing=\"2\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">TOOLS ARE COMPLICATED<\/text><path data-hk=\"000000010000000000004000010a830110\" d=\"M61.5 62.8C207.9 65.3 432.8 60.1 550.6 61.1M60.4 61.8C251.8 59.8 429.8 65.1 548.8 62.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a83020\" x=\"136.5\" y=\"81.5\" width=\"212\" height=\"79\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a83021\" d=\"M134.1 80.5C220.1 79.1 287.8 83.6 351.3 80.5M132.3 79.2C232.6 78.9 304.1 80.9 349.8 78.9M350.5 77.6C348.3 113.9 350.2 135.2 351.2 161M348.9 78.2C349.9 105.9 349.5 148.2 349.2 163.4M351.6 161.2C252.3 162.6 194.5 163.8 133.8 161.3M351.5 161.6C246.9 161.2 184.3 159.7 133.4 162.4M133.7 162.2C134.1 124 133.4 99.6 136.5 78.2M134.5 163.6C133.5 131.4 134.4 99.6 136.3 79.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a83030\" x=\"155\" y=\"131\" font-size=\"26\" fill=\"#DBD8CF\">DRIVER<\/text><g data-hk=\"000000010000000000004000010a8304\" transform=\"translate(316 125) scale(1.35) translate(-316 -125)\"><ellipse data-hk=\"000000010000000000004000010a830500\" cx=\"316\" cy=\"125\" rx=\"13\" ry=\"13\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a830501\" d=\"M327.2 129.4Q325.6 133.7 320.8 136Q316 138.3 311.5 136.3Q307 134.2 304.7 129.6Q302.5 125 304.4 120.4Q306.4 115.8 311.2 114Q316 112.3 320.8 113.9Q325.7 115.5 327.3 120.3Q328.8 125 327.2 129.4M326.7 129.4Q324.7 133.9 320.4 135.8Q316 137.7 311.1 136.1Q306.3 134.5 304.7 129.7Q303 125 305.3 120.6Q307.5 116.3 311.8 113.7Q316 111.1 320.3 113.1Q324.7 115.1 326.7 120.1Q328.7 125 326.7 129.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830510\" d=\"M320.2 126Q319.5 127.1 317.8 128Q316 128.9 314.8 128.6Q313.5 128.3 312.6 126.7Q311.6 125 312.2 123.3Q312.8 121.5 314.4 120.9Q316 120.3 317.7 120.9Q319.4 121.5 320.2 123.2Q320.9 125 320.2 126M319.7 126.5Q319.1 128 317.5 128.4Q316 128.8 314.3 128.1Q312.7 127.3 312.4 126.1Q312.1 125 312.5 123.4Q312.9 121.9 314.4 121.6Q316 121.4 317.5 121.6Q318.9 121.9 319.7 123.4Q320.4 125 319.7 126.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830520\" d=\"M316.4 121.2C315.7 117.5 316.3 114.3 316.2 113.5M316 120.8C316.5 118 316.2 114.2 315.5 113.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830530\" d=\"M312.3 126.5C309 128.3 307.8 129.4 305.8 131M312.9 126.7C309.2 128.2 307 130.3 305.1 130.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830540\" d=\"M320 127.6C322.1 128.9 324.3 129.9 326.6 130.9M319.8 126.6C323.1 129 323.8 129.6 326.2 131.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><\/g><text data-hk=\"000000010000000000004000010a83060\" x=\"137\" y=\"193\" font-size=\"19\" fill=\"#DBD8CF\">trusted harness<\/text><path data-hk=\"000000010000000000004000010a83070\" d=\"M499 73.5C498.9 120.1 498 150.3 498.8 167M499.3 72.9C500.6 111.9 501.7 149.2 499.6 167.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"4\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a83080\" x=\"500\" y=\"192\" font-size=\"18\" fill=\"#DBD8CF\" text-anchor=\"middle\">trust<\/text><text data-hk=\"000000010000000000004000010a83090\" x=\"500\" y=\"216\" font-size=\"18\" fill=\"#DBD8CF\" text-anchor=\"middle\">boundary<\/text><path data-hk=\"000000010000000000004000010a830a100\" d=\"M350.8 123.6Q430.9 111.2 482.4 112.2Q533.9 113.3 574.9 117.5L615.9 121.8M352.9 123.8Q429.9 112 482.5 112.6Q535.2 113.2 574.6 118.1L614 122.9M615.3 122.9C612.1 123.9 607 125.4 604.3 125.8M614.7 123C609.9 124.4 607.1 124.9 604.6 125.9M615.2 123.1C612.2 121.7 608.9 119.1 605.3 117.5M615.2 123.1C610.7 119.7 608.3 118.8 605.9 117.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2.2\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a830a110\" x=\"621.5\" y=\"79.5\" width=\"157\" height=\"79\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a830a111\" d=\"M620 76.5C676.4 77.1 751.7 75.3 782.2 77M618.1 78.7C691.2 76.8 739.9 76.1 780.6 78.4M780.5 75.1C781.3 107.8 780.3 135.1 779.8 160.6M780.8 77.7C778.7 103.3 778.9 141.6 780.2 162.4M780.6 161.2C728.4 162.1 641.2 158 619.2 160.2M782.4 160.8C699.9 161.1 658.2 159.4 618.9 158.8M619.9 161.8C620.6 133.1 621 94.9 619.9 78.4M619.2 160.7C621.3 131.7 622.2 92.5 618.5 77.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a830a120\" x=\"649\" y=\"131\" font-size=\"27\" fill=\"#DBD8CF\">VM<\/text><path data-hk=\"000000010000000000004000010a830a130\" d=\"M734.8 124.7Q746.2 139.5 755.2 119.8L764.1 100.1M734.4 123.6Q745.1 138.9 753.8 120.2L762.5 101.5\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a830a140\" x=\"623\" y=\"191\" font-size=\"17\" fill=\"#DBD8CF\">untrusted: code exec,<\/text><text data-hk=\"000000010000000000004000010a830a150\" x=\"760\" y=\"215\" font-size=\"17\" fill=\"#DBD8CF\">web content<\/text><text data-hk=\"000000010000000000004000010a830a160\" x=\"55\" y=\"257\" font-size=\"20\" fill=\"#DBD8CF\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">WHERE DOES EACH TOOL LIVE?<\/text><text data-hk=\"000000010000000000004000010a830a170\" x=\"60\" y=\"301\" font-size=\"21\" fill=\"#DBD8CF\">1) TODO<\/text><path data-hk=\"000000010000000000004000010a830a180\" d=\"M719.6 283.5Q519.8 284.8 434.6 284.4Q349.4 284.1 283.1 283.4L216.9 282.8M719.8 283.8Q520.1 284 434.6 283.8Q349.1 283.5 283.5 283.4L218 283.3M217.8 284C222.6 282 226 280.4 227.7 279.4M218 284.2C221.4 282.5 224.5 281.4 228.3 279.3M218 283.9C221.8 285.4 224.3 287 228 288.7M218 284.3C223.2 286.1 225.4 287.6 228 288.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a830a190\" x=\"735\" y=\"291\" font-size=\"19\" fill=\"#DBD8CF\">harness state<\/text><text data-hk=\"000000010000000000004000010a830a200\" x=\"60\" y=\"347\" font-size=\"21\" fill=\"#DBD8CF\">2) FILE R\/W<\/text><path data-hk=\"000000010000000000004000010a830a210\" d=\"M287.4 330.2Q479.4 331.2 532.5 324.3Q585.5 317.4 652.4 317.4L719.2 317.4M286.1 329.1Q479.5 330.8 532.2 323.8Q584.9 316.9 652.8 317.5L720.6 318.1M719.7 318.3C717 319.8 712.5 321.4 709.7 322.7M720.3 317.8C715.9 319.4 712.7 321 710.3 322.8M719.8 318.3C715.3 315.5 712.1 314.6 709.7 313.7M720.2 317.7C715.3 316.2 713.4 315 710.1 313.6M287.2 330.3C291.4 328.1 294.4 326.6 297.1 325.5M286.8 330.4C290.9 328.3 294.5 326.7 297.1 325.7M287 330.1C291.6 332.1 295 333.9 297.4 334.3M287 329.9C290 331.6 295.1 333.3 296.7 334.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a830a220\" x=\"735\" y=\"338\" font-size=\"19\" fill=\"#DBD8CF\">which side?<\/text><text data-hk=\"000000010000000000004000010a830a230\" x=\"60\" y=\"394\" font-size=\"21\" fill=\"#DBD8CF\">3) IMAGE-GEN<\/text><g data-hk=\"000000010000000000004000010a830a24\" transform=\"translate(306 374) scale(-1.35 1.35) translate(-306 -374)\"><ellipse data-hk=\"000000010000000000004000010a830a2500\" cx=\"306\" cy=\"374\" rx=\"5\" ry=\"5\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a830a2501\" d=\"M309.7 375.5Q308.8 377 307.4 377.6Q306 378.3 304.6 378.2Q303.1 378.2 302.1 376.1Q301 374 301.4 371.9Q301.9 369.7 303.9 369.8Q306 369.8 308.1 369.9Q310.3 369.9 310.4 372Q310.6 374 309.7 375.5M310.7 375.7Q309.8 377.4 307.9 378Q306 378.7 304 378.1Q301.9 377.6 300.9 375.8Q299.9 374 301.5 372.3Q303.1 370.6 304.6 370.3Q306 370.1 307.9 370.2Q309.7 370.3 310.6 372.1Q311.6 374 310.7 375.7\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a2510\" d=\"M311.2 378.4C315.8 382.3 322.3 390.5 326.9 392.7M309.2 379.5C316.5 383 321.6 389.6 328.4 393.3\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a2520\" d=\"M319.5 389.4C318.1 391.1 316.4 392.6 315 393.5M318.6 389.1C317.4 391.2 315.3 393.9 314.5 394.2\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a2530\" d=\"M323.7 393.1C322.3 394.6 320.7 397.2 320.4 398.6M324.5 393C322.7 395.3 320.6 397.2 319.8 398.2\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><\/g><path data-hk=\"000000010000000000004000010a830a260\" d=\"M449.9 333.7Q517.9 351.4 569.3 358.5Q620.8 365.6 667.9 365.6L715 365.6M449.5 333.8Q519.1 351.7 569.9 358.7Q620.6 365.6 667.9 366.3L715.1 367M714.1 365.7C709.6 367.7 706.5 369.1 704.1 370.1M714 366.1C710.9 367.6 706.8 369.5 704.3 370.3M714.1 366.3C710.8 364.6 707.3 363 704.1 361.8M714.1 365.8C710.1 364.3 707.1 363.4 703.9 361.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><text data-hk=\"000000010000000000004000010a830a270\" x=\"735\" y=\"385\" font-size=\"19\" fill=\"#DBD8CF\">output lands here<\/text><text data-hk=\"000000010000000000004000010a830a280\" x=\"60\" y=\"441\" font-size=\"21\" fill=\"#DBD8CF\">4) PY-EVAL<\/text><path data-hk=\"000000010000000000004000010a830a2900\" d=\"M262.3 440.4Q263.5 428.9 266.1 428.1Q268.7 427.4 273.1 428.2Q277.4 429.1 278.3 431.3L279.2 433.6M262.3 438.8Q261.7 429.6 264.5 428.3Q267.3 426.9 271.8 427.1Q276.2 427.2 277.4 429.6L278.6 432.1\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a2910\" d=\"M280.6 433.5Q279.4 443 276.1 444.9Q272.8 446.7 269 445.5Q265.2 444.4 264.4 442L263.7 439.5M279.7 433.5Q280.5 441.3 277.4 443.7Q274.2 446.1 269.7 444.5Q265.3 442.9 265.1 440.4L264.9 438\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a2920\" d=\"M267 429.7Q267.4 430.4 266.7 430.4Q266 430.4 265.1 430.6Q264.2 430.8 264.5 429.9Q264.9 429 264.9 428.3Q264.8 427.5 265.4 427.9Q266 428.2 266.9 428.2Q267.8 428.2 267.1 428.6Q266.5 429 267 429.7M268.1 429.3Q267.7 429.6 266.9 429.8Q266 430.1 265.5 430.2Q265 430.3 264.2 429.7Q263.4 429 264 428.2Q264.6 427.3 265.3 427Q266 426.7 266.9 426.9Q267.8 427.2 268.2 428.1Q268.5 429 268.1 429.3\" fill=\"none\" stroke=\"#121419\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a2930\" d=\"M276.8 443.3Q276.3 443.5 276.1 444Q276 444.4 275.2 444.2Q274.4 443.9 274.9 443.5Q275.3 443 275.5 442.6Q275.7 442.3 275.8 442.3Q276 442.3 276.5 442.5Q277 442.7 277.2 442.8Q277.3 443 276.8 443.3M276.7 443.4Q276.8 443.7 276.4 443.9Q276 444.1 275.8 443.8Q275.6 443.6 275.4 443.3Q275.3 443 275.3 442.7Q275.3 442.5 275.6 441.6Q276 440.8 276.2 441.7Q276.4 442.6 276.5 442.8Q276.6 443 276.7 443.4\" fill=\"none\" stroke=\"#121419\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a300\" d=\"M299.1 425.5Q448.8 413.3 522.2 411.6Q595.6 410 657.3 417.9L719 425.9M300.6 426.9Q450.4 412.5 522.8 411.3Q595.2 410 657.4 417.8L719.6 425.5M720.1 425.8C716.6 427 711.4 428 709.7 429.3M720.2 426C715.3 427.4 711.4 428.5 709.6 429.5M719.6 425.7C716.5 424.4 713.1 421.4 710.3 420.6M720 426.1C717 424.7 713.3 422.3 710.7 420.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a830a310\" x=\"735\" y=\"433\" font-size=\"19\" fill=\"#DBD8CF\">exec state<\/text><text data-hk=\"000000010000000000004000010a830a320\" x=\"374\" y=\"369\" font-size=\"16\" fill=\"#44CFFF\" transform=\"rotate(-1 374 369)\">needs secret<\/text><path data-hk=\"000000010000000000004000010a830a330\" d=\"M433.2 378.3Q387.5 368.1 360.8 373.4L334 378.6M431.2 378Q387.6 366.2 361 372.4L334.4 378.7M334.8 379.1C339.4 376.2 342.1 373.8 343.8 372.4M334.9 379.1C338.7 376.2 341.3 374.3 343.5 372.3M334.7 379.3C340 379.9 342.3 380.6 345.6 381.4M335.1 379C339.3 380.2 342.2 380.3 345.6 381.3\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"1.8\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a340\" d=\"M438.4 459.4Q383.8 428.7 369 412.8Q354.2 396.9 356.7 383.6Q359.1 370.3 342.6 356.6Q326.1 342.9 293 332.6Q259.8 322.4 232.9 312.7L206 303M437.4 458.1Q384.4 429.5 369.5 413.2Q354.7 397 357.3 383.9Q359.8 370.8 342 357.5Q324.2 344.3 291.6 333.4Q259.1 322.5 231.4 311.9L203.7 301.2M204.7 301.9C209.5 301.4 214.3 301.4 216.2 301.2M205.2 301.8C208.7 302.3 213.1 301.8 216.2 301.6M205.1 301.9C209 305.5 210.5 307.2 212.5 309.7M204.9 302.3C207.8 304.5 210.5 307.6 212.8 309.8\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"2.4\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a830a350\" d=\"M560.8 458.5Q629.3 419.9 671.2 399.8L713.2 379.8M561 458.4Q630.1 420.6 672.2 401.2L714.3 381.8M713.9 380.9C711 385 709 387.3 706.5 389.1M714.2 380.7C711.5 384 709.3 387.1 706.8 389.3M714.3 380.9C709.4 381 704.8 380.9 702.8 381.4M714.1 381.3C709 381.3 704.9 381.1 702.8 381.2\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"2.4\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a830a360\" x=\"500\" y=\"486\" font-size=\"17\" fill=\"#F4644A\" text-anchor=\"middle\" stroke=\"#F4644A\" stroke-width=\"0.8\">PROGRAMMATIC<\/text><text data-hk=\"000000010000000000004000010a830a370\" x=\"500\" y=\"518\" font-size=\"17\" fill=\"#F4644A\" text-anchor=\"middle\" stroke=\"#F4644A\" stroke-width=\"0.8\">TOOL USAGE<\/text><text data-hk=\"000000010000000000004000010a830a380\" x=\"725\" y=\"509\" font-size=\"20\" fill=\"#F4644A\" stroke=\"#F4644A\" stroke-width=\"0.8\">CONFLICT!<\/text><path data-hk=\"000000010000000000004000010a830a390\" d=\"M887.1 454.6Q897.4 460.8 899.2 466.6Q901.1 472.4 898 478Q894.9 483.6 892.5 487.5Q890 491.5 893.5 496.3Q896.9 501.2 899.1 509.1Q901.2 516.9 897.9 523Q894.6 529 890.2 530.7L885.8 532.4M887.1 455.7Q896.3 460.5 898.2 466.3Q900 472.1 897.3 478.1Q894.6 484 892.5 488.1Q890.4 492.2 894.6 496.3Q898.8 500.4 898.9 508.6Q899.1 516.7 896.9 523.3Q894.7 529.8 890.1 531.4L885.4 533.1\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"3\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a830a400\" x=\"918\" y=\"516\" font-size=\"28\" fill=\"#F4644A\" stroke=\"#F4644A\" stroke-width=\"0.8\">?<\/text><!--\/--><\/svg><\/figure>\n<p data-hk=\"000000010000000000004000010a8400\">Hmm, well that doesn&#8217;t work. Because:<\/p>\n<ul data-hk=\"000000010000000000004000010a8500\">\n<li data-hk=\"000000010000000000004000010a850100\">Programmatic tool usage requires access to all tools; so we can&#8217;t arbitrarily split harness-state<br \/>\ntools and environment-state tools<\/li>\n<li data-hk=\"000000010000000000004000010a850200\">We&#8217;d need to build a duplex gateway, allowing the VM to call host tools; which,\n<ol data-hk=\"000000010000000000004000010a85020100\">\n<li data-hk=\"000000010000000000004000010a8502010100\">Defeats the purpose (either you enable DoS; or you need to rate-limit your own VM with certain<br \/>\nactions)<\/li>\n<li data-hk=\"000000010000000000004000010a8502010200\">Just made this even more complicated, no thank you.<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010a8600\">Okay, let&#8217;s put the driving app, in the VM!<\/p>\n<figure data-hk=\"000000010000000000004000010a87\"><svg data-hk=\"000000010000000000004000010a8800\" class=\"st-sketch\" viewbox=\"0 0 1000 560\" role=\"img\" aria-label=\"Hand-drawn sketch titled 'what if the driver lives in the VM?': the driver, app source, and prompts sit inside the untrusted VM behind an LLM gateway proxy; connection errors and OOM kills are indistinguishable from outside, and app source leaks out to whoever prompts it. Caption: moved the boundary, kept the pain.\" font-family=\"var(--st-font-sketch)\"><defs><pattern id=\"drv-dots\" width=\"22\" height=\"22\" patternunits=\"userSpaceOnUse\"><circle cx=\"11\" cy=\"11\" r=\"1.1\" fill=\"#2E333C\"\/><\/pattern><\/defs><rect width=\"1000\" height=\"560\" fill=\"#121419\"\/><rect width=\"1000\" height=\"560\" fill=\"url(#drv-dots)\"\/><!--$--><text data-hk=\"000000010000000000004000010a880100\" x=\"500\" y=\"55\" font-size=\"29\" fill=\"#DBD8CF\" text-anchor=\"middle\" letter-spacing=\"2\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">WHAT IF THE DRIVER LIVES IN THE VM?<\/text><path data-hk=\"000000010000000000004000010a880110\" d=\"M110.9 66.4C413.8 68.1 672.5 68.2 889.4 67M111.1 67.9C383.9 69.5 720.9 67.1 890.9 67.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a88020\" x=\"316.5\" y=\"117.5\" width=\"452\" height=\"267\" rx=\"26\" fill=\"transparent\"\/><path data-hk=\"000000010000000000004000010a88021\" d=\"M342 116C528.5 116.4 676.4 114.1 744.9 115.1M341.8 116.5C475.7 116.8 677.2 116.8 745.3 114.8M769.2 142.4C767.3 229.7 771.9 313.9 769.5 359.6M770.8 141.3C767.7 232.2 772.6 313.3 769.1 360.9M743.2 387.3C591.9 389.8 408.6 385.3 340.7 386.2M744.6 385.9C561.9 387.2 408.7 385.9 342.4 387M314.2 360C318.2 259.7 312.1 197.9 315.8 141.7M315.7 359.8C316.2 289.2 313.8 178.7 313.6 143.1M744.8 115Q769.3 115.9 768.7 142.7M769.3 359.4Q770.7 386.2 743.5 386.2M341.1 385.3Q314.2 387 314.4 360.6M313.9 140.7Q315.6 115.5 342 115.4\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a88030\" x=\"543\" y=\"154\" font-size=\"28\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">VM (untrusted)<\/text><rect data-hk=\"000000010000000000004000010a88040\" x=\"391.5\" y=\"196.5\" width=\"197\" height=\"142\" rx=\"8\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a88041\" d=\"M396.6 195.4C469.6 195.9 529.1 194 582.9 196.1M398.9 194.6C464.9 196.7 549 196.8 581.3 194.2M589.9 202.7C591.8 243.4 588.1 292.8 588.6 331.8M591.1 202C592.1 262.1 587.7 306.3 589 330.6M581.7 341.3C515.2 340.1 456.9 340.7 398.8 340.2M580.7 339.3C494.5 340.9 458.7 338 398.4 338.9M391.3 332.2C389.5 273.7 388.4 231.7 390.8 204.1M390.2 333.1C389.2 281.1 387.5 226.1 390 203.2M583.4 195.9Q589.2 196.5 590.9 204.4M590.5 330.6Q588.8 340.8 580.6 339.8M398.5 341Q390 340.1 390.5 332.3M388.6 202.9Q389.3 193.6 396.7 194.1\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a88050\" x=\"490\" y=\"230\" font-size=\"25\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">DRIVER<\/text><ellipse data-hk=\"000000010000000000004000010a880600\" cx=\"560\" cy=\"213\" rx=\"1.6\" ry=\"1.6\" fill=\"#DBD8CF\"\/><path data-hk=\"000000010000000000004000010a880601\" d=\"M561.1 213.9Q561.6 214.8 560.8 214.2Q560 213.6 559.2 213.8Q558.4 214 558.1 213.5Q557.8 213 558.2 212.4Q558.7 211.7 559.3 211.2Q560 210.7 560.7 211.3Q561.5 212 561.1 212.5Q560.7 213 561.1 213.9M560.8 213.7Q560.7 214.3 560.4 214.8Q560 215.3 559.8 214.9Q559.6 214.5 559.2 213.8Q558.9 213 559.2 212.1Q559.6 211.2 559.8 211.7Q560 212.3 560.3 212.3Q560.6 212.3 560.8 212.6Q561 213 560.8 213.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><ellipse data-hk=\"000000010000000000004000010a880610\" cx=\"572\" cy=\"213\" rx=\"1.6\" ry=\"1.6\" fill=\"#DBD8CF\"\/><path data-hk=\"000000010000000000004000010a880611\" d=\"M573.6 213.7Q573.1 214.4 572.6 214.5Q572 214.6 571.7 214.2Q571.4 213.7 571.3 213.4Q571.1 213 571 212.7Q570.9 212.4 571.4 211.5Q572 210.6 572.6 211.2Q573.3 211.8 573.7 212.4Q574.1 213 573.6 213.7M573.8 213.7Q573.9 214.4 573 214.3Q572 214.3 571.7 214.3Q571.4 214.3 571 213.6Q570.6 213 571.1 212.6Q571.5 212.2 571.8 212.1Q572 212.1 573 211.9Q573.9 211.8 573.8 212.4Q573.8 213 573.8 213.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880620\" d=\"M558 223.6Q565.6 219 569.4 222L573.2 225M559.4 225.6Q567.1 221.5 569.5 223.5L571.9 225.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><g data-hk=\"000000010000000000004000010a8807\" transform=\"translate(426 269) scale(1.35) translate(-426 -269)\"><ellipse data-hk=\"000000010000000000004000010a880800\" cx=\"426\" cy=\"269\" rx=\"13\" ry=\"13\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a880801\" d=\"M436.8 273.7Q435 278.4 430.5 279.8Q426 281.1 421.7 280Q417.3 278.9 415.5 273.9Q413.7 269 414.9 264.7Q416.1 260.3 421 258.5Q426 256.8 430.8 258.2Q435.6 259.7 437.1 264.4Q438.6 269 436.8 273.7M437 273.5Q434.6 277.9 430.3 279.9Q426 281.8 421.4 280.2Q416.8 278.6 415.4 273.8Q414 269 415.5 264.5Q417 260 421.5 257.7Q426 255.4 430.3 257.7Q434.6 260 437 264.5Q439.4 269 437 273.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880810\" d=\"M429.8 270.7Q428.5 272.3 427.3 272.8Q426 273.3 424.4 272.7Q422.8 272.1 422.1 270.6Q421.3 269 422.1 267.3Q422.9 265.6 424.5 265.7Q426 265.9 427.6 265.7Q429.2 265.6 430.1 267.3Q431.1 269 429.8 270.7M429.4 270.5Q429.1 272 427.5 272.4Q426 272.7 424.4 272.4Q422.9 272 422.6 270.5Q422.3 269 422.7 267.2Q423.2 265.5 424.6 265.3Q426 265.1 427.7 265.4Q429.4 265.6 429.6 267.3Q429.8 269 429.4 270.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880820\" d=\"M426 264.9C426.1 260.8 425.4 259.4 426.4 256.5M425.8 264.6C426.8 262.5 425.9 258.3 426.5 257.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880830\" d=\"M422.9 270.5C419.3 273.1 417.1 273.8 415.7 275.2M423.1 270.5C419.1 272.8 418.3 273.8 415.6 275\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880840\" d=\"M429.2 270.5C432.1 272.6 435.3 274.5 436.9 274.7M429.2 271.3C432.4 273.2 434.6 274.5 436.3 274.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><\/g><g data-hk=\"000000010000000000004000010a8809\" transform=\"translate(474 280) scale(1.45) translate(-474 -280)\"><path data-hk=\"000000010000000000004000010a880a1000\" d=\"M464.8 282.6Q465 275 468.1 272.8Q471.2 270.6 474.7 270.6Q478.2 270.6 479.4 273.3L480.6 276M464.7 283.9Q464 274.6 466.8 271.7Q469.6 268.8 473.7 270.8Q477.7 272.9 480.1 274.9L482.5 276.9\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1010\" d=\"M483.7 278.1Q484.1 285.9 479.9 288.3Q475.8 290.7 472.2 288.8Q468.5 287 467.5 284.2L466.5 281.5M481.9 275.8Q483.6 284.8 480.5 287.1Q477.4 289.4 473 288.9Q468.6 288.4 468.5 285.1L468.4 281.8\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1020\" d=\"M470.2 273.2Q470.7 273.5 469.9 274.3Q469 275.1 468.6 274.7Q468.3 274.3 467.8 273.7Q467.4 273 468 272.2Q468.7 271.3 468.9 271.9Q469 272.5 469.6 272.5Q470.3 272.5 469.9 272.8Q469.6 273 470.2 273.2M470 273.8Q469.3 274.6 469.1 274.8Q469 275 468.5 274.3Q468 273.6 467.7 273.3Q467.5 273 467.6 272.2Q467.7 271.5 468.4 271.4Q469 271.3 469.4 271.5Q469.7 271.7 470.2 272.4Q470.7 273 470 273.8\" fill=\"none\" stroke=\"#121419\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1030\" d=\"M480.2 287.2Q479.9 287.5 479.5 287.8Q479 288.2 478.7 288Q478.4 287.7 477.8 287.4Q477.2 287 477.3 286.1Q477.4 285.3 478.2 285Q479 284.7 479.5 285Q479.9 285.2 480.2 286.1Q480.6 287 480.2 287.2M480.8 287.2Q480.1 287.3 479.5 287.9Q479 288.5 478.3 288.3Q477.7 288.2 477.3 287.6Q476.9 287 477.2 286.3Q477.4 285.5 478.2 286Q479 286.5 479.6 285.9Q480.2 285.4 480.8 286.2Q481.5 287 480.8 287.2\" fill=\"none\" stroke=\"#121419\" stroke-width=\"2\" stroke-linecap=\"round\"\/><\/g><polygon data-hk=\"000000010000000000004000010a880a1100\" points=\"530,244 559,244 568,253 568,292 530,292\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a880a1101\" d=\"M530.3 291.8C530.1 275 529.5 253.4 531.1 243.6M529.9 292.5C531.8 267.4 529.9 255.5 529.3 244.5M530.1 243.7C538.2 242.8 554.4 244.1 559.6 243.3M529.6 243.1C540 242.8 553.3 244.9 558.8 243M559.7 244.9C562.6 247 567 252.2 568.8 253M558.6 243.9C563.6 247.2 566.9 251.7 567.9 252.6M567.2 252.7C569.7 270.8 568.3 284.5 568.3 291.7M568.8 252C568.9 264.5 567.1 282.5 567.3 293.1M567.3 291.1C550.9 293.5 540 291.3 529 292.7M567.9 291.5C556.9 291.6 543.2 291.9 531.1 291.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1110\" d=\"M558.6 243.4C558.7 247.4 558.9 250.6 559 253.4M559.5 244.4C558.3 247.2 558.5 250.8 558.8 253.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1120\" d=\"M559.2 253.3C562.4 252.5 566.2 252.5 568.1 252.8M558.7 252.4C561.9 253.7 566 252.8 568 253.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1130\" d=\"M536.2 261.9C548.1 261.5 554.7 262.3 559.8 260.9M538.5 261.6C545 263.3 557.9 263.2 560.6 262.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1140\" d=\"M535.8 268.7C549.3 271.8 555.1 271.7 559.7 270.4M538.1 269.7C545.9 270.6 555.8 271.8 561.5 269.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1150\" d=\"M537.5 278.9C543.2 278.9 556.8 277.1 561.1 276.8M537.3 277.8C549 278.4 555.2 278.6 562.2 277.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1160\" d=\"M536.1 285C545.7 286.7 550 286 556.8 284.7M537.3 285.5C546.1 285.6 550.3 286.9 555.6 285.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a880a120\" x=\"403.5\" y=\"299.5\" width=\"173\" height=\"51\" rx=\"8\" fill=\"#262B33\"\/><path data-hk=\"000000010000000000004000010a880a121\" d=\"M409.6 298.5C470.1 296.9 535.8 300.1 568.5 297M409.1 297.3C480.6 298.7 534 297.6 570.6 297M578.5 307C578.7 321.6 577.1 335.2 577.5 344.9M578.1 304.8C579.4 321.4 578.6 336 579.3 342.8M569.1 351.5C520 350.5 463.1 350.8 409.2 352.2M570.3 352.1C499.9 352.4 450.2 354 408.6 352.4M402.7 343.7C401 325.9 403.7 317.4 401.7 307.2M400.7 344.3C400.4 327.7 400.6 317.2 401.1 307.1M570.8 296.7Q578.1 296.8 578.2 306.9M577.2 344.6Q577.2 352.5 570.3 351.8M411.3 351.1Q401.3 352.5 401.6 344.1M402.9 307.4Q401.9 297.1 408.8 296.8\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a880a130\" x=\"490\" y=\"322\" font-size=\"18\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\"><tspan data-hk=\"000000010000000000004000010a880a131\" x=\"490\">app source +<\/tspan><tspan data-hk=\"000000010000000000004000010a880a132\" x=\"490\" dy=\"21\">prompts<\/tspan><\/text><text data-hk=\"000000010000000000004000010a880a140\" x=\"157\" y=\"132\" font-size=\"20\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\" transform=\"rotate(-1 157 132)\"><tspan data-hk=\"000000010000000000004000010a880a141\" x=\"157\">now you have<\/tspan><tspan data-hk=\"000000010000000000004000010a880a142\" x=\"157\" dy=\"25\">to build &amp; host<\/tspan><tspan data-hk=\"000000010000000000004000010a880a143\" x=\"157\" dy=\"25\">THIS<\/tspan><\/text><rect data-hk=\"000000010000000000004000010a880a150\" x=\"60.5\" y=\"206.5\" width=\"148\" height=\"102\" rx=\"7\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a880a151\" d=\"M67.1 203.8C117.1 202.9 163.4 204.4 203.6 203.5M65.6 205.8C123.4 207 182.2 204.1 204.2 204M211 212.5C209.4 251.9 208.4 284.8 210.9 302.9M208.5 210.7C207.9 252.5 210.6 286.3 210.4 302.1M204 309.6C160.1 309.2 89.5 309.2 65.2 310.1M201.9 310.7C140.7 310.3 92.2 311.7 64.7 310.9M58.3 301.9C59.3 257.8 58.4 232.9 57.9 212.3M60.3 303.4C60.8 271.2 58.6 242.4 60.2 211.8M203.4 205.1Q211 205.6 211.3 213.3M210.9 302.6Q209.2 308.9 203.5 310.8M67.3 308.9Q60.3 310.8 57.8 303.2M57.9 211.7Q59.3 204.8 65 203.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a880a160\" x=\"134\" y=\"238\" font-size=\"24\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\"><tspan data-hk=\"000000010000000000004000010a880a161\" x=\"134\">LLM<\/tspan><tspan data-hk=\"000000010000000000004000010a880a162\" x=\"134\" dy=\"31\">GATEWAY<\/tspan><\/text><path data-hk=\"000000010000000000004000010a880a1700\" d=\"M191.4 196Q190.8 186.1 194.6 184.2Q198.3 182.3 201.2 184Q204 185.7 204.6 189.9L205.2 194.1M192 194.2Q192.4 187.1 195 185.1Q197.7 183 201.1 184.3Q204.5 185.6 204.5 190L204.5 194.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><polygon data-hk=\"000000010000000000004000010a880a1710\" points=\"185,195 211,195 211,211 185,211\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a880a1711\" d=\"M185.3 211.2C185.1 204.5 184.8 200.2 184.5 195.3M184.6 212.1C185.1 204.8 185.7 200.3 184.7 195.8M184.6 195.1C196.6 195.5 205.4 194.3 212 195.3M184.2 193.9C197.1 195.6 203.1 195.6 211.9 194M211.6 195.5C211 201.8 211.4 207 210.7 211.2M210.2 195.6C210.5 200.8 211.3 207.4 210.9 211M210.2 211.6C200.8 211.3 189.7 211.5 185.4 210.8M211.6 211.6C199.1 211.9 194 211.9 185 212.1\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><ellipse data-hk=\"000000010000000000004000010a880a1800\" cx=\"94\" cy=\"276\" rx=\"5\" ry=\"5\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a880a1801\" d=\"M98.1 277.7Q98 279.3 96 279.7Q94 280.1 92.2 280.2Q90.3 280.2 89.1 278.1Q88 276 89 274.6Q90.1 273.2 92 271.8Q94 270.5 95.9 271.5Q97.7 272.5 98 274.3Q98.3 276 98.1 277.7M98.2 277.4Q98.1 278.8 96.1 279.6Q94 280.4 92.1 279.7Q90.2 279 89.6 277.5Q89 276 89.6 273.9Q90.1 271.7 92 271.6Q94 271.5 95.9 272.1Q97.8 272.7 98 274.4Q98.2 276 98.2 277.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1810\" d=\"M97.9 280.9C104.5 285.1 109.5 291.1 113.7 295.2M97.4 279.4C104.9 288.5 111.3 290 113.7 295.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1820\" d=\"M107.1 291.5C105 294.3 103.8 294.5 102.7 295.5M107.2 291C105.2 293.2 103.7 294.1 102.8 296.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a1830\" d=\"M111.8 294.8C110.7 297.8 109.3 298.7 108.5 299.6M111.8 295.5C109.9 296.6 108.7 299.5 107.7 300.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a190\" d=\"M208.7 253.3Q281.7 215.2 335.6 233L389.5 250.7M210.9 251.8Q280.8 213.4 335.9 232.9L391 252.3M390.1 252.2C385.7 252.5 381.9 252.3 378.7 253M389.7 251.7C386.1 252.3 381.9 252.3 379.4 253M390.2 251.9C386 248.3 383.8 246.2 382.1 244.2M390.2 251.9C386.6 249.5 383.5 246 381.9 244.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a200\" d=\"M244.6 317.8Q270.2 290.3 268.2 268L266.1 245.8M244.5 318.5Q269.8 290.4 269 268.1L268.3 245.7M266.8 247.2C268.8 251.2 271.1 255.2 272 256.5M266.7 246.7C268.6 250 270.1 253.6 272 256.7M266.9 247.3C265.9 250 264 254.6 263.1 257.5M267.2 247.1C265.2 251.6 263.8 254.9 263.2 257.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.8\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a880a210\" x=\"216\" y=\"343\" font-size=\"21\" fill=\"#DBD8CF\" text-anchor=\"middle\" transform=\"rotate(-1 216 343)\"><tspan data-hk=\"000000010000000000004000010a880a211\" x=\"216\">proxy \u2014<\/tspan><tspan data-hk=\"000000010000000000004000010a880a212\" x=\"216\" dy=\"27\">key stays<\/tspan><tspan data-hk=\"000000010000000000004000010a880a213\" x=\"216\" dy=\"27\">out here<\/tspan><\/text><text data-hk=\"000000010000000000004000010a880a220\" x=\"600\" y=\"194\" font-size=\"19\" fill=\"#DBD8CF\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">(a)<\/text><polygon data-hk=\"000000010000000000004000010a880a2300\" points=\"642,200 651,192 660,200 651,210\" fill=\"#1E2A3C\"\/><path data-hk=\"000000010000000000004000010a880a2301\" d=\"M650.4 210.2C646.1 204.9 644.2 201.9 640.9 199.2M650.7 210.1C648.5 207.2 645 202.4 641.1 199.9M641.7 198.9C645.6 196.6 649 194.4 650.5 193M641.9 199C644.8 196.5 647.1 193.8 651.3 191.5M650.7 192C655.8 195.8 657.1 197.2 659.6 200.2M649.9 192.2C654.5 196.8 657 199.1 659.9 199.5M659.4 199.5C656.2 202.9 651.9 209.2 650.6 210.3M660.5 200.5C656.9 203.5 652.4 207.5 650.3 210.1\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a2310\" d=\"M647.3 195C645.7 192.4 644.3 190.6 642.6 188M647.3 194.8C645.9 192.8 644 189.4 643.2 187.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a2320\" d=\"M652.8 191.5C651.1 189 651.4 187 650 184.8M653.1 192.2C652 189.3 650.3 186.9 650.6 185.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a2330\" d=\"M652.3 209.3Q647.8 217.4 649.7 219.4Q651.5 221.4 649.6 225L647.6 228.6M649.7 209.8Q649 216.3 650.5 219Q652 221.8 650.8 225.6L649.6 229.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a880a240\" x=\"672\" y=\"204\" font-size=\"19\" fill=\"#DBD8CF\" stroke=\"#DBD8CF\" stroke-width=\"0.8\"><tspan data-hk=\"000000010000000000004000010a880a241\" x=\"672\">conn<\/tspan><tspan data-hk=\"000000010000000000004000010a880a242\" x=\"672\" dy=\"22\">error<\/tspan><\/text><path data-hk=\"000000010000000000004000010a880a250\" d=\"M640.4 218Q619.1 236 604.7 234.3L590.2 232.6M642.3 218.9Q619.2 234.9 604.1 233.1L589 231.3M590 231.7C594.2 230.9 598 229.2 600.3 228.7M589.7 232.3C593.3 231 598.6 229.3 600.6 228.7M589.8 232C593.7 233.7 597.2 236 599.2 237.7M590.2 231.8C594.2 234.5 597.7 236.1 599.3 237.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.8\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a260\" d=\"M727.9 215.6Q752 222.2 759.2 237L766.4 251.8M725.8 216.8Q751.3 221.8 758.3 237.1L765.4 252.5M765.8 251.9C762 248.6 759.6 246.8 758 244.7M766.3 252.3C763.4 249.8 759.6 246 757.5 244.7M765.9 251.7C766 248.2 765.8 244 765.5 240.8M765.8 251.8C765.7 248.2 766.2 244.2 766 241\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.8\" stroke-linecap=\"round\"\/><g data-hk=\"000000010000000000004000010a880a27\" transform=\"translate(669 279) scale(.78) translate(-669 -279)\"><polygon data-hk=\"000000010000000000004000010a880a2800\" points=\"637,287 651,283 641,267 659,274 661,250 672,267 683,245 687,269 708,262 697,280 712,288 692,292 698,310 678,300 670,318 662,299 645,308 651,293\" fill=\"#4A2A10\"\/><path data-hk=\"000000010000000000004000010a880a2801\" d=\"M651.1 292.8C644.5 290.2 640.6 287.7 637.7 287.5M650.9 293.6C644.6 290.5 641.3 288.2 636 286.7M638.1 287.7C642.3 286 647.4 284.4 651.2 283.1M637.9 286.8C644.3 285.4 647 283.6 651.7 283.2M651.6 284C646.6 276.7 642.4 271.2 641.7 267M650.2 283.5C647 275.9 641.6 270.7 640.8 267.5M641.6 266.8C649.7 271 655.1 273 659.7 273M640.9 265.9C646.4 268.7 654 271.5 658.2 275M658.3 273C660.8 263.4 661.2 255.4 661.1 250.9M658.5 273.2C660 267.5 661.5 258.1 660.8 249.7M661.1 249.1C665.1 258 668.8 262.4 670.9 266.2M660 250.9C666.7 257.7 669.4 263.2 672.3 267.5M671.1 266.3C675.2 260.8 680.4 252.2 682.2 244M671.5 267.2C675 260.8 679.3 249.8 683.3 245.8M683.4 244C684.2 254.4 686.8 264.9 687.9 269.5M681.9 245.5C684.8 255 686.1 263.9 686.3 269.9M686.5 270C694.5 264.9 702 263.4 707.8 262.8M687.6 269.3C696.4 264.6 702.7 263.6 708.4 261M707.8 261.4C703.3 270.6 700.2 278.1 696.4 280.7M709 261C703.5 269.3 701 273.2 697.9 280.5M696.1 279.2C703.9 282.1 707.6 285.8 711.6 288.3M697.9 279.2C703.4 283.9 707.5 285.8 711.5 288M711.2 287C704.8 290.7 697.4 291.7 691.7 291.8M712.7 288.4C706 288.4 695 291.9 692 291.4M692.4 292.3C693.7 300.6 695.9 305 699.1 309.8M692.3 291.8C693.6 297.5 697.8 307 697.6 309.5M697.2 308.9C692.7 306.8 682.1 301.4 677.3 301M697 309C687.1 304.4 680.5 302.1 677.4 300.6M677.4 300.3C674.4 307.3 671.1 313.7 669 317.7M678.6 299.7C674.5 307.2 671.3 314.3 669 318.3M670.8 317.8C667.7 310.8 664.8 304.2 662.1 300.1M670.6 318.3C666.2 312.3 663 302.9 662 298.9M661 298.1C654.5 301.3 649.3 304.3 644.4 308.1M661.6 299C655 303.4 650.4 305.3 644 308.4M646 307.4C646.7 302.7 650.2 296 650.5 292.2M645.8 307.3C647.2 301.1 649.1 297.3 651.9 292.3\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a2810\" d=\"M646.7 249C644.1 245.4 642.6 243.9 641.2 242.1M646.7 249.3C644.5 246.1 642.4 241.2 641.9 239.6\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a2820\" d=\"M703.3 252.6C705.7 251.2 710.7 245.7 710.7 244.8M703.6 254.4C706.4 250.3 708.2 247.1 709.3 244.3\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"2\" stroke-linecap=\"round\"\/><\/g><text data-hk=\"000000010000000000004000010a880a290\" x=\"602\" y=\"326\" font-size=\"19\" fill=\"#DBD8CF\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">(b)<\/text><text data-hk=\"000000010000000000004000010a880a300\" x=\"641\" y=\"328\" font-size=\"19\" fill=\"#DBD8CF\" stroke=\"#DBD8CF\" stroke-width=\"0.8\"><tspan data-hk=\"000000010000000000004000010a880a301\" x=\"641\">OOM<\/tspan><tspan data-hk=\"000000010000000000004000010a880a302\" x=\"641\" dy=\"22\">kamikaze<\/tspan><\/text><path data-hk=\"000000010000000000004000010a880a310\" d=\"M635.1 281.5Q614.7 275.7 602.8 274.7L590.9 273.8M635.7 282.4Q613.3 276.6 601.7 274.7L590.1 272.8M589.7 273.1C593 271.7 597.9 270.5 600.8 270M590.2 272.7C594.6 271.7 597.1 271 600.4 269.6M589.8 272.9C593.7 275.3 597.2 277.4 599.1 278.7M590 272.8C594.2 275.9 596 276.8 599.6 278.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.8\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a320\" d=\"M710.6 291.9Q740.6 285.2 751.4 272.2L762.2 259.2M710.3 289.7Q741.2 284.8 752.3 272.8L763.4 260.8M763.2 260.1C761.8 263.8 760.5 267.4 759.3 270.8M763.2 260.1C761.1 265 760.2 267.4 759.4 270.5M762.8 260.3C759.7 261.3 755.1 262.9 752.8 264.4M762.8 259.8C758.5 261.6 755.7 263.4 752.8 264.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.8\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a3300\" d=\"M761 254Q764.3 245 764.8 250Q765.3 254.9 767.5 250.1Q769.6 245.2 769.7 252.1Q769.8 258.9 773.9 252.8Q778 246.6 776 253.3L774 260.1M761 252.8Q765.1 244.1 764.7 250Q764.2 255.9 767.8 251Q771.4 246.2 770.5 252.2Q769.7 258.2 773.2 252.5Q776.7 246.8 774.7 254.1L772.8 261.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a3310\" d=\"M765.2 260.6Q770.9 251.7 770.7 257.8Q770.5 263.9 773.6 258.2L776.8 252.6M765.3 260.3Q770.4 250 770.9 257.1Q771.5 264.1 774.8 259.3L778.2 254.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a340\" d=\"M781.2 250.2Q809.6 227.2 823.2 226.5L836.8 225.7M780.5 252Q810.6 226.4 824.8 226L839.1 225.7M838 224.7C834.3 226.7 831.2 228.1 827.8 229.8M837.7 224.9C834.2 226.6 829.9 228.5 828.4 229.9M837.8 224.8C834.9 224 829.2 221.4 828.1 220.8M837.7 225.2C833 222.8 829.6 221.5 827.9 220.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a3500\" d=\"M846 208.1Q856.8 188.1 856.4 199.7Q856 211.3 862.9 201.1Q869.8 190.8 868.4 205.2Q867 219.5 875.5 206.6Q884.1 193.6 880.3 209L876.5 224.3M848.4 207.7Q859 188.5 857 199.7Q855 210.8 863.4 200Q871.9 189.1 869.2 204.2Q866.5 219.3 875.1 207.3Q883.6 195.3 880.2 209.3L876.7 223.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a3510\" d=\"M858.7 223.2Q871.8 202.3 870.6 215.8Q869.4 229.3 877.3 218.1L885.2 206.8M858.1 222.3Q871.1 203.5 869.8 216Q868.5 228.5 877.2 217.5L885.9 206.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a360\" d=\"M846.2 290.7Q815.8 284.1 795.4 274.6L775.1 265M844.8 292.3Q814.8 283.9 795.3 275.3L775.8 266.8M775.9 265.9C780.9 265.7 784 266.1 786.8 265.8M776.4 266.1C781.1 266.2 783.6 265.7 787.3 265.8M775.8 265.7C779.5 269.8 782.2 272.5 783 274.4M776 266.3C779.4 270.6 781.2 273 783.3 274.4\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.8\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a880a370\" x=\"837\" y=\"320\" font-size=\"21\" fill=\"#F4644A\" text-anchor=\"middle\" stroke=\"#F4644A\" stroke-width=\"0.8\" transform=\"rotate(1 837 320)\"><tspan data-hk=\"000000010000000000004000010a880a371\" x=\"837\">outside can&#8217;t tell<\/tspan><tspan data-hk=\"000000010000000000004000010a880a372\" x=\"837\" dy=\"25\">which!<\/tspan><\/text><text data-hk=\"000000010000000000004000010a880a380\" x=\"945\" y=\"340\" font-size=\"42\" fill=\"#F4644A\" text-anchor=\"middle\" stroke=\"#F4644A\" stroke-width=\"0.8\" transform=\"rotate(2 945 340)\">?<\/text><path data-hk=\"000000010000000000004000010a880a3900\" d=\"M314.1 419.2Q429.3 417.9 439.1 425.4Q448.9 432.9 448.5 452.4Q448.1 472 439.5 479.9Q431 487.7 448.5 492.8Q466.1 497.8 443.5 492.4Q420.9 487.1 366.8 487.1Q312.8 487.1 303.6 480.5Q294.4 473.8 294.4 454.4Q294.5 434.9 304.8 426.5L315.2 418.1M313.8 418.8Q427.8 419.7 438 426.8Q448.3 433.9 448.5 453.5Q448.7 473.1 439.8 480.6Q430.9 488.1 449.6 493.4Q468.4 498.6 443.5 492.8Q418.6 486.9 367 486.6Q315.3 486.3 304.6 480.3Q293.9 474.4 294 453.6Q294.1 432.9 303.3 425.2L312.5 417.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a880a400\" x=\"369\" y=\"448\" font-size=\"20\" fill=\"#DBD8CF\" text-anchor=\"middle\"><tspan data-hk=\"000000010000000000004000010a880a401\" x=\"369\">untrusted<\/tspan><tspan data-hk=\"000000010000000000004000010a880a402\" x=\"369\" dy=\"23\">prompt<\/tspan><\/text><ellipse data-hk=\"000000010000000000004000010a880a4100\" cx=\"500\" cy=\"464\" rx=\"10\" ry=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a880a4101\" d=\"M508 467.2Q507 470.4 503.5 472.6Q500 474.9 496.7 473.1Q493.4 471.4 491.6 467.7Q489.9 464 491.8 460.4Q493.7 456.9 496.8 455.5Q500 454.2 503.3 455.3Q506.6 456.4 507.8 460.2Q508.9 464 508 467.2M508.6 467.5Q507.6 471 503.8 472.8Q500 474.6 496.3 472.5Q492.6 470.3 491.4 467.2Q490.2 464 491.6 460.4Q493 456.8 496.5 455.2Q500 453.5 503.6 455.3Q507.2 457.1 508.4 460.6Q509.6 464 508.6 467.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4110\" d=\"M498.8 473.9C499 485.6 499.8 499.5 498.8 513.4M500.5 474.6C500.5 486.4 500.3 500.5 500.7 514.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4120\" d=\"M499.7 488.8C492.1 484.4 486.7 480.6 482.6 477.3M499.9 488.9C494.7 486.4 484.7 479.4 481.3 476.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4130\" d=\"M501.3 490.1C507.3 486.1 511.4 479.8 519.9 474.8M499.2 488.4C506.6 485.2 513.4 479.6 518.7 474.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4140\" d=\"M500.3 514.2C494.2 522.3 487.9 531.9 486.4 537.2M500.1 514.2C491.3 524.4 490.1 532.4 484.3 535.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4150\" d=\"M501.1 515.3C505.7 521.7 509.8 530 516 536.2M500.5 514.8C504.6 521.3 510 528 514.4 537\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a420\" d=\"M480.6 455.1Q451 421.3 448.6 386.2L446.1 351M481 454.3Q453 421.1 449.8 386.5L446.6 351.8M446.1 352.2C448 355.7 450.7 359.8 451.4 361.5M445.7 352C447.8 355.3 449.7 359.5 451.1 361.3M446 352C445 355.2 442.9 359.3 442.7 362.2M446.2 352.1C444.3 355.6 443.7 359.3 442.5 362.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2.2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a430\" d=\"M552.1 351.5Q558 413.8 539.1 439L520.2 464.2M551.4 353Q559.7 413.4 540.4 438.6L521.2 463.7M520.7 465.2C522.5 459.5 523.1 457.7 523.7 454.4M521.3 465.3C521.5 461.1 522.5 456.5 523.8 454.5M520.9 465.3C525.3 462.9 527.1 461.7 530.3 459.4M520.9 465.2C524.5 463.4 528.9 460.5 530.4 459.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2.2\" stroke-linecap=\"round\"\/><polygon data-hk=\"000000010000000000004000010a880a4400\" points=\"576,412 603,412 612,421 612,458 576,458\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a880a4401\" d=\"M576.3 457.2C576.7 444.2 574.6 420.3 575.9 412.9M575.1 457.3C577.4 436.2 576.8 423.7 576.7 411M576.7 413C586.4 410.7 597.5 411.2 601.9 411.1M576.9 412.6C586.2 413.4 594.9 411.2 602.8 411.7M603.7 412.1C607.3 415.2 611.3 419.3 611.5 420.5M602.4 412.9C606.5 415.7 610.3 419.2 612.5 421M612.8 421.2C611.2 432.8 613.3 450.8 611 457.1M612.4 421.3C611.5 434.8 613 447.2 611.5 458.3M612.9 458.5C597 458.9 586.4 457.9 575.1 458.8M611.8 458.4C600 458.4 587.2 458.3 576 457.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4410\" d=\"M603.3 411.4C602.9 415.7 603.1 419 603.6 420.9M603 412.5C602.9 414.9 602.7 418.3 603.4 421\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4420\" d=\"M602.5 420.4C606.4 421.1 609.5 421.1 612.2 420.6M602.5 421.3C607.2 420.7 609.9 421.3 611.6 421\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4430\" d=\"M584 430.6C590.8 429.8 600.3 429.4 604 428.8M584 429.6C590.5 430.9 601.9 430.3 604.3 429.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4440\" d=\"M581.9 437.5C590.7 438.3 600.9 436.6 604.5 439.1M582 438.3C589.3 439.2 600.4 438.4 605.5 438.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4450\" d=\"M582.9 445.7C592.3 446.2 598.2 446 604.5 446.1M583.6 445.8C594.2 447.2 599.3 445.8 605.6 446.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a880a4460\" d=\"M584.1 453.4C587.2 454.8 597.5 453.9 600 454.6M582.1 454.2C588.6 453.8 593.5 453.4 598.9 454.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a880a450\" x=\"626\" y=\"434\" font-size=\"20\" fill=\"#F4644A\" stroke=\"#F4644A\" stroke-width=\"0.8\" transform=\"rotate(1 626 434)\"><tspan data-hk=\"000000010000000000004000010a880a451\" x=\"626\">app source<\/tspan><tspan data-hk=\"000000010000000000004000010a880a452\" x=\"626\" dy=\"25\">leaks out<\/tspan><\/text><text data-hk=\"000000010000000000004000010a880a460\" x=\"752\" y=\"460\" font-size=\"38\" fill=\"#F4644A\" stroke=\"#F4644A\" stroke-width=\"0.8\" transform=\"rotate(2 752 460)\">!<\/text><text data-hk=\"000000010000000000004000010a880a470\" x=\"768\" y=\"542\" font-size=\"16\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\" transform=\"rotate(-1 768 542)\">moved the boundary, kept the pain<\/text><!--\/--><\/svg><\/figure>\n<ul data-hk=\"000000010000000000004000010a8900\">\n<li data-hk=\"000000010000000000004000010a890100\">Now we&#8217;re leaking app prompts as well as internal source, unless we move our app outside the VM, and<br \/>\nconnect to the harness via a network RPC, as well as move the session storage outside<\/li>\n<li data-hk=\"000000010000000000004000010a890200\">But, session storage being outside, means we&#8217;d need to grant write access to the VM, which again,<br \/>\ngets us back to Problem #1 &amp; #2 together.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010a9000\">The solution is to put a single, obedient, stub inside the VM, and be very very careful, limiting<br \/>\nthe max amount of data streamed back (you don&#8217;t want a 2GB response to a misused Read tool):<\/p>\n<figure data-hk=\"000000010000000000004000010a91\"><svg data-hk=\"000000010000000000004000010a9200\" class=\"st-sketch\" viewbox=\"0 0 1000 560\" role=\"img\" aria-label=\"Hand-drawn sketch titled 'the stub stays in, everything else stays out': the trusted host keeps the driver, harness, LLM gateway keys, and session storage; the untrusted VM contains only an executor stub (python plus ripgrep) talking over one typed RPC door, with a read-only git overlay mirror. Caption: minimum viable prisoner.\" font-family=\"var(--st-font-sketch)\"><defs><pattern id=\"stub-dots\" width=\"22\" height=\"22\" patternunits=\"userSpaceOnUse\"><circle cx=\"11\" cy=\"11\" r=\"1.1\" fill=\"#2E333C\"\/><\/pattern><\/defs><rect width=\"1000\" height=\"560\" fill=\"#121419\"\/><rect width=\"1000\" height=\"560\" fill=\"url(#stub-dots)\"\/><!--$--><text data-hk=\"000000010000000000004000010a920100\" x=\"500\" y=\"56\" font-size=\"26\" fill=\"#DBD8CF\" text-anchor=\"middle\" letter-spacing=\"2\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">THE STUB STAYS IN, EVERYTHING ELSE STAYS OUT<\/text><path data-hk=\"000000010000000000004000010a920110\" d=\"M110.6 68.2C446.7 71.2 700.5 71.8 890.3 67.4M109.2 66.8C405.6 67.1 738.6 71.7 890.1 68.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a92020\" x=\"71.5\" y=\"101.5\" width=\"357\" height=\"397\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a92021\" d=\"M67.2 99.6C180 98.4 374.5 99.4 432.3 99.2M68.7 99.5C228.5 97.7 375.6 97.3 431.9 99.3M429.5 100.1C430.7 233.3 429.5 410.8 431 499.6M430.5 100.5C429.9 295.4 432 390.9 430.7 501.1M430.8 499.6C265.4 502.2 166.1 499 67.6 498.9M430.4 500.9C293.7 499 165.8 496.8 66.6 501.3M70.9 502.6C68.7 363.8 70.3 231.5 70 99.6M70 501.4C70.1 341.8 67.3 191.7 71.2 98.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-dasharray=\"7 5\"\/><text data-hk=\"000000010000000000004000010a92030\" x=\"95\" y=\"140\" font-size=\"19\" fill=\"#DBD8CF\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">HOST<\/text><text data-hk=\"000000010000000000004000010a92040\" x=\"172\" y=\"140\" font-size=\"16\" fill=\"#4ADE80\">(trusted)<\/text><path data-hk=\"000000010000000000004000010a92050\" d=\"M272.7 131Q280 142.6 290.9 128.8L301.7 115M271.6 131.5Q279.6 143.8 291.1 130.4L302.6 117\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"3\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a92060\" x=\"186.5\" y=\"166.5\" width=\"102\" height=\"37\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a92061\" d=\"M185 164.6C238.3 165.7 260.4 162.4 293.3 164.9M184.3 164.3C221.4 164.5 259.8 167.3 292.8 166.1M291.4 163.6C291.2 179.2 290.9 200 289.3 205.9M291.4 164.4C289.9 182.9 287.7 197 290.9 205.6M289.3 205.6C243.7 204.8 213.8 204.3 183.8 205.8M290.8 203.7C256 203.1 214.8 206 183.8 204.1M185.1 205.5C184.9 189.3 184.2 175.6 184.9 163.7M183.9 206.6C183.1 188.1 183.2 172.8 186 164.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a92070\" x=\"237\" y=\"190\" font-size=\"15\" fill=\"#DBD8CF\" text-anchor=\"middle\">DRIVER<\/text><ellipse data-hk=\"000000010000000000004000010a920800\" cx=\"290\" cy=\"165\" rx=\"13\" ry=\"13\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920801\" d=\"M300.5 169.3Q298.8 173.7 294.4 175.6Q290 177.5 285.6 175.6Q281.1 173.7 279.2 169.3Q277.3 165 279 160.3Q280.8 155.6 285.4 153.4Q290 151.2 294.9 153.4Q299.9 155.5 301.1 160.3Q302.2 165 300.5 169.3M301.3 169.7Q299.3 174.5 294.7 175.9Q290 177.3 285.7 175.5Q281.3 173.7 279.6 169.4Q277.8 165 279.4 160.4Q281.1 155.7 285.5 154.3Q290 152.9 294.6 154.2Q299.3 155.4 301.3 160.2Q303.2 165 301.3 169.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920810\" d=\"M293 166.8Q293.1 168.6 291.5 169.1Q290 169.6 288.2 168.4Q286.4 167.2 286.7 166.1Q287 165 287.2 163.5Q287.5 161.9 288.7 161.6Q290 161.2 291.6 161.8Q293.2 162.4 293.1 163.7Q292.9 165 293 166.8M293.1 166.7Q292.3 168.3 291.1 168.5Q290 168.7 288.3 168.1Q286.6 167.5 286.5 166.3Q286.4 165 287.2 163.6Q287.9 162.3 289 161.2Q290 160.2 291.2 161.4Q292.5 162.6 293.2 163.8Q293.9 165 293.1 166.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920820\" d=\"M289.4 160.8C290.2 158.3 289.9 155 290.4 152.8M289.6 161C290.6 157.9 289.7 154.1 290.4 152.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920830\" d=\"M286.5 166.9C283.2 169 281.4 170.2 279.8 170.4M287.1 166.8C284.2 168.4 280.9 171.1 279 171.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920840\" d=\"M294 166.6C296.4 168.6 297.9 170.1 299.9 171.5M293 167.2C296.3 168.9 298.1 169.5 300.6 171.1\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><polygon data-hk=\"000000010000000000004000010a920900\" points=\"330,237 330,199 335,195 356,195 361,202 402,202 402,237\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920901\" d=\"M401.1 236.9C375.8 236.1 345.6 236.7 329.4 236.7M402.2 237.9C368.7 236.3 345.6 236.8 331 236.2M330.9 237.3C331.5 221.2 328.6 210.6 329 199.3M330.4 237.7C330.2 219.7 330 206.7 330.2 199.3M330.2 199C331.3 197.7 334.1 196.1 335.1 195M330.3 199.2C331.6 198.1 333.5 195.8 335.2 194.9M335.9 193.9C342.4 194.2 351 194.6 355.2 195.8M335.2 194.3C343 195.5 350.2 194.3 355 195.3M355.9 195C357.7 198.1 359.8 199.8 360.9 202.2M356.1 195.2C358.8 198.5 359.9 201 361.1 202.1M361.2 202.3C373.7 201.3 389.4 202.1 401.1 202.2M361.8 201.5C374.7 202.9 390.2 202.7 402.6 202.1M402.4 201.5C403 220 402.7 225.6 402.5 237.4M401.4 202.4C402 217.4 403 225.1 402.4 237.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920910\" x=\"366\" y=\"226\" font-size=\"13.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">&lt;git&gt;<\/text><path data-hk=\"000000010000000000004000010a920a100\" d=\"M328.8 236.5Q305.9 250.7 298.9 255.2L292 259.6M330.1 237.4Q306.2 250.8 298.5 255.2L290.8 259.6M291.9 260.1C294.4 257.2 296.7 252.9 298.2 250.9M292 259.8C294.8 255.7 296.5 252.7 297.9 251.1M291.8 260.3C296.4 259.8 299.5 258.9 303.2 258.8M291.8 260.2C297 259.5 300.9 259.1 302.6 258.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a110\" d=\"M180.1 194.6Q149.1 220.5 153.4 235.6Q157.7 250.7 169.3 259.2L180.8 267.7M181 194.6Q150.9 219.1 154.7 234.2Q158.5 249.2 170.8 258L183.1 266.8M182.2 267.9C176.7 266.7 173.8 266 171 265.6M181.8 267.9C177.9 267 174.1 266.3 171.3 265.6M182 268C179.7 264.3 177.8 259.8 176.5 258.3M181.6 267.9C180.3 265.5 178 261.4 176.9 258.1\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a920a120\" x=\"186.5\" y=\"256.5\" width=\"132\" height=\"41\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a121\" d=\"M183.6 255.9C237.9 254.3 299.5 254 319.7 253.9M183.6 254.7C246 255 287.5 253.1 319.5 254.4M319.8 252.4C321 268.6 320.3 283.7 320.8 298M319.7 254.1C320.2 271.2 320.2 285.5 320.1 300.4M320.4 299.5C267.5 301.8 214.7 299.5 184.1 298.6M319.9 298.2C270 301 208.4 299 183.6 298.1M185.3 299.8C183.1 283.5 184.6 267.1 184.3 254.6M186.2 300.1C186.6 277 185.6 270.1 185.7 255.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a130\" x=\"252\" y=\"283\" font-size=\"16\" fill=\"#DBD8CF\" text-anchor=\"middle\">HARNESS<\/text><ellipse data-hk=\"000000010000000000004000010a920a1480\" cx=\"320\" cy=\"255\" rx=\"8\" ry=\"8\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a1481\" d=\"M326.5 258.1Q325.7 261.3 322.9 262.1Q320 263 316.8 261.7Q313.6 260.4 312.9 257.7Q312.1 255 313.4 252.5Q314.7 249.9 317.4 248.9Q320 247.9 323.1 248.8Q326.2 249.7 326.8 252.3Q327.3 255 326.5 258.1M326.6 257.5Q325 260.1 322.5 262.1Q320 264.1 316.9 262.4Q313.9 260.7 312.6 257.9Q311.4 255 312.5 252.2Q313.6 249.4 316.8 248.2Q320 247.1 322.9 248.1Q325.8 249.1 327 252.1Q328.2 255 326.6 257.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1490\" d=\"M322.1 256Q322 257 321 256.7Q320 256.5 319.1 256.6Q318.2 256.8 317.5 255.9Q316.8 255 317.9 254.4Q319 253.9 319.5 253.4Q320 252.9 320.7 253Q321.4 253.2 321.8 254.1Q322.2 255 322.1 256M323 255.6Q322.5 256.1 321.2 256.5Q320 257 318.9 257.1Q317.8 257.3 318.1 256.2Q318.3 255 317.9 253.9Q317.6 252.8 318.8 252.5Q320 252.3 320.8 252.7Q321.6 253.1 322.6 254Q323.5 255 323 255.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1400\" d=\"M327.4 257.1C329.2 257.6 330 257.7 331.2 258.9M327.2 257.2C329 257.9 330.4 258.6 332 258.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1410\" d=\"M323.4 261.9C324.7 264 324.6 265.3 325.4 266M324.3 262C324.6 263.8 325.7 265.4 325.9 265.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1420\" d=\"M317.9 262C316.9 263.9 316.7 265.6 316.6 267M318.2 263.1C317.3 264 316.8 265.7 316 265.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1430\" d=\"M312.4 259.3C311.7 260.1 310.4 260.3 309.2 260.6M312.9 258.5C311.2 259.7 311.1 260.1 309.6 260.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1440\" d=\"M312.8 252.7C310.6 252.8 309.6 251.9 308.1 251.7M312.4 252.7C310.4 252.8 308.7 251.2 309 251.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1450\" d=\"M316.8 248C315.3 245.8 314.8 245.7 313.9 244.4M316.3 248C315.3 247.1 315.4 245.4 314.2 244.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1460\" d=\"M321.9 247.1C323.3 245.9 323.2 243.9 324.1 243.8M321.9 247.2C322.9 245.7 323.9 244.8 324 243.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a1470\" d=\"M327.4 251.4C328.7 250.8 329.9 250.4 331 249.4M326.9 251.3C328.8 251.1 329.8 249.9 330.6 249.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a150\" d=\"M213 300.1Q177.6 330.9 172 345.5L166.4 360.2M211.2 298.8Q177.8 328.8 171.9 344L166.1 359.3M166.1 359.9C165.6 356 165.6 351.6 165.8 348.9M166.2 359.8C165.8 356.5 165.6 351.6 165.5 349.1M166 360.2C170 356.4 171.5 354.4 173.8 352.3M165.8 360.1C169.6 356.8 171.7 354.4 173.9 352.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a160\" d=\"M291.2 299Q321.4 328.7 326.7 344L332 359.3M293.2 299.9Q322.8 329.9 327.3 345L331.8 360.2M332 359.8C328.3 356.5 325.9 353.3 324.5 352.2M331.8 360C329.3 357.4 325.9 353.4 324.5 351.6M332.1 360.3C332.6 355.7 332.6 352.5 333.2 348.9M332.3 359.9C332.4 356.1 333 352.2 332.8 349\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a920a170\" x=\"106.5\" y=\"366.5\" width=\"112\" height=\"49\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a171\" d=\"M105.1 364.4C155.1 363 189.7 363.8 220.8 365.8M106 364.6C145.1 364.9 190.6 363.1 219.1 366M221 364.3C217.7 383.6 220.6 407.2 219.3 419.7M219.2 363.9C218.7 389.8 220.6 403.1 220.4 419.6M219.4 417.9C163.8 418.7 129.5 416.5 103.6 416.7M219.7 416C171.2 417.7 121 417.1 102.4 416.6M105.4 416.7C106.6 399.7 106.2 373.8 104.4 363.7M104.3 418.2C105 396.9 104.9 377.7 104.9 362.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a180\" x=\"168\" y=\"387\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">LLM<\/text><text data-hk=\"000000010000000000004000010a920a190\" x=\"168\" y=\"405\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">GATEWAY<\/text><ellipse data-hk=\"000000010000000000004000010a920a2000\" cx=\"97\" cy=\"362\" rx=\"5\" ry=\"5\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a2001\" d=\"M101.5 364Q100.5 365.9 98.7 366.9Q97 367.9 95.2 366.3Q93.3 364.8 92.1 363.4Q90.9 362 92.5 360.3Q94.2 358.6 95.6 358.3Q97 358 99.1 358.1Q101.3 358.1 101.9 360.1Q102.6 362 101.5 364M101.5 363.6Q101.1 365.3 99.1 366.1Q97 366.8 95.3 366.2Q93.5 365.5 92.3 363.7Q91.1 362 92.4 360Q93.8 358 95.4 357.3Q97 356.6 98.6 357.5Q100.3 358.4 101.1 360.2Q101.8 362 101.5 363.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2010\" d=\"M101.9 367.3C107.3 372.6 113.5 376.4 117.8 379.7M101.7 365.8C107.6 370.1 111.8 376.8 119.2 378.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2020\" d=\"M109.7 377.5C108.3 378.6 106.2 381.4 106.6 382.6M110 376.5C107.7 379.1 107.3 380.3 105.4 381.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2030\" d=\"M115 381.2C114 383.2 112.5 384.7 110.7 386.5M115 380.6C113.1 382.5 111.9 385.1 111.3 385.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2100\" d=\"M213.2 356.4Q212.6 347.9 215.3 346Q218 344.1 221.9 345.5Q225.8 346.9 226 350.8L226.1 354.6M212.9 355.6Q211.6 347.9 215.9 345.8Q220.2 343.7 222.8 346.4Q225.4 349 225.5 352.7L225.6 356.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><polygon data-hk=\"000000010000000000004000010a920a2110\" points=\"206,356 232,356 232,372 206,372\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a2111\" d=\"M205.6 372.1C205.2 366.1 204.8 358.8 205.8 355.2M205.5 371.2C206.7 364.2 205.9 360.5 207.1 355.7M206.2 354.9C214.9 356.9 227.5 355.1 232.2 356.4M206.6 357C218.3 356.3 226.1 355.2 231 355.2M231.4 356.3C231.5 363.1 231.7 367.8 232.3 371.1M231 355.3C231.7 362.4 230.8 368.5 232.1 371M231 372.7C222.6 372 211.3 370.7 206.8 371.4M232.8 371C220.8 371.9 209.9 371.9 206.5 372.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a220\" x=\"162\" y=\"444\" font-size=\"13\" fill=\"#DBD8CF\" text-anchor=\"middle\" transform=\"rotate(-1 162 444)\">keys live here<\/text><rect data-hk=\"000000010000000000004000010a920a230\" x=\"271.5\" y=\"366.5\" width=\"127\" height=\"49\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a231\" d=\"M270.3 365.2C335.4 366.8 381.6 365.1 401 364.4M270.7 366.4C331.2 364.9 365.9 364 401.5 363.8M399 364.3C399.5 386.5 401.1 407.2 399.3 418.1M399.8 363.3C398.9 383.1 402 406.1 399.3 419M400.1 416.1C336.8 415.8 297.2 418 271 416.3M402 416.6C358 415.3 300.7 419.6 269.6 416.4M270.9 419.1C269.2 391.9 269.5 381 270.1 364.4M269 418.4C271.8 399.1 270.4 380.4 268.7 362.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a240\" x=\"354\" y=\"387\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">SESSION<\/text><text data-hk=\"000000010000000000004000010a920a250\" x=\"354\" y=\"405\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">STORAGE<\/text><ellipse data-hk=\"000000010000000000004000010a920a2600\" cx=\"290\" cy=\"378\" rx=\"13\" ry=\"4.5\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a2601\" d=\"M301.1 380Q299.5 381.9 294.7 381.8Q290 381.7 285.6 381.2Q281.3 380.6 279.3 379.3Q277.3 378 279.4 376.8Q281.5 375.5 285.7 374.9Q290 374.3 294.6 374.2Q299.2 374.1 300.9 376.1Q302.7 378 301.1 380M300.9 379.4Q299.3 380.9 294.7 381.3Q290 381.6 285.1 381.2Q280.2 380.8 278.1 379.4Q276.1 378 278.2 376.3Q280.3 374.6 285.2 374.1Q290 373.5 294.4 373.8Q298.8 374.1 300.6 376.1Q302.4 378 300.9 379.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2610\" d=\"M276.5 378.1C278.2 387.3 276.8 390.6 277.3 395.1M277.5 377.1C276.8 386.4 278.9 392.9 276.6 396\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2620\" d=\"M302.5 378.4C302.5 384.5 304.5 389.3 302.9 396M303.7 377.6C304.1 386 302.8 392.3 302.2 395.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2630\" d=\"M276.7 395.3Q289.6 400.5 296.4 397.6L303.2 394.6M277.8 396.1Q291.2 400.1 296.8 397.9L302.4 395.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a2640\" d=\"M276.1 388.7Q289.1 392.4 295.7 390.9L302.4 389.5M277.6 388Q289.7 393.6 296.8 390.3L303.9 387\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a270\" x=\"335\" y=\"444\" font-size=\"13\" fill=\"#DBD8CF\" text-anchor=\"middle\" transform=\"rotate(0.8 335 444)\">single writer<\/text><rect data-hk=\"000000010000000000004000010a920a280\" x=\"556.5\" y=\"156.5\" width=\"392\" height=\"267\" rx=\"22\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a281\" d=\"M575.7 153.6C718.4 153.5 845.2 155.8 927.8 155.5M577.8 155.6C691.3 154.9 846.6 157.9 927.2 154M949.7 177.2C952.6 258.4 947.7 359.5 948.8 404M949.3 177.8C951.3 266.8 951 339.1 950 403.1M928.6 425.5C790.6 422.3 691.3 424.3 576 425.5M926.7 425.6C776.2 426.7 655.8 425.5 576.7 423.5M554.2 402.7C558.2 308.9 554.5 218.6 554 176M556.3 404C553.1 296.9 553.7 237.2 554.2 178.4M928.5 153.8Q950 155.2 948.6 178.2M950.7 402.6Q951 425.8 926.8 425.8M575.8 425Q554 424.6 554.6 403.9M554 178.3Q556.5 156.5 575.8 156.3\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a290\" d=\"M320.7 276.8C423 274.7 537 277.4 586.7 277M320 278.7C424.2 279.4 525.1 278.5 584.6 278.8M585.3 277.1C581 278.9 577.2 280.6 574.8 281.7M585 276.9C582.2 278.3 577.6 280.7 575.1 281.8M585.2 276.9C580.9 275.1 578.1 273.5 574.7 272.7M584.7 277.2C582.2 275.6 576.4 273.4 574.7 272.2M320.1 277.2C325 274.5 328.1 273.3 329.8 272.9M319.7 276.9C325.3 274.6 327.2 273.5 330.3 272.3M320.1 276.8C323.1 278.5 327.7 280.2 330.2 281.5M319.9 276.9C323.9 278.9 326.7 280 330.3 281.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2.4\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a300\" x=\"438\" y=\"260\" font-size=\"15\" fill=\"#DBD8CF\" text-anchor=\"middle\">typed RPC<\/text><polygon data-hk=\"000000010000000000004000010a920a3100\" points=\"482,248 504,248 496,259 490,259\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a3101\" d=\"M490.4 259.1C486.5 254.4 484 249 481.4 249.1M489.5 259.5C486.2 255.9 482.4 249.8 481.9 247.1M483 247.5C490.1 248 499.9 247.2 504.9 248.3M482 249C489.2 248.5 498.1 246.6 504.3 249M503.8 248.2C500.2 252.4 498.9 255.9 497 260M503.5 248.5C500.6 251.2 496.3 258.1 496.3 258.7M495.8 259.4C493.4 258.7 491.7 258.8 489.6 258.9M495.7 259C494.1 259.2 491.9 259.1 489.6 259.1\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a3110\" d=\"M492.6 259.1C492.4 261.5 493.4 263.3 493.2 265.6M492.5 259C492.4 261.8 492.7 264.7 493 265.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a320\" x=\"445\" y=\"312\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\" transform=\"rotate(-0.6 445 312)\">the only door<\/text><text data-hk=\"000000010000000000004000010a920a330\" x=\"752\" y=\"192\" font-size=\"19\" fill=\"#DBD8CF\" text-anchor=\"middle\"><tspan data-hk=\"000000010000000000004000010a920a331\" font-weight=\"bold\">VM<\/tspan> <tspan data-hk=\"000000010000000000004000010a920a332\" fill=\"#F4644A\">(untrusted)<\/tspan><\/text><text data-hk=\"000000010000000000004000010a920a340\" x=\"955\" y=\"112\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"end\" transform=\"rotate(-1 955 112)\">if popped: attacker gets<\/text><text data-hk=\"000000010000000000004000010a920a350\" x=\"955\" y=\"128\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"end\" transform=\"rotate(-1 955 128)\">a stub, python, and grep<\/text><path data-hk=\"000000010000000000004000010a920a3600\" d=\"M598.2 222.7Q599.2 214.4 601.5 212.5Q603.7 210.6 608.8 211.4Q613.9 212.3 614.5 214.7L615.2 217.2M598.4 222.4Q598.5 213.7 602 211.4Q605.4 209.1 609.5 211.2Q613.6 213.3 614.5 215.2L615.4 217.2\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a3610\" d=\"M616.3 217.8Q616.2 227.5 614 229Q611.8 230.6 607.3 229.9Q602.8 229.3 601.2 225.8L599.7 222.3M617.4 217.8Q616.4 225.8 614.3 227.5Q612.1 229.1 608.3 228.4Q604.4 227.7 602.6 226.1L600.8 224.4\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a3620\" d=\"M604 213.7Q604.4 214.4 603.7 214.2Q603 214 602.8 213.8Q602.6 213.6 602.5 213.3Q602.4 213 602.3 212.4Q602.2 211.8 602.6 211.3Q603 210.7 603.3 211.6Q603.6 212.4 603.6 212.7Q603.6 213 604 213.7M603.9 213.9Q604.1 214.7 603.6 214.3Q603 214 602.9 213.8Q602.7 213.6 602.2 213.3Q601.7 213 601.5 212.7Q601.3 212.3 602.1 211.4Q603 210.4 603.5 211.3Q604 212.1 603.8 212.6Q603.6 213 603.9 213.9\" fill=\"none\" stroke=\"#121419\" stroke-width=\"2\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a3630\" d=\"M614.4 227.7Q614.7 228.3 613.9 228.9Q613 229.4 612.2 229.1Q611.5 228.8 611.9 227.9Q612.4 227 612.2 226.2Q612 225.3 612.5 225.6Q613 225.9 613.4 225.9Q613.8 225.9 613.9 226.4Q614 227 614.4 227.7M614.9 227.6Q614.6 228.2 613.8 227.9Q613 227.6 612.2 228.2Q611.4 228.8 611.2 227.9Q610.9 227 611.6 226.1Q612.3 225.2 612.6 225.8Q613 226.4 613.9 225.8Q614.8 225.3 615 226.2Q615.2 227 614.9 227.6\" fill=\"none\" stroke=\"#121419\" stroke-width=\"2\" stroke-linecap=\"round\"\/><ellipse data-hk=\"000000010000000000004000010a920a3700\" cx=\"652\" cy=\"220\" rx=\"9\" ry=\"9\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a3701\" d=\"M659.6 223.5Q657.6 227 654.8 228.3Q652 229.7 648.6 228Q645.2 226.4 644.3 223.2Q643.5 220 644.2 216.4Q644.9 212.9 648.5 212.4Q652 211.8 655 212.5Q657.9 213.1 659.8 216.6Q661.7 220 659.6 223.5M659.4 223.4Q658.2 226.8 655.1 228.4Q652 229.9 649.2 228.2Q646.4 226.5 645.1 223.3Q643.8 220 644.5 216.6Q645.2 213.3 648.6 211.7Q652 210.2 655.3 211.5Q658.7 212.9 659.6 216.4Q660.6 220 659.4 223.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010a920a3710\" d=\"M658.9 226.9C665.3 231.5 667.4 234.3 668.9 238.8M658.5 226.3C664.6 231.8 667.7 234.7 670.7 238.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2.2\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010a920a380\" x=\"586.5\" y=\"251.5\" width=\"117\" height=\"49\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a381\" d=\"M584.6 248.9C642.3 250.5 665.7 249.1 707.6 248.8M584.6 248.5C632.2 249.8 671.7 250.5 708.5 251.4M704 249.2C705 273.8 704.4 290.6 705.7 303.8M704.2 248.3C706.1 269.7 706.1 291.7 704.6 303.3M706 302.5C647.4 301.6 614 301.9 584.9 300.6M707.5 301.5C652.5 301.7 626.9 301.5 585.3 302.5M585 303.7C583.8 279.8 583.9 257.1 586.2 250.1M586.4 302.5C584.7 280.6 586.8 259.9 586 248.8\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a390\" x=\"645\" y=\"272\" font-size=\"13.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">EXECUTOR<\/text><text data-hk=\"000000010000000000004000010a920a400\" x=\"645\" y=\"290\" font-size=\"13.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">STUB<\/text><text data-hk=\"000000010000000000004000010a920a410\" x=\"645\" y=\"322\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">py + rg<\/text><path data-hk=\"000000010000000000004000010a920a420\" d=\"M708.8 275.9C748 275.4 771.1 276.3 789.8 276.9M709.8 275.8C736.7 277.6 772.1 276 790.7 275.5\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><text data-hk=\"000000010000000000004000010a920a430\" x=\"750\" y=\"264\" font-size=\"13\" fill=\"#9AA2AD\" text-anchor=\"middle\">mirrored<\/text><polygon data-hk=\"000000010000000000004000010a920a4400\" points=\"795,296 795,258 800,254 821,254 826,261 867,261 867,296\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010a920a4401\" d=\"M868.1 295.2C839.7 296.6 820.3 295.3 794.8 296M867.7 296.3C832.4 295.4 810.9 296.5 794.5 296.1M794.4 295.6C794.2 282.2 794 268.4 794.5 258.2M795 295.8C796.4 281 795.2 268.4 794.5 257.6M795.4 257.9C796.7 256.2 798.3 255.3 800 253.9M794.8 258.1C797.7 255.7 798.7 254.7 799.7 254M800.9 253.8C807.4 253.1 816.7 255.6 821.3 253.1M799.1 255C807.9 254.5 816.3 254.4 821.1 253.4M820.7 254.1C823.5 256.7 825.7 259.7 826.2 260.7M820.8 253.8C822.7 256.5 823.7 259.1 825.9 261.3M826.3 262C842.9 261.1 855.7 260.6 867.5 259.9M825.3 261.8C845.1 261.2 853.7 261 866.1 260.5M866.9 262C866.9 273.9 867.4 288.6 867.3 296.5M866.1 260.5C867.2 275.3 867 288.3 866.9 296.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010a920a4410\" x=\"831\" y=\"285\" font-size=\"13.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">&lt;git&gt;<\/text><text data-hk=\"000000010000000000004000010a920a450\" x=\"831\" y=\"322\" font-size=\"13\" fill=\"#DBD8CF\" text-anchor=\"middle\" transform=\"rotate(-0.8 831 322)\">RO overlay<\/text><text data-hk=\"000000010000000000004000010a920a460\" x=\"720\" y=\"372\" font-size=\"13\" fill=\"#9AA2AD\">that&#8217;s it.<\/text><text data-hk=\"000000010000000000004000010a920a470\" x=\"720\" y=\"388\" font-size=\"13\" fill=\"#9AA2AD\">nothing else.<\/text><text data-hk=\"000000010000000000004000010a920a480\" x=\"950\" y=\"545\" font-size=\"14.5\" fill=\"#DBD8CF\" text-anchor=\"end\" transform=\"rotate(-0.5 950 545)\">minimum viable prisoner<\/text><!--\/--><\/svg><\/figure>\n<p data-hk=\"000000010000000000004000010a9300\">The diagrams lead to one boundary:<\/p>\n<ul data-hk=\"000000010000000000004000010a9400\">\n<li data-hk=\"000000010000000000004000010a940100\">The <strong data-hk=\"000000010000000000004000010a94010100\">host<\/strong> owns session state, inference, policy, tool routing, approval, limits, and journaling.<\/li>\n<li data-hk=\"000000010000000000004000010a940200\">The <strong data-hk=\"000000010000000000004000010a94020100\">sandbox<\/strong> owns environment execution through a small, obedient protocol.<\/li>\n<li data-hk=\"000000010000000000004000010a940300\">Every stream crossing back is bounded before the untrusted side can exhaust host memory or context.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010a9500\">That arrangement satisfies Factorio without making local use worse. The same host can point the stub<br \/>\nat a local process, a container, a VM, or a remote machine.<\/p>\n<h3 data-hk=\"000000010000000000004000010a9600\" id=\"subagents-cross-the-same-boundary\">Subagents cross the same boundary<\/h3>\n<p data-hk=\"000000010000000000004000010a9700\">Placement is not only host versus VM. Subagents need the same boundary at the filesystem layer:<br \/>\nworktrees isolate tracked files only, while <code data-hk=\"000000010000000000004000010a970100\">pi-iso<\/code> gives each child a copy-on-write view of the<br \/>\nwhole workspace using APFS, btrfs, ZFS, overlayfs, ProjFS, or a copy fallback. The child diverges;<br \/>\nthe parent receives a diff.<\/p>\n<p data-hk=\"000000010000000000004000010a9800\">The child receives a view and returns changes. It does not share the parent&#8217;s mutable authority.<br \/>\nThat is the filesystem form of the same host\/sandbox rule.<\/p>\n<h3 data-hk=\"000000010000000000004000010a9900\" id=\"what-omp-taught-us-one-call-three-disconnected-apis\">What omp taught us: one call, three disconnected APIs<\/h3>\n<p data-hk=\"000000010000000000004000010b10000\">Okay, but how do we define a tool? We&#8217;ll go into the changes we made initially later on, but we<br \/>\nmostly kept the core contract identical:<\/p>\n<pre data-hk=\"000000010000000000004000010b10100\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1010100\"><span data-hk=\"000000010000000000004000010b101010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101010100\" style=\"color:#FF54C0\">export<\/span><span data-hk=\"000000010000000000004000010b10101010200\" style=\"color:#FF54C0\"> const<\/span><span data-hk=\"000000010000000000004000010b10101010300\" style=\"color:#C9A4FF\"> myCustomTool<\/span><span data-hk=\"000000010000000000004000010b10101010400\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b10101010500\" style=\"color:#C9A4FF\">ToolDefinition<\/span><span data-hk=\"000000010000000000004000010b10101010600\" style=\"color:#CFD4DC\"> = {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101020100\" style=\"color:#9BE8FF\">\tname<\/span><span data-hk=\"000000010000000000004000010b10101020200\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b10101020300\" style=\"color:#B99AFF\">\"my_tool\"<\/span><span data-hk=\"000000010000000000004000010b10101020400\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101030100\" style=\"color:#9BE8FF\">\tparameters<\/span><span data-hk=\"000000010000000000004000010b10101030200\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b10101030300\" style=\"color:#9BE8FF\">mySchema<\/span><span data-hk=\"000000010000000000004000010b10101030400\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010400\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b101010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101050100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\t\/\/ 1. Called during argument streaming &amp; before execute()<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101060100\" style=\"color:#44CFFF\">\trenderCall<\/span><span data-hk=\"000000010000000000004000010b10101060200\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b10101060300\" style=\"color:#9BE8FF;fontStyle:italic\">args<\/span><span data-hk=\"000000010000000000004000010b10101060400\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b10101060500\" style=\"color:#9BE8FF;fontStyle:italic\">theme<\/span><span data-hk=\"000000010000000000004000010b10101060600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b10101060700\" style=\"color:#9BE8FF;fontStyle:italic\">context<\/span><span data-hk=\"000000010000000000004000010b10101060800\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101070100\" style=\"color:#FF54C0\">\t\tif<\/span><span data-hk=\"000000010000000000004000010b10101070200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b10101070300\" style=\"color:#9BE8FF\">context<\/span><span data-hk=\"000000010000000000004000010b10101070400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b10101070500\" style=\"color:#9BE8FF\">argsComplete<\/span><span data-hk=\"000000010000000000004000010b10101070600\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101080100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\t\t\t\/\/ Trigger async preview computation<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b10101090100\" style=\"color:#CFD4DC\">\t\t}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a100100\" style=\"color:#FF54C0\">\t\treturn<\/span><span data-hk=\"000000010000000000004000010b101010a100200\" style=\"color:#FF54C0\"> new<\/span><span data-hk=\"000000010000000000004000010b101010a100300\" style=\"color:#44CFFF\"> Text<\/span><span data-hk=\"000000010000000000004000010b101010a100400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b101010a100500\" style=\"color:#B99AFF\">\"Pre-execution preview UI...\"<\/span><span data-hk=\"000000010000000000004000010b101010a100600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a100700\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b101010a100800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a100900\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b101010a100a1000\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a110100\" style=\"color:#CFD4DC\">\t},<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1200\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b101010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a130100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\t\/\/ 2. Main execution<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a140100\" style=\"color:#FF54C0\">\tasync<\/span><span data-hk=\"000000010000000000004000010b101010a140200\" style=\"color:#44CFFF\"> execute<\/span><span data-hk=\"000000010000000000004000010b101010a140300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b101010a140400\" style=\"color:#9BE8FF;fontStyle:italic\">_id<\/span><span data-hk=\"000000010000000000004000010b101010a140500\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a140600\" style=\"color:#9BE8FF;fontStyle:italic\">params<\/span><span data-hk=\"000000010000000000004000010b101010a140700\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1500\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a150100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\t\t\/* ... -&gt; string *\/<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1600\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a160100\" style=\"color:#CFD4DC\">\t},<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1700\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b101010a1800\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a180100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\t\/\/ 3. Called after execute() settles<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a1900\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a190100\" style=\"color:#44CFFF\">\trenderResult<\/span><span data-hk=\"000000010000000000004000010b101010a190200\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b101010a190300\" style=\"color:#9BE8FF;fontStyle:italic\">result<\/span><span data-hk=\"000000010000000000004000010b101010a190400\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a190500\" style=\"color:#9BE8FF;fontStyle:italic\">options<\/span><span data-hk=\"000000010000000000004000010b101010a190600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a190700\" style=\"color:#9BE8FF;fontStyle:italic\">theme<\/span><span data-hk=\"000000010000000000004000010b101010a190800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a190900\" style=\"color:#9BE8FF;fontStyle:italic\">context<\/span><span data-hk=\"000000010000000000004000010b101010a190a1000\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a2000\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a200100\" style=\"color:#FF54C0\">\t\treturn<\/span><span data-hk=\"000000010000000000004000010b101010a200200\" style=\"color:#FF54C0\"> new<\/span><span data-hk=\"000000010000000000004000010b101010a200300\" style=\"color:#44CFFF\"> Text<\/span><span data-hk=\"000000010000000000004000010b101010a200400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b101010a200500\" style=\"color:#B99AFF\">\"Final execution result UI\"<\/span><span data-hk=\"000000010000000000004000010b101010a200600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a200700\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b101010a200800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b101010a200900\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b101010a200a1000\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a2100\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a210100\" style=\"color:#CFD4DC\">\t},<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b101010a2200\" class=\"line \"><span data-hk=\"000000010000000000004000010b101010a220100\" style=\"color:#CFD4DC\">};<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b10200\">This contract looks pleasantly small, but it splits one operation into three unrelated phases. The<br \/>\npreview, execution, model result, human result, diagnostics, streaming updates, cancellation, and<br \/>\njournal record all describe the same call. The API makes them pretend otherwise.<\/p>\n<h3 data-hk=\"000000010000000000004000010b10300\" id=\"the-callback-split-duplicates-work\">The callback split duplicates work<\/h3>\n<p data-hk=\"000000010000000000004000010b10400\">First, splitting the renderer path makes reactivity opt-in. Even when the rendered tool does not<br \/>\n\u201csnap\u201d into a new shape, the author has to duplicate much of the presentation logic.<\/p>\n<p data-hk=\"000000010000000000004000010b10500\">The larger problem is how <code data-hk=\"000000010000000000004000010b1050100\">execute<\/code> works. Take Edit as an example:<\/p>\n<ul data-hk=\"000000010000000000004000010b10600\">\n<li data-hk=\"000000010000000000004000010b1060100\"><code data-hk=\"000000010000000000004000010b106010100\">renderCall<\/code> will open the file, hopefully caching the read parts somewhere (where?), apply the<br \/>\nedits, and render a diff<\/li>\n<li data-hk=\"000000010000000000004000010b1060200\"><code data-hk=\"000000010000000000004000010b106020100\">execute<\/code> will then open the file again, applying all, writing, and returning a diff in a<br \/>\nmodel-friendly format<\/li>\n<li data-hk=\"000000010000000000004000010b1060300\"><code data-hk=\"000000010000000000004000010b106030100\">renderResult<\/code> then gets this diff, but has to parse whatever format we decided on! Why? Because<br \/>\na human wants to see colorized and highlighted version of course, maybe with nicer line numbers.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b10700\">This led to an instinctual implementation that:<\/p>\n<ul data-hk=\"000000010000000000004000010b10800\">\n<li data-hk=\"000000010000000000004000010b1080100\">wasted I\/O time: file opened twice<\/li>\n<li data-hk=\"000000010000000000004000010b1080200\">wasted CPU time: application was calculated not once, not twice, but each time a character<br \/>\nchanged, all over (renderCall is not a coroutine!)<\/li>\n<li data-hk=\"000000010000000000004000010b1080300\">unnecessary ser\/de over arbitrary format: we had to parse model output to implement renderResult<br \/>\n(or pass bits in details, duplicating the data journaled)<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b10900\">In order to make this efficient, you need to implement a coroutine that you drive outside this<br \/>\ndefinition, find a place to store its handle, and you will still have to implement the whole result<br \/>\ndeserialization business.<\/p>\n<p data-hk=\"000000010000000000004000010b11000\">The problem is not merely duplicated code. The contract has no authoritative object whose state<br \/>\nmoves from \u201carguments streaming\u201d through \u201crunning\u201d to \u201csettled.\u201d Every implementation invents a<br \/>\nside channel for that lifecycle.<\/p>\n<h3 data-hk=\"000000010000000000004000010b11100\" id=\"what-omp-changes-execution-is-a-state-stream\">What omp\u00b2 changes: execution is a state stream<\/h3>\n<aside data-hk=\"000000010000000000004000010b1120\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Tool execution is a bounded, cancellable stream of state\u2014not an async function that returns text.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b11210\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b11300\">There is also no general way to add structured warnings, diagnostics, or truncation notices. Most<br \/>\nPi tool implementations end up doing something like:<\/p>\n<pre data-hk=\"000000010000000000004000010b11400\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1140100\"><span data-hk=\"000000010000000000004000010b114010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b11401010100\" style=\"color:#9BE8FF\">text<\/span><span data-hk=\"000000010000000000004000010b11401010200\" style=\"color:#CFD4DC\"> += <\/span><span data-hk=\"000000010000000000004000010b11401010300\" style=\"color:#B99AFF\">`<\/span><span data-hk=\"000000010000000000004000010b11401010400\" style=\"color:#CFD4DC\">\\n<\/span><span data-hk=\"000000010000000000004000010b11401010500\" style=\"color:#FF54C0\">${<\/span><span data-hk=\"000000010000000000004000010b11401010600\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b11401010700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b11401010800\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b11401010900\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b11401010a1000\" style=\"color:#B99AFF\">\"warning\"<\/span><span data-hk=\"000000010000000000004000010b11401010a1100\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b11401010a1200\" style=\"color:#B99AFF\">`[Truncated: <\/span><span data-hk=\"000000010000000000004000010b11401010a1300\" style=\"color:#FF54C0\">${<\/span><span data-hk=\"000000010000000000004000010b11401010a1400\" style=\"color:#9BE8FF\">truncation<\/span><span data-hk=\"000000010000000000004000010b11401010a1500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b11401010a1600\" style=\"color:#9BE8FF\">outputLines<\/span><span data-hk=\"000000010000000000004000010b11401010a1700\" style=\"color:#FF54C0\">}<\/span><span data-hk=\"000000010000000000004000010b11401010a1800\" style=\"color:#B99AFF\"> lines shown (<\/span><span data-hk=\"000000010000000000004000010b11401010a1900\" style=\"color:#FF54C0\">${<\/span><span data-hk=\"000000010000000000004000010b11401010a2000\" style=\"color:#44CFFF\">formatSize<\/span><span data-hk=\"000000010000000000004000010b11401010a2100\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b11401010a2200\" style=\"color:#9BE8FF\">truncation<\/span><span data-hk=\"000000010000000000004000010b11401010a2300\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b11401010a2400\" style=\"color:#9BE8FF\">maxBytes<\/span><span data-hk=\"000000010000000000004000010b11401010a2500\" style=\"color:#CFD4DC\"> ?? <\/span><span data-hk=\"000000010000000000004000010b11401010a2600\" style=\"color:#C9A4FF\">DEFAULT_MAX_BYTES<\/span><span data-hk=\"000000010000000000004000010b11401010a2700\" style=\"color:#CFD4DC\">)<\/span><span data-hk=\"000000010000000000004000010b11401010a2800\" style=\"color:#FF54C0\">}<\/span><span data-hk=\"000000010000000000004000010b11401010a2900\" style=\"color:#B99AFF\"> limit)]`<\/span><span data-hk=\"000000010000000000004000010b11401010a3000\" style=\"color:#CFD4DC\">)<\/span><span data-hk=\"000000010000000000004000010b11401010a3100\" style=\"color:#FF54C0\">}<\/span><span data-hk=\"000000010000000000004000010b11401010a3200\" style=\"color:#B99AFF\">`<\/span><span data-hk=\"000000010000000000004000010b11401010a3300\" style=\"color:#CFD4DC\">;<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b11500\">The model then has to guess where tool data ends and harness commentary begins. Because <code data-hk=\"000000010000000000004000010b1150100\">execute<\/code><br \/>\nis not a generator, streaming output requires yet another protocol over the update channel.<\/p>\n<p data-hk=\"000000010000000000004000010b11600\">The DOM model removes both special cases:<\/p>\n<ul data-hk=\"000000010000000000004000010b11700\">\n<li data-hk=\"000000010000000000004000010b1170100\">streaming output mutates the <code data-hk=\"000000010000000000004000010b117010100\">&lt;result&gt;<\/code> body;<\/li>\n<li data-hk=\"000000010000000000004000010b1170200\">adding a warning creates <code data-hk=\"000000010000000000004000010b117020100\">&lt;diag severity=\"warn\"&gt;<\/code>.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b11800\">While execution is ongoing, clients receive patches to this state. Once it settles, the final diff<br \/>\nagainst the previous state is journaled.<\/p>\n<p data-hk=\"000000010000000000004000010b11900\">In the unified session model, a call is an element with structured children:<\/p>\n<pre data-hk=\"000000010000000000004000010b12000\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1200100\"><span data-hk=\"000000010000000000004000010b120010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b12001010100\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b12001010200\" style=\"color:#FF54C0\">Edit<\/span><span data-hk=\"000000010000000000004000010b12001010300\" style=\"color:#9BE8FF\"> id<\/span><span data-hk=\"000000010000000000004000010b12001010400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b12001010500\" style=\"color:#B99AFF\">\"e41\"<\/span><span data-hk=\"000000010000000000004000010b12001010600\" style=\"color:#9BE8FF\"> status<\/span><span data-hk=\"000000010000000000004000010b12001010700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b12001010800\" style=\"color:#B99AFF\">\"running\"<\/span><span data-hk=\"000000010000000000004000010b12001010900\" style=\"color:#9BE8FF\"> version<\/span><span data-hk=\"000000010000000000004000010b12001010a1000\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b12001010a1100\" style=\"color:#B99AFF\">\"3\"<\/span><span data-hk=\"000000010000000000004000010b12001010a1200\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b120010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b12001020100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010b12001020200\" style=\"color:#FF54C0\">input<\/span><span data-hk=\"000000010000000000004000010b12001020300\" style=\"color:#9BE8FF\"> i<\/span><span data-hk=\"000000010000000000004000010b12001020400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b12001020500\" style=\"color:#B99AFF\">\"Update the parser without changing the public API\"<\/span><span data-hk=\"000000010000000000004000010b12001020600\" style=\"color:#CFD4DC\">&gt;\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010b12001020700\" style=\"color:#FF54C0\">input<\/span><span data-hk=\"000000010000000000004000010b12001020800\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b120010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b12001030100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010b12001030200\" style=\"color:#FF54C0\">result<\/span><span data-hk=\"000000010000000000004000010b12001030300\" style=\"color:#CFD4DC\">&gt;\u2026streaming structured state\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010b12001030400\" style=\"color:#FF54C0\">result<\/span><span data-hk=\"000000010000000000004000010b12001030500\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b120010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b12001040100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010b12001040200\" style=\"color:#FF54C0\">diag<\/span><span data-hk=\"000000010000000000004000010b12001040300\" style=\"color:#9BE8FF\"> severity<\/span><span data-hk=\"000000010000000000004000010b12001040400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b12001040500\" style=\"color:#B99AFF\">\"warn\"<\/span><span data-hk=\"000000010000000000004000010b12001040600\" style=\"color:#CFD4DC\">&gt;\u2026&lt;\/<\/span><span data-hk=\"000000010000000000004000010b12001040700\" style=\"color:#FF54C0\">diag<\/span><span data-hk=\"000000010000000000004000010b12001040800\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b120010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b12001050100\" style=\"color:#CFD4DC\">   &lt;<\/span><span data-hk=\"000000010000000000004000010b12001050200\" style=\"color:#FF54C0\">usage<\/span><span data-hk=\"000000010000000000004000010b12001050300\" style=\"color:#9BE8FF\"> tokens<\/span><span data-hk=\"000000010000000000004000010b12001050400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b12001050500\" style=\"color:#B99AFF\">\"0\"<\/span><span data-hk=\"000000010000000000004000010b12001050600\" style=\"color:#9BE8FF\"> elapsed-ms<\/span><span data-hk=\"000000010000000000004000010b12001050700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b12001050800\" style=\"color:#B99AFF\">\"842\"<\/span><span data-hk=\"000000010000000000004000010b12001050900\" style=\"color:#CFD4DC\">\/&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b120010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b12001060100\" style=\"color:#CFD4DC\">&lt;\/<\/span><span data-hk=\"000000010000000000004000010b12001060200\" style=\"color:#FF54C0\">Edit<\/span><span data-hk=\"000000010000000000004000010b12001060300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b12100\">The executor mutates this element while it runs. The model, user, journal, remote client, and test<br \/>\nharness observe different projections of the same state. Settling freezes the final diff; no client<br \/>\nhas to parse a result string to recover the richer object that existed before serialization.<\/p>\n<h3 data-hk=\"000000010000000000004000010b12200\" id=\"limits-are-part-of-the-primitive\">Limits are part of the primitive<\/h3>\n<p data-hk=\"000000010000000000004000010b12300\">A Pi tool has no limits: return 1 MB of text and it is forwarded to the model verbatim. That is too<br \/>\nlow-level a primitive to expose.<\/p>\n<h4 data-hk=\"000000010000000000004000010b12400\" id=\"bound-output-once\">Bound output once<\/h4>\n<p data-hk=\"000000010000000000004000010b12500\">Pi faced this itself with <code data-hk=\"000000010000000000004000010b1250100\">Bash<\/code> and <code data-hk=\"000000010000000000004000010b1250200\">Read<\/code>, and answered with a truncation utility exported for<br \/>\nimplementations to share. omp extended that utility with an artifact system so the model can read<br \/>\nthe preserved full output back, but left the responsibility where Pi left it: on each<br \/>\nimplementation.<\/p>\n<p data-hk=\"000000010000000000004000010b12600\">Sending 1 MB to the model may be a capability worth keeping, but it should be an opt-out\u2014one central<br \/>\nimplementation and an explicit <code data-hk=\"000000010000000000004000010b1260100\">notrunc<\/code> property\u2014rather than truncation being an opt-in to good<br \/>\ndesign. Leaving the helper optional fails in two ways.<\/p>\n<p data-hk=\"000000010000000000004000010b12700\">Most tools need some truncation, so an opt-in helper guarantees uneven coverage:<\/p>\n<ul data-hk=\"000000010000000000004000010b12800\">\n<li data-hk=\"000000010000000000004000010b1280100\">authors who do not know the helper exists roll their own, each with a slightly different notice;<\/li>\n<li data-hk=\"000000010000000000004000010b1280200\">authors who never imagined a huge result roll nothing.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b12900\">Truncating inside the tool implementation, rather than at the conversation-rendering layer, breaks<br \/>\nCode mode:<\/p>\n<ul data-hk=\"000000010000000000004000010b13000\">\n<li data-hk=\"000000010000000000004000010b1300100\">the agent can never rely on a tool&#8217;s output inside <code data-hk=\"000000010000000000004000010b130010100\">Eval<\/code>; every use has to parse harness notices<br \/>\nout of the data first;<\/li>\n<li data-hk=\"000000010000000000004000010b1300200\">the <code data-hk=\"000000010000000000004000010b130020100\">Eval<\/code> result may itself be truncated, so each invocation stacks N+1 independent truncation<br \/>\nlayers around the same data.<\/li>\n<\/ul>\n<h4 data-hk=\"000000010000000000004000010b13100\" id=\"bound-blocking-time-once\">Bound blocking time once<\/h4>\n<p data-hk=\"000000010000000000004000010b13200\">Backgrounding <em data-hk=\"000000010000000000004000010b1320100\">anything<\/em>, and capping how long a call may block, belong to the library layer as<br \/>\nwell\u2014not to each tool that happens to run long.<\/p>\n<p data-hk=\"000000010000000000004000010b13300\">The first reason is caching and UX. An unexpectedly long call otherwise leaves the agent unable to<br \/>\nnotice and adjust, the user returning to a stuck session, autonomous jobs waiting forever, and the<br \/>\nprovider&#8217;s KV cache expiring before the call returns.<\/p>\n<p data-hk=\"000000010000000000004000010b13400\">The second reason, which omp got wrong too, is duplication. When every tool grows its own<br \/>\nbackgrounding, every tool also grows its own spawn, poll, message, kill, and list helpers. Take<br \/>\nthis diagram Claude drew around its own <code data-hk=\"000000010000000000004000010b1340100\">Task<\/code> and <code data-hk=\"000000010000000000004000010b1340200\">Bash<\/code> tools:<\/p>\n<figure data-hk=\"000000010000000000004000010b135\"><svg data-hk=\"000000010000000000004000010b13600\" class=\"st-sketch\" viewbox=\"0 0 1000 630\" role=\"img\" aria-label=\"Mapping of Claude Code's background Bash tool surface against its Task subagent surface: spawn, stream out, message in, stop, result, and list each have a counterpart on both sides \u2014 run_in_background\/Task, BashOutput\/system-reminder, stdin\/SendMessage, KillShell\/interrupt, exit code\/tool_result, \/bashes\/ListAgents.\" font-family=\"var(--st-font-sketch)\"><defs><pattern id=\"bvt-dots\" width=\"22\" height=\"22\" patternunits=\"userSpaceOnUse\"><circle cx=\"11\" cy=\"11\" r=\"1.1\" fill=\"#2E333C\"\/><\/pattern><\/defs><rect width=\"1000\" height=\"630\" fill=\"#121419\"\/><rect width=\"1000\" height=\"630\" fill=\"url(#bvt-dots)\"\/><!--$--><rect data-hk=\"000000010000000000004000010b136010\" x=\"101.5\" y=\"49.5\" width=\"277\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b136011\" d=\"M110.2 49.5C224.2 49.2 325.3 48.1 371.1 48.6M111.1 47.3C216 47.5 291 47.6 371 49.2M378.5 59C381.7 69.2 381.2 77.8 379.2 81.4M380.8 56.6C380.7 66.8 380.5 74.4 381.4 82.9M371.3 90.9C285.5 91.7 160.6 89.8 111.3 91.7M369.7 92.4C287.9 92.3 178.9 91.2 110.3 92.6M99.5 81C99.5 71.1 100.4 64.2 100.3 57.8M100.5 82.8C99.3 70.5 98.2 63.5 99.4 58.6M371 49.4Q381 47 380.9 59M378.9 80.6Q380.4 92.3 369.7 92.2M110.9 90.9Q100.3 93.5 101.5 82.6M99.8 57.2Q99.5 46.7 109 48.3\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b136020\" x=\"240\" y=\"76\" font-size=\"15.5\" fill=\"#4ADE80\" text-anchor=\"middle\" stroke=\"#4ADE80\" stroke-width=\"0.8\">Background Bash<\/text><rect data-hk=\"000000010000000000004000010b136030\" x=\"431.5\" y=\"49.5\" width=\"157\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b136031\" d=\"M439.8 49.1C502 46.9 547.8 47.2 580.2 47M440.2 48.1C509.4 48.1 534.6 48.8 579.1 49.4M589.6 58C590.4 67.4 588.5 76.6 589.2 83.2M590.7 57C588.2 65.6 588.6 74 591.5 80.6M579.1 92.2C530.2 94.3 471.1 93.4 440.2 92.9M579.4 90.8C533.2 93.7 480.5 89.8 439.7 91.4M428.6 83C428.7 72.8 429.2 64.9 430.7 59.2M429 83.3C428.1 70.5 428.7 61.1 431.4 57.7M581.4 47.7Q589 47.3 588.8 58.1M590.1 80.7Q590.7 92.3 580.6 90.6M440.2 92Q429.2 90.7 428.6 83.2M429.5 57.9Q428.9 48 439.3 49.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b136040\" x=\"510\" y=\"76\" font-size=\"15.5\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">Interface<\/text><rect data-hk=\"000000010000000000004000010b136050\" x=\"651.5\" y=\"49.5\" width=\"277\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b136051\" d=\"M660.1 48.8C744.9 51.4 862.3 50.1 919.8 47.1M660 47.4C779.1 46.4 858.6 47.1 919.9 47.8M929.4 58.2C931 70.6 928.3 76.4 930.4 83M928.5 59C928.8 70.4 930.6 76.9 931.4 83.2M920.6 91.2C799.5 93.4 741.1 89.8 659.7 93M920.9 92.5C802.6 91.4 729.7 90.7 660.7 92.6M650.3 83.3C649.5 71 651.6 64.8 650.6 57.3M650.4 80.9C650.1 70.1 651.2 64.3 650 56.8M919.9 47.4Q929.4 48.5 931.2 57.1M930.1 80.7Q930.3 92.2 918.7 91.8M661.3 91.2Q648.6 93.1 649 82.9M649 57.3Q650.3 46.9 660.9 49.2\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b136060\" x=\"790\" y=\"76\" font-size=\"15.5\" fill=\"#A78BFA\" text-anchor=\"middle\" stroke=\"#A78BFA\" stroke-width=\"0.8\">Subagent<\/text><rect data-hk=\"000000010000000000004000010b13607000\" x=\"101.5\" y=\"117.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607001\" d=\"M109.1 115.2C224.2 115.9 314.1 112.7 371.1 115.4M110.4 116.4C209.6 117.3 300.8 117.3 370.8 117.4M380.3 125.3C381 141.7 381.1 150.9 379.4 161.1M381.1 127C380.9 138.7 382.3 153.6 380.7 162.8M369.6 170.8C281.3 173.5 163.5 171.2 110.8 171.4M371.2 172.1C287.4 170.6 186.7 172.6 108.8 171.7M100.7 162.7C101.1 147 100.6 139 99.8 125.8M100 162.9C101.1 145.1 100.9 136.9 99.9 127M370.3 115.4Q379.6 114.7 379.5 127M380.6 161.1Q378.9 172.8 371 170.6M110.6 172Q100.8 172 100.8 160.5M99.9 126.3Q100.7 115.9 110.1 115.2\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607010\" x=\"240\" y=\"141\" font-size=\"14.5\" fill=\"#4ADE80\" text-anchor=\"middle\">Bash<\/text><text data-hk=\"000000010000000000004000010b13607020\" x=\"240\" y=\"160\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">run_in_background: true<\/text><rect data-hk=\"000000010000000000004000010b1360710\" x=\"431.5\" y=\"123.5\" width=\"157\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b1360711\" d=\"M440.4 121.3C493 122.2 534.9 119.9 580.8 120.8M439.1 122.7C507.9 121.5 550.3 121.4 581.1 120.7M588.8 131.9C590.3 142.6 588.9 151.4 588.5 155.1M590.6 133.1C591.1 140 590.7 149.5 588.9 155M579.7 165.7C536.5 164.3 486.8 165 438.7 165.3M579.5 166.6C517.8 165 469.8 168.1 441 165.2M430.8 155.9C429.7 143.6 430.4 137.3 431.1 133.4M430 156.2C431.3 145.7 430.9 138.2 428.6 132.7M579.6 121.8Q590.8 123 590.9 132M589.4 156.3Q591.5 164.9 580.1 167.3M439.2 166.8Q430.8 166.5 429.4 155.1M430.1 132.2Q430 123 439.7 120.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1360720\" x=\"510\" y=\"150\" font-size=\"14.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">Spawn<\/text><rect data-hk=\"000000010000000000004000010b13607300\" x=\"651.5\" y=\"117.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607301\" d=\"M661.1 117.4C788.3 117 839.4 113.6 918.5 117M659.2 114.7C770.3 115.7 835.6 118 920.2 114.5M929.7 124.6C931 145.2 931.7 153.6 928.7 163.4M931.2 127.3C930.8 139.5 930.4 154.4 930.3 161M919.1 173.4C791.7 173.5 702.9 171.1 658.7 172.4M921.1 170.6C827 171.8 737.7 172.3 660.1 171M649.8 162.6C650.3 148.5 649.3 133.8 648.9 125.3M651.1 162.7C651.1 150.7 649.7 136.3 649.9 125.2M919.6 117.5Q931.4 116.7 930.2 125.9M929.9 162.2Q931.4 171.8 919.1 171.5M660.9 173.4Q649.6 172.2 650 161.8M651 127.4Q649.8 117.2 659.4 116.4\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607310\" x=\"790\" y=\"141\" font-size=\"14.5\" fill=\"#A78BFA\" text-anchor=\"middle\">Task<\/text><text data-hk=\"000000010000000000004000010b13607320\" x=\"790\" y=\"160\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">prompt, subagent_type<\/text><path data-hk=\"000000010000000000004000010b1360740\" d=\"M389.2 145.3C397.5 144.3 414.4 145.7 421.3 143.6M388.2 143.7C402.1 145.3 415.9 143.5 421.7 142.6\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b1360750\" d=\"M597.7 143.9C618.7 142.8 634.4 143.9 642.2 143.2M598.1 143.3C616.4 142.9 631.8 143.8 643 144\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><rect data-hk=\"000000010000000000004000010b13607600\" x=\"101.5\" y=\"201.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607601\" d=\"M109.5 199.3C199.2 199.2 295.2 199.5 368.8 198.9M111.1 201.1C189.2 203.5 320.8 202.9 369 200.9M379.8 209.1C381 224.5 379.2 233.9 380.1 244.9M381.1 209.9C379.3 225.2 381.7 238.1 380.2 245.4M369.4 254.6C262.4 258.2 167.7 252.4 108.6 256.7M371.4 255.9C286.9 253.9 191.8 255.8 111 256.7M99.8 244.8C99.5 230 99.9 218.2 99.9 208.9M100.4 247C100.9 232.8 100.5 219.4 101.1 210.8M369 199.1Q380.5 199.1 379.9 209.4M380.2 247.2Q380.3 257.3 370.4 255.7M111.3 254.8Q98.7 255.5 98.6 245.8M98.9 210.6Q98.8 200.8 109.2 199.7\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607610\" x=\"240\" y=\"225\" font-size=\"14.5\" fill=\"#4ADE80\" text-anchor=\"middle\">BashOutput<\/text><text data-hk=\"000000010000000000004000010b13607620\" x=\"240\" y=\"244\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">poll by bash_id<\/text><rect data-hk=\"000000010000000000004000010b1360770\" x=\"431.5\" y=\"207.5\" width=\"157\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b1360771\" d=\"M440.6 206.9C484.9 206.9 557.2 205.8 578.8 205.2M441.3 206C506.2 204.8 538.7 206.9 579.9 204.8M591.2 214.5C589.7 225.1 590.8 232 589.5 240.1M589.5 214.5C590 225.7 590.8 233.9 590.4 239.2M578.6 249.8C533.5 247.9 473.3 250.8 440.4 248.9M580.8 250.6C536.7 251.7 475.1 249.3 441 250.2M429.8 241.2C430.7 228.7 431.2 223.6 430 215M429.9 239C430.7 230.7 428.8 221.7 431.3 216.4M579.7 205.6Q590.2 205.4 589.4 215.2M590.6 240Q589.2 250.7 580.6 248.6M441.1 250.1Q430.6 250.2 431.1 238.9M429.1 216Q431.2 206.8 441.5 205.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1360780\" x=\"510\" y=\"234\" font-size=\"14.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">Stream out<\/text><rect data-hk=\"000000010000000000004000010b13607900\" x=\"651.5\" y=\"201.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607901\" d=\"M659.4 201.2C783.1 201.8 856.8 198.6 920.8 201.5M659.3 200.6C740.4 202.6 847.9 202.5 920.6 201.5M930.1 210.6C932 227.9 930.1 236.8 929.8 247.2M931.1 211C930.7 225.2 928.5 235.4 929.4 246.4M920.4 256.3C800.4 256.1 721.1 258.7 661.3 255.8M919.5 254.7C801.2 257.2 739.3 256.4 659.6 254.9M648.7 246.2C648.6 228.7 649.2 222.8 649.1 210.5M650 244.5C648.9 227.7 651.2 216.6 650.2 210.4M920.7 199.8Q930.9 200.2 928.9 210.4M930.6 245.7Q928.9 255.4 918.6 254.6M661.4 256Q649.8 255.9 649.5 246.7M651.3 209.5Q649 200.3 660.3 200.3\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607910\" x=\"790\" y=\"225\" font-size=\"14.5\" fill=\"#F5B04A\" text-anchor=\"middle\">system-reminder<\/text><text data-hk=\"000000010000000000004000010b13607920\" x=\"790\" y=\"244\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">async agent notification<\/text><path data-hk=\"000000010000000000004000010b13607a100\" d=\"M387.6 228.6C399.9 227.9 416.2 227.4 422 228.5M387 228.2C402.2 227.7 413 227.5 422.2 226.8\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b13607a110\" d=\"M598.1 228.4C613.6 226.9 628.9 229.4 642.5 228.4M597.5 229.4C613.1 229.5 633.9 228.3 641.6 226.8\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><rect data-hk=\"000000010000000000004000010b13607a1200\" x=\"101.5\" y=\"285.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a1201\" d=\"M109.8 282.8C214.2 281 304.5 284.7 371 283.6M109.6 285.3C208.7 285.1 327.9 283.2 369.9 282.5M381.3 294.8C379.9 309.9 378.9 322.7 380.5 329M380.1 295.4C380.8 308.6 379.1 319.8 380 329.8M369.6 341.4C277.3 341.4 151.3 342.7 108.6 339.5M369.4 339.5C274.4 338.9 188.6 342.3 111.2 340.9M99 330.3C98.1 319.3 101.4 304.8 98.5 292.9M100.4 328.8C100.5 319 99.2 304.3 99.4 294.2M371.2 284Q380.3 283 381.4 294.2M380.8 330.3Q381.5 340.7 369.9 338.6M111.5 340.2Q99.8 338.9 101 328.7M101.1 292.7Q99.5 285.4 109.3 284.9\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a1210\" x=\"240\" y=\"309\" font-size=\"14.5\" fill=\"#F5B04A\" text-anchor=\"middle\">stdin<\/text><text data-hk=\"000000010000000000004000010b13607a1220\" x=\"240\" y=\"328\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">no tool exposed<\/text><rect data-hk=\"000000010000000000004000010b13607a130\" x=\"431.5\" y=\"291.5\" width=\"157\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a131\" d=\"M440.1 289.6C498.3 291.6 548.8 292.9 581.5 291M441.2 289.9C492.2 288.4 557.4 287.2 581.5 290M591.5 300.1C588.7 308 590 317.9 590.3 323.9M589.3 301.4C589.5 307.5 588.9 317.5 591 324.7M578.5 334.1C524 333.5 473.7 335.1 439.1 334.8M580 335.4C519.2 335.3 487.2 333.5 439.7 332.7M431.1 325.3C428.2 314.8 430.4 306.5 429.8 298.7M430.6 323.1C430.9 314.9 428.8 306.3 428.8 300.5M580.3 290.2Q590.5 291.1 588.6 299.4M590.6 324.1Q589.6 332.6 580.5 334.4M439.2 333.3Q430.7 335.3 429.8 324.4M429.8 301.2Q428.5 289.9 439.5 290.4\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a140\" x=\"510\" y=\"318\" font-size=\"14.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">Message in<\/text><rect data-hk=\"000000010000000000004000010b13607a1500\" x=\"651.5\" y=\"285.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a1501\" d=\"M659.9 282.5C766.9 280.4 853.6 283 920.3 283M661.5 283.1C765.3 284.2 873.1 287.4 920.8 285.1M929.7 293.8C929 309.2 930.4 322.8 931.2 328.6M931.1 295.3C928.9 307.8 930 319.1 929.4 329.1M918.8 340.8C805.6 342 722.8 341.1 660.2 340M918.8 340.2C830.9 342.9 745.4 337.9 658.7 341.4M649.8 329.9C651.9 314.8 649.6 305.3 648.7 294.7M651.4 329.7C651.4 317.5 649.3 302.4 650.7 295.2M919.2 285.5Q929.9 284.3 930.6 293.9M931.2 330.1Q930.3 339.8 921.2 340.6M660.1 340.5Q648.5 339.2 651.1 328.5M649.8 294.6Q649.5 285.1 659.8 284.7\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a1510\" x=\"790\" y=\"309\" font-size=\"14.5\" fill=\"#A78BFA\" text-anchor=\"middle\">SendMessage<\/text><text data-hk=\"000000010000000000004000010b13607a1520\" x=\"790\" y=\"328\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">agent_id, message<\/text><path data-hk=\"000000010000000000004000010b13607a160\" d=\"M386.6 311.9C401.1 312 412.3 311.1 421.7 311.2M389.4 311.4C403.3 310.3 416.7 313.5 421.1 311.1\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b13607a170\" d=\"M597 311.6C613.6 312.3 627.4 309.8 640.9 310.7M598.9 312.7C612.9 312.4 629.2 312.7 642.6 313.1\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><rect data-hk=\"000000010000000000004000010b13607a1800\" x=\"101.5\" y=\"369.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a1801\" d=\"M109.8 367C220 369.5 331.2 365.9 371 367.2M109.1 367.9C190 369.4 292.9 368.8 370.6 367M380.6 378.3C379.8 394.1 379.2 406.4 381.2 414.4M381.3 379C381.8 395.7 380.4 403.2 380.8 414.6M370.6 422.8C255.8 423.6 167.2 424.3 110.4 425.3M371 422.6C240.8 425.7 185.9 422.2 109.1 423.7M98.5 414.1C100.6 401.6 98.7 388.4 99 379.2M99.6 413.7C99.8 402.8 98.9 384.8 98.9 377.6M370.6 368Q381 367.2 380.4 377.8M380.4 412.8Q378.7 422.9 369.2 425.3M110.2 424.2Q101.3 423.9 101.3 414.5M99.8 377Q98.5 368.3 109.9 367.1\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a1810\" x=\"240\" y=\"393\" font-size=\"14.5\" fill=\"#4ADE80\" text-anchor=\"middle\">KillShell<\/text><text data-hk=\"000000010000000000004000010b13607a1820\" x=\"240\" y=\"412\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">shell_id<\/text><rect data-hk=\"000000010000000000004000010b13607a190\" x=\"431.5\" y=\"375.5\" width=\"157\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a191\" d=\"M439.1 373.3C487.5 371.6 550.1 375.5 580.6 374.9M440.7 375C499.4 373.5 555.5 373.3 580.6 373.1M590.1 382.7C590.1 393.3 589 402.2 591.2 407.3M591.4 383.2C589.4 395.8 590.8 402.6 588.6 408.9M581.4 418.8C526.8 417 463.6 417.3 439.9 417.4M578.6 416.9C536.1 418.1 467.7 416.5 440.8 418M431 409.4C430.2 397.9 428.8 390.6 431.1 385M429.8 408C430.8 397 429 388.2 430.1 382.7M579 373.1Q588.9 373.1 591.3 384.2M589.3 407.8Q588.7 418.4 580.8 419.5M440.6 419.3Q430.8 418 429.1 408.4M431.4 384.6Q428.7 373.4 440.3 374.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a200\" x=\"510\" y=\"402\" font-size=\"14.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">Stop<\/text><rect data-hk=\"000000010000000000004000010b13607a2100\" x=\"651.5\" y=\"369.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a2101\" d=\"M660.8 369.4C772 366.1 873.9 366.7 919.3 367.9M659 368.4C768.2 368.6 852.5 364.8 919.6 366.9M931.3 377.6C929.6 391.6 929.2 408 930.7 414.2M930.1 378.9C928.8 389.7 929.7 407.2 930.1 415.2M919.9 423.7C832.5 423.6 710 421 659.5 423.5M919.9 425.4C799.7 421.9 730.5 424.4 659.6 423M649.7 413.2C650 396.1 651.4 388 650.1 377.5M649.4 413.1C650.6 399.2 648.6 391.3 650.9 378.4M920.8 368.4Q929.7 367.2 930.1 379.5M929.8 413.7Q930.9 425.2 918.9 422.6M660.1 422.8Q649.6 425 650.2 413.2M649.2 376.7Q649 369.2 661 368\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a2110\" x=\"790\" y=\"393\" font-size=\"14.5\" fill=\"#A78BFA\" text-anchor=\"middle\">interrupt<\/text><text data-hk=\"000000010000000000004000010b13607a2120\" x=\"790\" y=\"412\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">cancel_queued: true<\/text><path data-hk=\"000000010000000000004000010b13607a220\" d=\"M388.1 395.7C401.9 396.1 412.1 396 423.4 395.5M387 394.7C403.4 397 415.8 395.6 421 395.3\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b13607a230\" d=\"M596.8 394.6C618.7 394.9 632.3 396.1 641.5 395.2M598.4 397.1C615.5 397 626.2 397.5 642 395\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><rect data-hk=\"000000010000000000004000010b13607a2400\" x=\"101.5\" y=\"453.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a2401\" d=\"M111.5 451.4C226.7 450.4 283.4 454.8 369.4 452.2M109 452.2C234 452.5 279.7 448.8 368.5 452.2M380.8 462.4C379.4 476.1 379.2 486.7 381.3 498.2M379.5 463.3C380.8 475.3 380.4 492.4 379.5 497.1M368.7 507.1C286.9 509 180.7 505.8 109.6 509.3M369.9 508.6C269.2 508.4 153.3 509.8 110.1 507.4M99.2 498.5C100.4 488.1 99.7 470.8 100.3 461.8M100.7 499.5C100.1 487.4 101.2 469 100.2 460.9M369.8 451.9Q379.5 451.2 380.6 461M380.1 499.3Q379 507.8 371.5 508M110.7 508.4Q99.7 508.1 100.9 498.1M99.8 462.9Q99.6 453.2 111.2 453.2\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a2410\" x=\"240\" y=\"477\" font-size=\"14.5\" fill=\"#4ADE80\" text-anchor=\"middle\">exit code + tail<\/text><text data-hk=\"000000010000000000004000010b13607a2420\" x=\"240\" y=\"496\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">final BashOutput<\/text><rect data-hk=\"000000010000000000004000010b13607a250\" x=\"431.5\" y=\"459.5\" width=\"157\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a251\" d=\"M439.9 456.8C492.6 457 548.7 457 580.7 456.7M440.2 458.2C503.3 458.1 543.6 460.4 580.5 459.4M589.4 467.8C590.7 476.4 588.1 485.2 590.6 492.2M590.3 467.6C590.7 476.6 588.3 486.3 589.1 492.4M581.1 501.6C514.7 500.6 480 501 438.9 501.4M579.9 501.8C517.9 504.6 459.8 501.4 440.3 502.9M428.6 491.9C430 480.1 431.2 476.2 431.5 469M431.1 491.3C430.1 482.5 430 476.3 430.9 466.7M581.5 458.2Q589.9 458.7 590.5 469.2M589.6 490.9Q589.3 502.3 579.8 502M440.9 502.9Q430.2 503.4 430.6 492.5M429.1 467.9Q428.7 456.9 439.4 457.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a260\" x=\"510\" y=\"486\" font-size=\"14.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">Result<\/text><rect data-hk=\"000000010000000000004000010b13607a2700\" x=\"651.5\" y=\"453.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a2701\" d=\"M660.2 452.5C764 452.1 863.4 453.7 921.4 451.4M660.2 450.8C770.7 452.7 877.7 453.3 920.3 452M928.9 462.9C929.9 478.2 929.8 485.7 928.8 497.5M930.6 462.3C929.2 478.5 929.8 489.5 929.1 499.2M919.9 508.8C815.6 509.1 724.3 510.1 661.3 508.5M919.2 507.7C827.6 508.4 710.6 508.5 659 508.6M651 497.8C650.3 481 650.7 469.7 649.3 461M650.9 498.2C648.1 485.8 649.7 469.7 651.1 461.2M920.7 452.1Q929 451.7 929.1 461.4M930.5 498.5Q928.7 508.8 920.5 509.3M659.9 509.3Q649.3 509.3 649.3 496.5M649.7 462.9Q650.6 452.6 659.1 450.6\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a2710\" x=\"790\" y=\"477\" font-size=\"14.5\" fill=\"#A78BFA\" text-anchor=\"middle\">tool_result<\/text><text data-hk=\"000000010000000000004000010b13607a2720\" x=\"790\" y=\"496\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">Task result block<\/text><path data-hk=\"000000010000000000004000010b13607a280\" d=\"M389.2 480C404.8 478.9 416.5 481.6 422.5 478.7M389.1 481.2C402.1 482 417.3 479.6 423.2 480.3\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b13607a290\" d=\"M597.3 480.2C614 479.4 634.5 480.4 642.4 479.7M596.9 480.6C617.7 480.1 631.1 479.5 641.4 478.6\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><rect data-hk=\"000000010000000000004000010b13607a3000\" x=\"101.5\" y=\"537.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a3001\" d=\"M109.3 536.5C199.3 534.7 308.2 537.3 369.3 535.8M111.2 535.5C197.2 539.1 312.9 537.1 370.4 535.9M379.9 545.2C379.7 561.1 380.1 570.4 378.6 582.4M380.9 546C382.1 560.3 380.5 571.9 381.2 582.5M370.8 591.7C257.7 589.9 187.4 588.5 108.8 593.2M369.9 591C259.5 590.7 184 593 108.8 591.8M100.3 582.4C100.8 566.4 99.8 553.2 99.6 547.1M101.4 582.3C97.7 568.1 101.8 551.5 101 544.9M370.6 537.2Q380.6 534.6 378.9 544.6M378.8 581.1Q381.3 592.3 369.5 592.1M109.1 591.1Q99.4 591.2 99.8 582.2M98.7 546.4Q99.5 535.3 109.8 536.3\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a3010\" x=\"240\" y=\"561\" font-size=\"14.5\" fill=\"#4ADE80\" text-anchor=\"middle\">\/bashes<\/text><text data-hk=\"000000010000000000004000010b13607a3020\" x=\"240\" y=\"580\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">running shells<\/text><rect data-hk=\"000000010000000000004000010b13607a310\" x=\"431.5\" y=\"543.5\" width=\"157\" height=\"41\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a311\" d=\"M438.5 541.2C483.7 539.2 534.8 542.1 581.4 540.9M440.7 542.8C483.9 541.5 539.1 543.5 580.6 541M589.1 550.6C590.3 563.6 589.5 569.5 590.4 577M589.1 551C590.5 561.7 590 568.1 590 576.5M579.1 587.2C531.8 585 485.1 587.7 440.4 585.8M581.3 587.1C533.3 583.5 487.2 585.7 440.7 584.5M428.6 575.8C431.1 564.2 428 556.6 429.1 553.2M429.7 576.1C430.1 567.9 429.5 558.5 430.5 550.9M579.2 541.4Q590.9 542 590.9 550.9M590.9 574.7Q590.1 587.2 578.9 584.9M439.6 586.1Q429.9 585.2 429.7 576.7M431 551Q428.5 542.4 439.8 542.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a320\" x=\"510\" y=\"570\" font-size=\"14.5\" fill=\"#DBD8CF\" text-anchor=\"middle\">List<\/text><rect data-hk=\"000000010000000000004000010b13607a3300\" x=\"651.5\" y=\"537.5\" width=\"277\" height=\"53\" rx=\"10\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b13607a3301\" d=\"M660.4 534.8C782.6 534.1 856.2 536.6 921.2 537M659.9 536.1C748.6 537.1 857.8 536.3 921.4 536M929.7 546.6C929.9 561 931.3 574.1 930.2 582.8M931.4 545.9C930.6 559.2 930.3 574 930.3 581.5M921 592.7C831.3 590.1 717.6 593.3 660.5 592.6M919.4 592.3C823.4 594.5 708.2 592.2 660.7 591.1M650.8 581.9C650.1 571.3 650 557.9 648.7 546.3M650.2 582.4C649.2 567.7 649.5 554.8 648.6 545.1M920.5 537.2Q929.9 536.6 929.2 545.2M929.9 581.8Q929.1 593.3 918.6 592.7M660.4 591.7Q650.5 590.7 651.4 581.9M651 547.1Q651.4 537.1 660.8 535.1\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b13607a3310\" x=\"790\" y=\"561\" font-size=\"14.5\" fill=\"#A78BFA\" text-anchor=\"middle\">ListAgents<\/text><text data-hk=\"000000010000000000004000010b13607a3320\" x=\"790\" y=\"580\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">running agents<\/text><path data-hk=\"000000010000000000004000010b13607a340\" d=\"M388 564.6C401.9 565.9 415.4 563.6 420.9 564.7M387.1 563.6C400.5 564.2 412.3 563.4 422.2 563.6\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b13607a350\" d=\"M598.2 562.7C614.7 564.1 628.2 564.7 640.5 562.8M597.2 564.7C614.9 563.2 635 564.3 642.8 564.3\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1.2\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><text data-hk=\"000000010000000000004000010b136080\" x=\"952\" y=\"616\" font-size=\"13\" fill=\"#9AA2AD\" text-anchor=\"end\" transform=\"rotate(-0.6 952 616)\">claude&#8217;s map of its own tools<\/text><!--\/--><\/svg><\/figure>\n<p data-hk=\"000000010000000000004000010b13700\">Both converge on the interface of a process: <code data-hk=\"000000010000000000004000010b1370100\">signal<\/code> + <code data-hk=\"000000010000000000004000010b1370200\">stream in<\/code> + <code data-hk=\"000000010000000000004000010b1370300\">stream out<\/code>. A backgrounded<br \/>\nshell, a subagent, a dev-server daemon, a remote function, and an ordinary call that ran past its<br \/>\nbudget are all the same object\u2014a job with stdin, stdout, an exit status, and a signal handle. One<br \/>\nstdio-shaped job primitive should encapsulate all of them. Then the blocking budget is enforced in<br \/>\none place, output spills to one artifact path, and inspecting, messaging, or killing any of them is<br \/>\none surface instead of a per-tool copy.<\/p>\n<p data-hk=\"000000010000000000004000010b13800\">Observability expectations converge the same way. Users who want to see subagent state also want<br \/>\nto see backgrounded shells. Agents that message peers across harness instances also want to see<br \/>\nthe daemons those peers run, so that N agents in one directory share a single HMR <code data-hk=\"000000010000000000004000010b1380100\">bun dev<\/code><br \/>\ninstead of launching N copies on N ports.<\/p>\n<h3 data-hk=\"000000010000000000004000010b13900\" id=\"cancellation-requires-a-kill-boundary\">Cancellation requires a kill boundary<\/h3>\n<p data-hk=\"000000010000000000004000010b14000\">Extensions\u2014and therefore custom tools\u2014sharing the engine&#8217;s JavaScript isolate leads to disaster.<br \/>\nProper hot reload becomes nearly impossible, and a tool call cannot be forcibly stopped once it has<br \/>\nescaped cooperative cancellation.<\/p>\n<p data-hk=\"000000010000000000004000010b14100\">JavaScript and Go expose cancellation through <code data-hk=\"000000010000000000004000010b1410100\">AbortSignal<\/code> and <code data-hk=\"000000010000000000004000010b1410200\">context.Context<\/code>: useful protocols,<br \/>\nbut not enforced ones. Forget to pass the signal, call a dependency that does not accept it, run<br \/>\nsynchronous work, or enter an infinite retry loop, and a timeout only tells the agent to continue;<br \/>\nthe work itself may keep burning resources in the background.<\/p>\n<p data-hk=\"000000010000000000004000010b14200\">A safe host therefore needs an execution unit it can actually terminate\u2014a process, worker,<br \/>\nsubinterpreter, VM request, or equivalent boundary whose death cannot take session authority with<br \/>\nit. Cancellation belongs to the runtime contract, not to every tool author&#8217;s good behavior.<\/p>\n<h3 data-hk=\"000000010000000000004000010b14300\" id=\"make-the-mandatory-boundary-pleasant\">Make the mandatory boundary pleasant<\/h3>\n<p data-hk=\"000000010000000000004000010b14400\">A deliberately dumb sandbox stub creates one final SDK problem: extension authors now see two<br \/>\nfilesystems. A custom edit function might otherwise have to read a file on one side, transfer it in<br \/>\nfull, and write it back on the other.<\/p>\n<p data-hk=\"000000010000000000004000010b14500\">This is why omp\u00b2 chose Python for extensions. Python can inspect its own AST using the standard<br \/>\nlibrary, package the source needed by a function, and submit it to another runtime; a <code data-hk=\"000000010000000000004000010b1450100\">@remote<\/code><br \/>\nattribute can turn a local-looking function into an RPC. It is the same property that makes remote<br \/>\nfunctions feel natural in systems such as Modal&#8217;s Python SDK.<\/p>\n<p data-hk=\"000000010000000000004000010b14600\">Bringing the Python runtime also makes <code data-hk=\"000000010000000000004000010b1460100\">Eval<\/code> dependable rather than contingent on whichever<br \/>\ninterpreter happens to be installed. Two birds with one stone.<\/p>\n<p data-hk=\"000000010000000000004000010b14700\">Once work has a trusted owner and a cancellable execution primitive, the harness still needs a<br \/>\ncoherent way to control values and multi-turn behavior. That is the control plane.<\/p>\n<h2 data-hk=\"000000010000000000004000010b14800\" id=\"the-control-plane\">The control plane<\/h2>\n<p data-hk=\"000000010000000000004000010b14900\">The runtime owns two different kinds of control. <strong data-hk=\"000000010000000000004000010b1490100\">Values<\/strong> answer which model, tier, theme, or<br \/>\npolicy is active. <strong data-hk=\"000000010000000000004000010b1490200\">Behaviors<\/strong> answer whether the agent may yield, must take another turn, or<br \/>\ntemporarily needs a capability. Both become incoherent when every caller owns a private setter or<br \/>\nflag.<\/p>\n<h3 data-hk=\"000000010000000000004000010b15000\" id=\"values-declare-policy-with-the-setting\">Values: declare policy with the setting<\/h3>\n<aside data-hk=\"000000010000000000004000010b1510\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Scope, persistence, inheritance, and replication belong in each setting&#8217;s declaration\u2014not in setter call sites.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b15110\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b15200\">The configuration system also became a minefield, with dirty tracking and several levels of<br \/>\nconfiguration (global, session-level, ephemeral&#8230;). Most get\/set operations were routed through<br \/>\nthe <code data-hk=\"000000010000000000004000010b1520100\">AgentSession<\/code> type, as they were in Pi, because changes have to be persisted to the JSONL.<\/p>\n<p data-hk=\"000000010000000000004000010b15300\">Do you know what configuration system solved all of these problems years ago? Yes, Source Engine!<\/p>\n<p data-hk=\"000000010000000000004000010b15400\">What&#8217;s especially remarkable is that most people who have touched a Valve game know what <code data-hk=\"000000010000000000004000010b1540100\">sv_cheats<\/code><br \/>\ndoes off the top of their head. Despite all these years of people customizing their setup, I can&#8217;t<br \/>\nrecall a single unhappy user. Can you remember any other configuration of any other software?<\/p>\n<p data-hk=\"000000010000000000004000010b15500\">A <a data-hk=\"000000010000000000004000010b1550100\" href=\"https:\/\/developer.valvesoftware.com\/wiki\/ConVar\">convar<\/a> is a typed variable with a name, a<br \/>\ndefault, a help string, and a bitfield of <strong data-hk=\"000000010000000000004000010b1550200\">flags<\/strong>, declared once, at the definition site:<\/p>\n<pre data-hk=\"000000010000000000004000010b15600\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1560100\"><span data-hk=\"000000010000000000004000010b156010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b15601010100\" style=\"color:#C9A4FF\">ConVar<\/span><span data-hk=\"000000010000000000004000010b15601010200\" style=\"color:#44CFFF\"> sv_gravity<\/span><span data-hk=\"000000010000000000004000010b15601010300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b15601010400\" style=\"color:#B99AFF\">\"sv_gravity\"<\/span><span data-hk=\"000000010000000000004000010b15601010500\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b15601010600\" style=\"color:#B99AFF\">\"800\"<\/span><span data-hk=\"000000010000000000004000010b15601010700\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b15601010800\" style=\"color:#C9A4FF\">FCVAR_REPLICATED<\/span><span data-hk=\"000000010000000000004000010b15601010900\" style=\"color:#CFD4DC\"> | <\/span><span data-hk=\"000000010000000000004000010b15601010a1000\" style=\"color:#9BE8FF;fontStyle:italic\">FCVAR_NOTIFY<\/span><span data-hk=\"000000010000000000004000010b15601010a1100\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b15601010a1200\" style=\"color:#B99AFF\">\"World gravity.\"<\/span><span data-hk=\"000000010000000000004000010b15601010a1300\" style=\"color:#CFD4DC\">);<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b15700\">Persistence, ownership, scope, replication, even replay-honesty: all <strong data-hk=\"000000010000000000004000010b1570100\">properties of the variable<\/strong>,<br \/>\nstated where it is born. Nobody routes a <code data-hk=\"000000010000000000004000010b1570200\">set<\/code> through a god object, nobody hand-rolls dirty<br \/>\ntracking.<\/p>\n<figure data-hk=\"000000010000000000004000010b158\"><!--$--><svg data-hk=\"000000010000000000004000010b15900\" class=\"st-sketch\" viewbox=\"0 0 1000 610\" role=\"img\" aria-label=\"Convar model: the server owns sv_cheats, sv_gravity, mp_friendlyfire, and a protected sv_password; REPLICATED forces server values onto every read-only client copy, USERINFO sends the client-owned name upward, ARCHIVE persists cl_interp to config.cfg, CHEAT locks r_drawothermodels unless sv_cheats is 1, and every change is stamped into the .dem so replay stays honest\" font-family=\"var(--st-font-sketch)\"><defs><pattern id=\"cv-dots\" width=\"22\" height=\"22\" patternunits=\"userSpaceOnUse\"><circle cx=\"11\" cy=\"11\" r=\"1.1\" fill=\"#2E333C\"\/><\/pattern><\/defs><rect width=\"1000\" height=\"610\" fill=\"#121419\"\/><rect width=\"1000\" height=\"610\" fill=\"url(#cv-dots)\"\/><!--$--><text data-hk=\"000000010000000000004000010b1590100\" x=\"500\" y=\"48\" font-size=\"26\" fill=\"#DBD8CF\" text-anchor=\"middle\" letter-spacing=\"2\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">FLAGS, NOT PLUMBING<\/text><path data-hk=\"000000010000000000004000010b1590110\" d=\"M298.6 61.4C472.2 60.1 563.9 63.3 701.2 58.7M300.6 59.3C431.2 59.1 623.3 62.4 700.6 60.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b159020\" x=\"500\" y=\"88\" font-size=\"13.5\" fill=\"#9AA2AD\" text-anchor=\"middle\">ConVar(&#8220;sv_gravity&#8221;, &#8220;800&#8221;, <tspan data-hk=\"000000010000000000004000010b159021\" fill=\"#44CFFF\">REPLICATED<\/tspan> | <tspan data-hk=\"000000010000000000004000010b159022\" fill=\"#F5B04A\">NOTIFY<\/tspan>, &#8220;World gravity.&#8221;)<\/text><rect data-hk=\"000000010000000000004000010b159030\" x=\"49.5\" y=\"113.5\" width=\"369\" height=\"281\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b159031\" d=\"M48 112.9C205.4 109.6 304.8 108.5 422.6 110.8M46.6 111.7C169.4 112.6 326.8 113.9 422.3 111.1M421.1 110.3C418.9 233 421.4 330.8 421.5 395.7M420.2 111.7C418.7 232.1 422.5 333.7 420.8 397.7M421.4 394.7C281.3 393.4 158.8 395.7 47.6 396M421.3 397.1C283.5 391.7 173.2 396.9 47.5 395.4M47.3 398.4C45.5 261.9 45.7 165.6 47 111M47.2 398.5C47.2 272.3 46.2 162.1 47.6 111.3\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-dasharray=\"7 5\"\/><text data-hk=\"000000010000000000004000010b159040\" x=\"68\" y=\"144\" font-size=\"17\" fill=\"#DBD8CF\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">SERVER<\/text><text data-hk=\"000000010000000000004000010b159050\" x=\"158\" y=\"144\" font-size=\"15\" fill=\"#4ADE80\">(one authority)<\/text><path data-hk=\"000000010000000000004000010b159060\" d=\"M265.1 134.2Q273.7 143.7 282.5 132.4L291.3 121.1M265.1 135.4Q273.2 142.9 283.2 132.6L293.1 122.2\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"2.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b159070\" x=\"68\" y=\"186\" font-size=\"14.5\" fill=\"#DBD8CF\">sv_cheats <tspan data-hk=\"000000010000000000004000010b159071\" fill=\"#9AA2AD\">0<\/tspan><\/text><text data-hk=\"000000010000000000004000010b159080\" x=\"68\" y=\"226\" font-size=\"14.5\" fill=\"#DBD8CF\">sv_gravity <tspan data-hk=\"000000010000000000004000010b159081\" fill=\"#9AA2AD\">800<\/tspan><\/text><text data-hk=\"000000010000000000004000010b159090\" x=\"68\" y=\"266\" font-size=\"14.5\" fill=\"#DBD8CF\">mp_friendlyfire <tspan data-hk=\"000000010000000000004000010b159091\" fill=\"#9AA2AD\">0<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a100\" x=\"68\" y=\"306\" font-size=\"14.5\" fill=\"#DBD8CF\">sv_password <tspan data-hk=\"000000010000000000004000010b1590a101\" fill=\"#9AA2AD\">\u2022\u2022\u2022<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a110\" x=\"400\" y=\"186\" font-size=\"13\" fill=\"#DBD8CF\" text-anchor=\"end\"><tspan data-hk=\"000000010000000000004000010b1590a111\" fill=\"#44CFFF\">REPLICATED<\/tspan> <tspan data-hk=\"000000010000000000004000010b1590a112\" fill=\"#F5B04A\">NOTIFY<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a120\" x=\"400\" y=\"226\" font-size=\"13\" fill=\"#DBD8CF\" text-anchor=\"end\"><tspan data-hk=\"000000010000000000004000010b1590a121\" fill=\"#44CFFF\">REPLICATED<\/tspan> <tspan data-hk=\"000000010000000000004000010b1590a122\" fill=\"#F5B04A\">NOTIFY<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a130\" x=\"400\" y=\"266\" font-size=\"13\" fill=\"#44CFFF\" text-anchor=\"end\">REPLICATED<\/text><text data-hk=\"000000010000000000004000010b1590a140\" x=\"400\" y=\"306\" font-size=\"13\" fill=\"#9AA2AD\" text-anchor=\"end\">PROTECTED<\/text><rect data-hk=\"000000010000000000004000010b1590a150\" x=\"581.5\" y=\"113.5\" width=\"369\" height=\"281\" rx=\"18\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b1590a151\" d=\"M599.1 112C719.4 115.7 839.5 112.7 934.7 112.6M596.7 113.1C724.8 111.1 872.5 113.8 934.5 111.4M953 128.9C955 242.2 952.6 314.5 952.2 378.3M951.1 130.9C949.3 224.4 952.7 322.4 950.9 378.9M933.1 395.1C806.9 397.4 673.8 398.2 598 396.7M934.6 394.8C811.5 397.1 684 394.3 599.2 396.2M581.4 379C578 261.1 583.9 171.3 580 130.9M579.7 378.9C580.6 297 577.5 187.7 580.5 129.9M933.8 112.6Q950.8 110.6 950.8 131.4M951.9 377.8Q952.5 395.5 933.3 395.8M597.7 395.8Q579.8 395.6 581 376.8M581.4 129.4Q579.7 111.7 599.3 112.8\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1590a160\" x=\"600\" y=\"144\" font-size=\"17\" fill=\"#F4644A\" stroke=\"#F4644A\" stroke-width=\"0.8\">CLIENT<\/text><text data-hk=\"000000010000000000004000010b1590a170\" x=\"688\" y=\"144\" font-size=\"15\" fill=\"#F4644A\">(every player)<\/text><text data-hk=\"000000010000000000004000010b1590a180\" x=\"600\" y=\"186\" font-size=\"14.5\" fill=\"#44CFFF\">sv_cheats <tspan data-hk=\"000000010000000000004000010b1590a181\" fill=\"#9AA2AD\">0<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a190\" x=\"600\" y=\"226\" font-size=\"14.5\" fill=\"#44CFFF\">sv_gravity <tspan data-hk=\"000000010000000000004000010b1590a191\" fill=\"#9AA2AD\">800<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a200\" x=\"600\" y=\"266\" font-size=\"14.5\" fill=\"#DBD8CF\">cl_interp <tspan data-hk=\"000000010000000000004000010b1590a201\" fill=\"#9AA2AD\">0.031<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a210\" x=\"600\" y=\"306\" font-size=\"14.5\" fill=\"#DBD8CF\">r_drawothermodels <tspan data-hk=\"000000010000000000004000010b1590a211\" fill=\"#9AA2AD\">1<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a220\" x=\"600\" y=\"346\" font-size=\"14.5\" fill=\"#DBD8CF\">name <tspan data-hk=\"000000010000000000004000010b1590a221\" fill=\"#9AA2AD\">&#8220;can&#8221;<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a230\" x=\"932\" y=\"186\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"end\">read-only<\/text><text data-hk=\"000000010000000000004000010b1590a240\" x=\"932\" y=\"226\" font-size=\"12.5\" fill=\"#9AA2AD\" text-anchor=\"end\">read-only<\/text><text data-hk=\"000000010000000000004000010b1590a250\" x=\"932\" y=\"266\" font-size=\"13\" fill=\"#A78BFA\" text-anchor=\"end\">ARCHIVE<\/text><text data-hk=\"000000010000000000004000010b1590a260\" x=\"932\" y=\"306\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"end\">CHEAT<\/text><text data-hk=\"000000010000000000004000010b1590a270\" x=\"932\" y=\"346\" font-size=\"13\" fill=\"#4ADE80\" text-anchor=\"end\">USERINFO<\/text><text data-hk=\"000000010000000000004000010b1590a280\" x=\"600\" y=\"322\" font-size=\"12\" fill=\"#F4644A\" transform=\"rotate(-1 600 322)\">locked unless sv_cheats = 1<\/text><path data-hk=\"000000010000000000004000010b1590a290\" d=\"M425.3 180C496.7 180.3 544.4 182.7 574.8 181.2M423.8 181.9C482.7 180.1 524.7 181.7 576 180.5M575.9 180.2C571.1 181.8 569.2 183.5 566 184.8M575.9 180.1C572.8 181.6 567.5 183.7 565.7 184.5M575.7 179.8C571.8 178.5 568.2 176.8 565.7 175.4M576.1 179.9C572.3 178.1 567.9 176.1 565.7 175.7\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b1590a300\" d=\"M422.9 218.9C489.7 218.5 543.6 219.1 574.3 221.3M424.6 220.3C476.8 220.3 533.3 222.3 576 219.3M575.9 220.1C572.5 221.4 568.6 222.9 566.2 224.7M575.7 219.9C571.9 222.2 569 223.3 565.7 224.1M575.8 219.8C572 218.7 568.5 216.5 566.2 215.5M576.3 220C571.5 217.7 568.5 216.4 565.8 215.8\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1590a310\" x=\"500\" y=\"198\" font-size=\"13\" fill=\"#44CFFF\" text-anchor=\"middle\" stroke=\"#44CFFF\" stroke-width=\"0.8\" transform=\"rotate(-1 500 198)\">REPLICATED<\/text><text data-hk=\"000000010000000000004000010b1590a320\" x=\"500\" y=\"212\" font-size=\"12\" fill=\"#9AA2AD\" text-anchor=\"middle\">forced onto every client<\/text><path data-hk=\"000000010000000000004000010b1590a330\" d=\"M576.2 339.6C500.3 339.1 463.3 341.4 422.2 341.3M575.1 340.5C506.4 339.2 463.6 341.3 426 341M423.8 339.8C428.5 338.2 431.1 337.2 433.9 335.2M423.7 339.9C428.6 337.9 431.9 337 433.8 335.8M424.3 340C427.9 341.7 431.4 343.2 433.8 344.5M423.8 340.2C427.9 341.8 431.3 343.5 434.3 344.4\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1590a340\" x=\"500\" y=\"328\" font-size=\"12.5\" fill=\"#4ADE80\" text-anchor=\"middle\">USERINFO \u00b7 sent up<\/text><path data-hk=\"000000010000000000004000010b1590a350\" d=\"M956.9 179.7Q986.5 222.4 985.7 241.4Q984.9 260.4 972.4 278.9L959.9 297.4M958.6 178.8Q985.8 221.9 986.1 240.8Q986.5 259.6 973.6 278.2L960.7 296.7M959.7 298.3C960.8 293.8 961.4 290.6 962.2 287.4M960.1 298.3C960.9 293.8 961.5 289.9 962 287.2M960.1 297.8C964.1 295.5 966.4 294.5 969.2 291.9M960.1 298.2C962.9 296.1 966.4 294.2 969.5 292.4\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b1590a360\" d=\"M234.7 394C232.6 411.1 235 430.5 235.7 439.9M234.7 395.6C235.8 417.6 235.1 426.4 233.7 437.6M233.9 438.1C232.1 433.7 230.9 430.9 229.6 427.8M234.2 438.1C232.3 435 231 431.2 229.7 427.6M234.1 438.1C236.2 433 237.7 429.5 238.5 427.7M234.3 438.1C236.2 433.4 237.9 429.3 238.8 427.6\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010b1590a370\" x=\"175.5\" y=\"443.5\" width=\"117\" height=\"41\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b1590a371\" d=\"M172.9 443.3C231.4 441.9 266.6 442.4 294.9 441.7M172.7 441.5C220.6 444.3 261.9 441.4 293.1 440.6M294.9 440.7C294.3 454.6 294.2 474.1 293.9 487.7M293.7 441.1C296.1 461 292.7 471.2 294 487.7M293.4 485.7C235.7 487.8 210 486.6 173.3 486.7M294 486.3C256.3 486.1 206.3 485.2 172.7 486.1M174 484.8C174.1 468.6 173.4 453.7 173.3 443.3M174.1 486.5C174.8 469.2 174.6 448.4 172.9 441.5\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1590a380\" x=\"234\" y=\"470\" font-size=\"14\" fill=\"#A78BFA\" text-anchor=\"middle\" stroke=\"#A78BFA\" stroke-width=\"0.8\">.dem<\/text><text data-hk=\"000000010000000000004000010b1590a390\" x=\"252\" y=\"414\" font-size=\"12.5\" fill=\"#9AA2AD\" transform=\"rotate(-0.5 252 414)\">every change stamped into the demo,<\/text><text data-hk=\"000000010000000000004000010b1590a400\" x=\"252\" y=\"429\" font-size=\"12.5\" fill=\"#9AA2AD\" transform=\"rotate(-0.5 252 429)\">replay stays honest<\/text><path data-hk=\"000000010000000000004000010b1590a410\" d=\"M766.4 396.4C767.2 411 765.9 432.1 765.1 438.5M765.9 396.9C767.7 410.3 767.4 431.5 766.2 437.9M766.2 438C764.4 434.1 762.6 430.6 761.5 427.7M765.9 438.1C764.8 434.6 762.7 430.9 761.3 427.9M765.8 437.9C767.4 434.9 769.3 430.5 770.4 428.1M766 438.3C767.2 434.8 768.9 431.3 770.4 428.3\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010b1590a420\" x=\"697.5\" y=\"443.5\" width=\"137\" height=\"41\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b1590a421\" d=\"M693.8 442.6C759.2 442 809.3 443.7 838.5 441.2M694.1 441.8C738.7 442.9 790.3 442.4 838.6 441.8M835.5 441.5C837 463 834.6 480.1 836.2 486.8M837.4 439.5C836.1 454.5 836.6 479.3 836.3 486.4M836.7 485.9C774.1 484.3 740.2 484.7 696.4 487.2M837.4 485.8C770.2 486.7 729.3 489.2 694.7 485.8M694.9 487.4C695.3 469.2 696.8 451.8 696 442.8M696.8 486.5C694.7 465.9 698 453.2 696.4 441.9\" fill=\"none\" stroke=\"#A78BFA\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1590a430\" x=\"766\" y=\"470\" font-size=\"14\" fill=\"#A78BFA\" text-anchor=\"middle\" stroke=\"#A78BFA\" stroke-width=\"0.8\">config.cfg<\/text><text data-hk=\"000000010000000000004000010b1590a440\" x=\"784\" y=\"414\" font-size=\"12.5\" fill=\"#9AA2AD\" transform=\"rotate(-0.5 784 414)\">ARCHIVE vars written to disk,<\/text><text data-hk=\"000000010000000000004000010b1590a450\" x=\"784\" y=\"429\" font-size=\"12.5\" fill=\"#9AA2AD\" transform=\"rotate(-0.5 784 429)\">everything else is ephemeral<\/text><text data-hk=\"000000010000000000004000010b1590a460\" x=\"500\" y=\"520\" font-size=\"13\" fill=\"#9AA2AD\" text-anchor=\"middle\"><tspan data-hk=\"000000010000000000004000010b1590a461\" fill=\"#F5B04A\">NOTIFY<\/tspan> = change announced to every player<!--!$-->\u00a0\u00a0\u00a0\u00a0\u00a0<!--!$-->PROTECTED = value never leaves the server<\/text><path data-hk=\"000000010000000000004000010b1590a470\" d=\"M47.1 539.5C346.6 538.5 813.4 542.6 953.2 541M48.8 540.5C471.2 538.9 805.4 542.3 951.2 540.2\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b1590a480\" x=\"500\" y=\"572\" font-size=\"15.5\" fill=\"#DBD8CF\" text-anchor=\"middle\"><tspan data-hk=\"000000010000000000004000010b1590a481\" fill=\"#F4644A\">set() through a god object + dirty tracking<\/tspan>\u00a0\u00a0-&gt;\u00a0\u00a0<tspan data-hk=\"000000010000000000004000010b1590a482\" fill=\"#4ADE80\">flags where the variable is born<\/tspan><\/text><text data-hk=\"000000010000000000004000010b1590a490\" x=\"952\" y=\"600\" font-size=\"13\" fill=\"#9AA2AD\" text-anchor=\"end\" transform=\"rotate(-1 952 600)\">one store. flags decide the rest.<\/text><!--\/--><\/svg><!--\/--><figcaption>One authoritative server store, mirrored to every client. REPLICATED pushes values down, USERINFO sends client-owned vars up, CHEAT locks vars behind <!--$--><code data-hk=\"000000010000000000004000010b16000\">sv_cheats<\/code><!--\/-->, ARCHIVE decides what reaches <!--$--><code data-hk=\"000000010000000000004000010b16100\">config.cfg<\/code><!--\/--> \u2014 and every change is stamped into the <!--$--><code data-hk=\"000000010000000000004000010b16200\">.dem<\/code><!--\/-->.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b16300\">A convar is not a second settings database beside the session DOM. A session-scoped convar is one<br \/>\nmore journaled node in the authoritative tree; its flags declare how it participates in resume,<br \/>\nrewind, spawn, replication, and archival.<\/p>\n<h3 data-hk=\"000000010000000000004000010b16400\" id=\"inheritance-should-not-require-a-second-setting\">Inheritance should not require a second setting<\/h3>\n<p data-hk=\"000000010000000000004000010b16500\">Today in omp, service tier (i.e. <code data-hk=\"000000010000000000004000010b1650100\">\/fast<\/code>) has a separate setting just for the subagent.<\/p>\n<pre data-hk=\"000000010000000000004000010b16600\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1660100\"><span data-hk=\"000000010000000000004000010b166010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b16601010100\" style=\"color:#FF54C0\">tier<\/span><span data-hk=\"000000010000000000004000010b16601010200\" style=\"color:#CFD4DC\">:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b166010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b16601020100\" style=\"color:#FF54C0\">  openai<\/span><span data-hk=\"000000010000000000004000010b16601020200\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b16601020300\" style=\"color:#B99AFF\">priority<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b166010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b16601030100\" style=\"color:#FF54C0\">  subagent<\/span><span data-hk=\"000000010000000000004000010b16601030200\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b16601030300\" style=\"color:#B99AFF\">inherit<\/span><span data-hk=\"000000010000000000004000010b16601030400\" style=\"color:#CFD4DC8F;fontStyle:italic\">   # separate setting<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b16700\">In convar land, <code data-hk=\"000000010000000000004000010b1670100\">ai_fastmode<\/code> is <em data-hk=\"000000010000000000004000010b1670200\">one<\/em> variable, flagged <code data-hk=\"000000010000000000004000010b1670300\">SESSION<\/code>: journaled with the session, so<br \/>\nresuming restores the value. Inheritance needs no flag at all: a spawned child seeds <em data-hk=\"000000010000000000004000010b1670400\">every<\/em><br \/>\nvariable from the parent&#8217;s live values, by default. There is nothing to opt into.<\/p>\n<p data-hk=\"000000010000000000004000010b16800\">Want children pinned instead? One line:<\/p>\n<pre data-hk=\"000000010000000000004000010b16900\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1690100\"><span data-hk=\"000000010000000000004000010b169010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b16901010100\" style=\"color:#CFD4DC8F;fontStyle:italic\"># subagent.cfg \u2014 auto-exec'd for every spawn<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b169010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b16901020100\" style=\"color:#44CFFF\">ai_fastmode<\/span><span data-hk=\"000000010000000000004000010b16901020200\" style=\"color:#B99AFF\"> 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b169010300\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b169010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b16901040100\" style=\"color:#CFD4DC8F;fontStyle:italic\"># sonic.cfg \u2014 auto-exec'd when a sonic spawns, class config<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b169010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b16901050100\" style=\"color:#44CFFF\">ai_model<\/span><span data-hk=\"000000010000000000004000010b16901050200\" style=\"color:#B99AFF\"> @smol<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b169010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b16901060100\" style=\"color:#44CFFF\">ai_thinking<\/span><span data-hk=\"000000010000000000004000010b16901060200\" style=\"color:#B99AFF\"> low<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b17000\"><code data-hk=\"000000010000000000004000010b1700100\">config.cfg<\/code> for the main session, any number of user cfgs as profiles, <code data-hk=\"000000010000000000004000010b1700200\">subagent.cfg<\/code> auto-exec&#8217;d<br \/>\non every spawn, <code data-hk=\"000000010000000000004000010b1700300\">&lt;agent&gt;.cfg<\/code> layered on top, also solving the god object with a thousand<br \/>\nproperties. TF2 knew the way to go!<\/p>\n<p data-hk=\"000000010000000000004000010b17100\">One value now describes the main session and its children. The inheritance rule lives where the<br \/>\nvalue is defined instead of becoming another property on a growing session god object.<\/p>\n<h3 data-hk=\"000000010000000000004000010b17200\" id=\"profiles-and-keybindings-stay-in-band\">Profiles and keybindings stay in-band<\/h3>\n<p data-hk=\"000000010000000000004000010b17300\">And once cfgs exist, binds make it even better \u2014 <code data-hk=\"000000010000000000004000010b1730100\">bind<\/code>, <code data-hk=\"000000010000000000004000010b1730200\">toggle<\/code>, and <code data-hk=\"000000010000000000004000010b1730300\">alias<\/code> are console commands<br \/>\ntoo, so every input pattern we keep inventing schemas for stays in-band. User wants a keybind to<br \/>\nhide thinking?<\/p>\n<pre data-hk=\"000000010000000000004000010b17400\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1740100\"><span data-hk=\"000000010000000000004000010b174010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b17401010100\" style=\"color:#44CFFF\">bind<\/span><span data-hk=\"000000010000000000004000010b17401010200\" style=\"color:#B99AFF\"> ctrl+t<\/span><span data-hk=\"000000010000000000004000010b17401010300\" style=\"color:#B99AFF\"> \"cl_showthinking 0\"<\/span><span data-hk=\"000000010000000000004000010b17401010400\" style=\"color:#CFD4DC8F;fontStyle:italic\">        # careful \u2014 one-way; the second press still writes 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b174010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b17401020100\" style=\"color:#44CFFF\">bind<\/span><span data-hk=\"000000010000000000004000010b17401020200\" style=\"color:#B99AFF\"> ctrl+t<\/span><span data-hk=\"000000010000000000004000010b17401020300\" style=\"color:#B99AFF\"> \"toggle cl_showthinking\"<\/span><span data-hk=\"000000010000000000004000010b17401020400\" style=\"color:#CFD4DC8F;fontStyle:italic\">   # there we go; toggle also cycles value lists<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b174010300\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b174010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b17401040100\" style=\"color:#CFD4DC\">alias <\/span><span data-hk=\"000000010000000000004000010b17401040200\" style=\"color:#B99AFF\">+thinkhud<\/span><span data-hk=\"000000010000000000004000010b17401040300\" style=\"color:#B99AFF\"> \"cl_showthinking 1\"<\/span><span data-hk=\"000000010000000000004000010b17401040400\" style=\"color:#CFD4DC8F;fontStyle:italic\">         # fires on key-down...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b174010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b17401050100\" style=\"color:#CFD4DC\">alias <\/span><span data-hk=\"000000010000000000004000010b17401050200\" style=\"color:#B99AFF\">-thinkhud<\/span><span data-hk=\"000000010000000000004000010b17401050300\" style=\"color:#B99AFF\"> \"cl_showthinking 0\"<\/span><span data-hk=\"000000010000000000004000010b17401050400\" style=\"color:#CFD4DC8F;fontStyle:italic\">         # ...and on key-up<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b174010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b17401060100\" style=\"color:#44CFFF\">bind<\/span><span data-hk=\"000000010000000000004000010b17401060200\" style=\"color:#B99AFF\"> ctrl+h<\/span><span data-hk=\"000000010000000000004000010b17401060300\" style=\"color:#B99AFF\"> +thinkhud<\/span><span data-hk=\"000000010000000000004000010b17401060400\" style=\"color:#CFD4DC8F;fontStyle:italic\">                       # hold to peek at the thinking stream<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b17500\">That&#8217;s what our keybinding layer should be: not a bespoke schema with its own defaults table!<\/p>\n<p data-hk=\"000000010000000000004000010b17600\">The command stream is the connective tissue: cfg files, console input, aliases, binds, remote<br \/>\nadministration, and journal replay all speak the same language over the same declared variables.<br \/>\nCustomization stops multiplying one-off schemas.<\/p>\n<h3 data-hk=\"000000010000000000004000010b17700\" id=\"behaviors-the-loop-shaped-hole\">Behaviors: the loop-shaped hole<\/h3>\n<aside data-hk=\"000000010000000000004000010b1780\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Anything that can keep control across turns belongs in one composable, agent-owned Director primitive.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b17810\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b17900\">Another topic of concern is extensibility. Now I&#8217;d argue Pi actually has a great extension layer,<br \/>\nbut it does have a &#8220;loop&#8221; shaped hole.<\/p>\n<p data-hk=\"000000010000000000004000010b18000\">Now I went ahead and installed the most popular Plan and Goal implementations in Pi. Trying to<br \/>\nactivate both gives you:<\/p>\n<figure data-hk=\"000000010000000000004000010b181\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/plan-goal-mutex.png\" width=\"776\" height=\"130\" alt=\"Pi status line showing: Warning: Another workflow is active in this session. End it before starting Plan mode.\" loading=\"lazy\"\/><\/figure>\n<p data-hk=\"000000010000000000004000010b18200\">Okay! That&#8217;s interesting, but there&#8217;s no &#8220;workflow&#8221; API. How would that work? The implementations<br \/>\ndefine their own:<\/p>\n<pre data-hk=\"000000010000000000004000010b18300\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1830100\"><span data-hk=\"000000010000000000004000010b183010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b18301010100\" style=\"color:#FF54C0\">export<\/span><span data-hk=\"000000010000000000004000010b18301010200\" style=\"color:#FF54C0\"> const<\/span><span data-hk=\"000000010000000000004000010b18301010300\" style=\"color:#C9A4FF\"> WORKFLOW_MUTEX_CHANNEL<\/span><span data-hk=\"000000010000000000004000010b18301010400\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b18301010500\" style=\"color:#B99AFF\">\"workflow:mutex:v1\"<\/span><span data-hk=\"000000010000000000004000010b18301010600\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b18301020100\" style=\"color:#FF54C0\">export<\/span><span data-hk=\"000000010000000000004000010b18301020200\" style=\"color:#FF54C0\"> const<\/span><span data-hk=\"000000010000000000004000010b18301020300\" style=\"color:#C9A4FF\"> AGENT_WORKFLOW_GROUP<\/span><span data-hk=\"000000010000000000004000010b18301020400\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b18301020500\" style=\"color:#B99AFF\">\"agent-workflow\"<\/span><span data-hk=\"000000010000000000004000010b18301020600\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010300\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b183010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b18301040100\" style=\"color:#FF54C0\">export<\/span><span data-hk=\"000000010000000000004000010b18301040200\" style=\"color:#FF54C0\"> class<\/span><span data-hk=\"000000010000000000004000010b18301040300\" style=\"color:#C9A4FF\"> WorkflowMutex<\/span><span data-hk=\"000000010000000000004000010b18301040400\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b18301050100\" style=\"color:#FF54C0\">  private<\/span><span data-hk=\"000000010000000000004000010b18301050200\" style=\"color:#9BE8FF\"> session<\/span><span data-hk=\"000000010000000000004000010b18301050300\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b18301050400\" style=\"color:#C9A4FF\">object<\/span><span data-hk=\"000000010000000000004000010b18301050500\" style=\"color:#CFD4DC\"> | <\/span><span data-hk=\"000000010000000000004000010b18301050600\" style=\"color:#C9A4FF\">undefined<\/span><span data-hk=\"000000010000000000004000010b18301050700\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b18301060100\" style=\"color:#FF54C0\">  private<\/span><span data-hk=\"000000010000000000004000010b18301060200\" style=\"color:#FF54C0\"> readonly<\/span><span data-hk=\"000000010000000000004000010b18301060300\" style=\"color:#9BE8FF\"> heldGroups<\/span><span data-hk=\"000000010000000000004000010b18301060400\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b18301060500\" style=\"color:#FF54C0\">new<\/span><span data-hk=\"000000010000000000004000010b18301060600\" style=\"color:#44CFFF\"> Map<\/span><span data-hk=\"000000010000000000004000010b18301060700\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b18301060800\" style=\"color:#C9A4FF\">string<\/span><span data-hk=\"000000010000000000004000010b18301060900\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b18301060a1000\" style=\"color:#C9A4FF\">WorkflowMutexOwner<\/span><span data-hk=\"000000010000000000004000010b18301060a1100\" style=\"color:#CFD4DC\">&gt;();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b18301070100\" style=\"color:#FF54C0\">  private<\/span><span data-hk=\"000000010000000000004000010b18301070200\" style=\"color:#9BE8FF\"> generation<\/span><span data-hk=\"000000010000000000004000010b18301070300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b18301070400\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b18301070500\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b18301080100\" style=\"color:#FF54C0\">  private<\/span><span data-hk=\"000000010000000000004000010b18301080200\" style=\"color:#FF54C0\"> readonly<\/span><span data-hk=\"000000010000000000004000010b18301080300\" style=\"color:#9BE8FF\"> pi<\/span><span data-hk=\"000000010000000000004000010b18301080400\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b18301080500\" style=\"color:#C9A4FF\">Pick<\/span><span data-hk=\"000000010000000000004000010b18301080600\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b18301080700\" style=\"color:#C9A4FF\">ExtensionAPI<\/span><span data-hk=\"000000010000000000004000010b18301080800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b18301080900\" style=\"color:#B99AFF\">\"events\"<\/span><span data-hk=\"000000010000000000004000010b18301080a1000\" style=\"color:#CFD4DC\">&gt;;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010900\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b183010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b183010a100100\" style=\"color:#FF54C0\">  constructor<\/span><span data-hk=\"000000010000000000004000010b183010a100200\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b183010a100300\" style=\"color:#9BE8FF;fontStyle:italic\">pi<\/span><span data-hk=\"000000010000000000004000010b183010a100400\" style=\"color:#CFD4DC\">: <\/span><span data-hk=\"000000010000000000004000010b183010a100500\" style=\"color:#C9A4FF\">Pick<\/span><span data-hk=\"000000010000000000004000010b183010a100600\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b183010a100700\" style=\"color:#C9A4FF\">ExtensionAPI<\/span><span data-hk=\"000000010000000000004000010b183010a100800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b183010a100900\" style=\"color:#B99AFF\">\"events\"<\/span><span data-hk=\"000000010000000000004000010b183010a100a1000\" style=\"color:#CFD4DC\">&gt;) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b183010a110100\" style=\"color:#C9A4FF\">    this<\/span><span data-hk=\"000000010000000000004000010b183010a110200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b183010a110300\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b183010a110400\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b183010a110500\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b183010a110600\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010b183010a120100\" style=\"color:#9BE8FF\">    pi<\/span><span data-hk=\"000000010000000000004000010b183010a120200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b183010a120300\" style=\"color:#9BE8FF\">events<\/span><span data-hk=\"000000010000000000004000010b183010a120400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b183010a120500\" style=\"color:#44CFFF\">on<\/span><span data-hk=\"000000010000000000004000010b183010a120600\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b183010a120700\" style=\"color:#C9A4FF\">WORKFLOW_MUTEX_CHANNEL<\/span><span data-hk=\"000000010000000000004000010b183010a120800\" style=\"color:#CFD4DC\">, (<\/span><span data-hk=\"000000010000000000004000010b183010a120900\" style=\"color:#9BE8FF;fontStyle:italic\">payload<\/span><span data-hk=\"000000010000000000004000010b183010a120a1000\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b183010a120a1100\" style=\"color:#FF54C0\">=&gt;<\/span><span data-hk=\"000000010000000000004000010b183010a120a1200\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010b183010a130100\" style=\"color:#C9A4FF\">      this<\/span><span data-hk=\"000000010000000000004000010b183010a130200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b183010a130300\" style=\"color:#44CFFF\">answer<\/span><span data-hk=\"000000010000000000004000010b183010a130400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b183010a130500\" style=\"color:#9BE8FF\">payload<\/span><span data-hk=\"000000010000000000004000010b183010a130600\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010b183010a140100\" style=\"color:#CFD4DC\">    });<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b183010a1500\" class=\"line \"><span data-hk=\"000000010000000000004000010b183010a150100\" style=\"color:#CFD4DC\">  }<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b18400\">Aha! Both implementations came from the same author, who had faced this problem and built a<br \/>\nsolution that works across that plugin suite.<\/p>\n<p data-hk=\"000000010000000000004000010b18500\">The complexity of introducing a system to encapsulate this behavior was passed down to the plugin<br \/>\nauthors, who can only build a system that works among their own extensions.<\/p>\n<p data-hk=\"000000010000000000004000010b18600\">omp has a similar problem:<\/p>\n<pre data-hk=\"000000010000000000004000010b18700\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1870100\"><span data-hk=\"000000010000000000004000010b187010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b18701010100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ modes\/interactive-mode.ts \u2014 the exclusivity \"system\", in its entirety<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b187010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b18701020100\" style=\"color:#FF54C0\">if<\/span><span data-hk=\"000000010000000000004000010b18701020200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b18701020300\" style=\"color:#C9A4FF\">this<\/span><span data-hk=\"000000010000000000004000010b18701020400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b18701020500\" style=\"color:#9BE8FF\">goalModeEnabled<\/span><span data-hk=\"000000010000000000004000010b18701020600\" style=\"color:#CFD4DC\"> || <\/span><span data-hk=\"000000010000000000004000010b18701020700\" style=\"color:#C9A4FF\">this<\/span><span data-hk=\"000000010000000000004000010b18701020800\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b18701020900\" style=\"color:#9BE8FF\">goalModePaused<\/span><span data-hk=\"000000010000000000004000010b18701020a1000\" style=\"color:#CFD4DC\">) { <\/span><span data-hk=\"000000010000000000004000010b18701020a1100\" style=\"color:#C9A4FF\">this<\/span><span data-hk=\"000000010000000000004000010b18701020a1200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b18701020a1300\" style=\"color:#44CFFF\">showWarning<\/span><span data-hk=\"000000010000000000004000010b18701020a1400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b18701020a1500\" style=\"color:#B99AFF\">\"Exit goal mode first.\"<\/span><span data-hk=\"000000010000000000004000010b18701020a1600\" style=\"color:#CFD4DC\">); <\/span><span data-hk=\"000000010000000000004000010b18701020a1700\" style=\"color:#FF54C0\">return<\/span><span data-hk=\"000000010000000000004000010b18701020a1800\" style=\"color:#CFD4DC\">; }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b187010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b18701030100\" style=\"color:#FF54C0\">if<\/span><span data-hk=\"000000010000000000004000010b18701030200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b18701030300\" style=\"color:#C9A4FF\">this<\/span><span data-hk=\"000000010000000000004000010b18701030400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b18701030500\" style=\"color:#9BE8FF\">vibeModeEnabled<\/span><span data-hk=\"000000010000000000004000010b18701030600\" style=\"color:#CFD4DC\">)                        { <\/span><span data-hk=\"000000010000000000004000010b18701030700\" style=\"color:#C9A4FF\">this<\/span><span data-hk=\"000000010000000000004000010b18701030800\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b18701030900\" style=\"color:#44CFFF\">showWarning<\/span><span data-hk=\"000000010000000000004000010b18701030a1000\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b18701030a1100\" style=\"color:#B99AFF\">\"Exit vibe mode first.\"<\/span><span data-hk=\"000000010000000000004000010b18701030a1200\" style=\"color:#CFD4DC\">); <\/span><span data-hk=\"000000010000000000004000010b18701030a1300\" style=\"color:#FF54C0\">return<\/span><span data-hk=\"000000010000000000004000010b18701030a1400\" style=\"color:#CFD4DC\">; }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b187010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b18701040100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ \u2026restated by hand at six other entry points<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b18800\">The missing abstraction becomes visible as soon as independently written behaviors meet. A private<br \/>\nmutex can keep one author&#8217;s Plan and Goal plugins from colliding, but it cannot make arbitrary<br \/>\nextensions compose. omp&#8217;s hand-written mode checks have the same limitation.<\/p>\n<p data-hk=\"000000010000000000004000010b18900\">Two decisions follow: name the loop-owning primitive\u2014a <strong data-hk=\"000000010000000000004000010b1890100\">Director<\/strong>\u2014and move more built-in behavior<br \/>\nonto the public extension surface so holes in that surface become impossible to ignore.<\/p>\n<h3 data-hk=\"000000010000000000004000010b19000\" id=\"directors-own-candidate-yields\">Directors own candidate yields<\/h3>\n<p data-hk=\"000000010000000000004000010b19100\">The agent has a loop. Things increasingly want to direct that loop: plan wants another turn until a<br \/>\nplan exists, goal wants another turn until the goal is complete, <code data-hk=\"000000010000000000004000010b1910100\">\/force<\/code> wants to alter the next<br \/>\ninference, the todo reminder wants one last chance to object before we yield.<\/p>\n<p data-hk=\"000000010000000000004000010b19200\">So give the <strong data-hk=\"000000010000000000004000010b1920100\">agent layer<\/strong> one object which owns that decision: a stack of Directors.<\/p>\n<p data-hk=\"000000010000000000004000010b19300\">By &#8220;stack&#8221; we mean one live subtree in the session DOM, not a Python array that we promise to<br \/>\nserialize later. The DOM is the authority; the runtime only walks it.<\/p>\n<pre data-hk=\"000000010000000000004000010b19400\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1940100\"><span data-hk=\"000000010000000000004000010b194010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b19401010100\">candidate yield flows this way \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b194010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b19401020100\">                                                               \u25bc<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b194010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b19401030100\">Base  \u2192  TodoReminder  \u2192  Goal  \u2192  Plan  \u2192  ForceTool(write)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b194010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b19401040100\">                                                parent    child\/top<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b19500\">The loop stays very boring:<\/p>\n<pre data-hk=\"000000010000000000004000010b19600\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b1960100\"><span data-hk=\"000000010000000000004000010b196010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b19601010100\" style=\"color:#FF54C0;fontStyle:italic\">while<\/span><span data-hk=\"000000010000000000004000010b19601010200\" style=\"color:#B99AFF\"> True<\/span><span data-hk=\"000000010000000000004000010b19601010300\" style=\"color:#CFD4DC\">:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b19601020100\" style=\"color:#CFD4DC\">    request = directors.<\/span><span data-hk=\"000000010000000000004000010b19601020200\" style=\"color:#44CFFF\">prepare_inference<\/span><span data-hk=\"000000010000000000004000010b19601020300\" style=\"color:#CFD4DC\">(base_request)  <\/span><span data-hk=\"000000010000000000004000010b19601020400\" style=\"color:#CFD4DC8F;fontStyle:italic\"># outside \u2192 inside<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b19601030100\" style=\"color:#CFD4DC\">    turn = <\/span><span data-hk=\"000000010000000000004000010b19601030200\" style=\"color:#FF54C0;fontStyle:italic\">await<\/span><span data-hk=\"000000010000000000004000010b19601030300\" style=\"color:#44CFFF\"> inference<\/span><span data-hk=\"000000010000000000004000010b19601030400\" style=\"color:#CFD4DC\">(request)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b19601040100\" style=\"color:#FF54C0;fontStyle:italic\">    await<\/span><span data-hk=\"000000010000000000004000010b19601040200\" style=\"color:#44CFFF\"> execute_tools<\/span><span data-hk=\"000000010000000000004000010b19601040300\" style=\"color:#CFD4DC\">(turn)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010500\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b196010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b19601060100\" style=\"color:#FF54C0;fontStyle:italic\">    if<\/span><span data-hk=\"000000010000000000004000010b19601060200\" style=\"color:#CFD4DC\"> turn.has_tool_calls:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b19601070100\" style=\"color:#FF54C0;fontStyle:italic\">        continue<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010800\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b196010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b19601090100\" style=\"color:#CFD4DC\">    decision = <\/span><span data-hk=\"000000010000000000004000010b19601090200\" style=\"color:#FF54C0;fontStyle:italic\">await<\/span><span data-hk=\"000000010000000000004000010b19601090300\" style=\"color:#CFD4DC\"> directors.<\/span><span data-hk=\"000000010000000000004000010b19601090400\" style=\"color:#44CFFF\">on_yield<\/span><span data-hk=\"000000010000000000004000010b19601090500\" style=\"color:#CFD4DC\">(turn)            <\/span><span data-hk=\"000000010000000000004000010b19601090600\" style=\"color:#CFD4DC8F;fontStyle:italic\"># inside \u2192 outside<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b196010a100100\" style=\"color:#FF54C0;fontStyle:italic\">    match<\/span><span data-hk=\"000000010000000000004000010b196010a100200\" style=\"color:#CFD4DC\"> decision:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b196010a110100\" style=\"color:#FF54C0;fontStyle:italic\">        case<\/span><span data-hk=\"000000010000000000004000010b196010a110200\" style=\"color:#44CFFF\"> Continue<\/span><span data-hk=\"000000010000000000004000010b196010a110300\" style=\"color:#CFD4DC\">(): <\/span><span data-hk=\"000000010000000000004000010b196010a110400\" style=\"color:#FF54C0;fontStyle:italic\">continue<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b196010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010b196010a120100\" style=\"color:#FF54C0;fontStyle:italic\">        case<\/span><span data-hk=\"000000010000000000004000010b196010a120200\" style=\"color:#44CFFF\"> Yield<\/span><span data-hk=\"000000010000000000004000010b196010a120300\" style=\"color:#CFD4DC\">():    <\/span><span data-hk=\"000000010000000000004000010b196010a120400\" style=\"color:#FF54C0;fontStyle:italic\">return<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b19700\"><code data-hk=\"000000010000000000004000010b1970100\">prepare_inference<\/code> walks the stack from the outside in, so the innermost behavior may refine the<br \/>\nrequest its parent was about to make. <code data-hk=\"000000010000000000004000010b1970200\">on_yield<\/code> walks back out. Each Director may:<\/p>\n<ul data-hk=\"000000010000000000004000010b19800\">\n<li data-hk=\"000000010000000000004000010b1980100\"><strong data-hk=\"000000010000000000004000010b198010100\">Pass<\/strong> \u2014 let the next Director inspect the candidate yield.<\/li>\n<li data-hk=\"000000010000000000004000010b1980200\"><strong data-hk=\"000000010000000000004000010b198020100\">Continue<\/strong> \u2014 consume the yield and run another turn.<\/li>\n<li data-hk=\"000000010000000000004000010b1980300\"><strong data-hk=\"000000010000000000004000010b198030100\">Yield<\/strong> \u2014 consume it and actually yield to the user.<\/li>\n<li data-hk=\"000000010000000000004000010b1980400\"><strong data-hk=\"000000010000000000004000010b198040100\">Push<\/strong> \u2014 put a child Director on top of itself.<\/li>\n<li data-hk=\"000000010000000000004000010b1980500\"><strong data-hk=\"000000010000000000004000010b198050100\">Done<\/strong> \u2014 pop itself, then offer the same candidate yield to its parent.<\/li>\n<li data-hk=\"000000010000000000004000010b1980600\"><strong data-hk=\"000000010000000000004000010b198060100\">Fail<\/strong> \u2014 pop with an error.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b19900\">Consequently, rewind removes Directors, resume restores them, and a remote inspector can see which<br \/>\nbehavior currently owns the candidate yield.<\/p>\n<h3 data-hk=\"000000010000000000004000010b20000\" id=\"plan-mode-completely\">Plan mode, completely<\/h3>\n<p data-hk=\"000000010000000000004000010b20100\">Say plan mode is active and the model tries to yield without writing the plan file. Plan sees that<br \/>\ncandidate yield before any outer behavior does:<\/p>\n<pre data-hk=\"000000010000000000004000010b20200\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2020100\"><span data-hk=\"000000010000000000004000010b202010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201010100\" style=\"color:#FF54C0\">class<\/span><span data-hk=\"000000010000000000004000010b20201010200\" style=\"color:#C9A4FF\"> Plan<\/span><span data-hk=\"000000010000000000004000010b20201010300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20201010400\" style=\"color:#C9A4FF\">Director<\/span><span data-hk=\"000000010000000000004000010b20201010500\" style=\"color:#CFD4DC\">):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201020100\" style=\"color:#FF54C0\">    async<\/span><span data-hk=\"000000010000000000004000010b20201020200\" style=\"color:#FF54C0\"> def<\/span><span data-hk=\"000000010000000000004000010b20201020300\" style=\"color:#44CFFF\"> on_yield<\/span><span data-hk=\"000000010000000000004000010b20201020400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20201020500\" style=\"color:#C9A4FF;fontStyle:italic\">self<\/span><span data-hk=\"000000010000000000004000010b20201020600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b20201020700\" style=\"color:#B99AFF;fontStyle:italic\">agent<\/span><span data-hk=\"000000010000000000004000010b20201020800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b20201020900\" style=\"color:#B99AFF;fontStyle:italic\">turn<\/span><span data-hk=\"000000010000000000004000010b20201020a1000\" style=\"color:#CFD4DC\">):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201030100\" style=\"color:#FF54C0;fontStyle:italic\">        if<\/span><span data-hk=\"000000010000000000004000010b20201030200\" style=\"color:#FF54C0\"> not<\/span><span data-hk=\"000000010000000000004000010b20201030300\" style=\"color:#CFD4DC\"> turn.<\/span><span data-hk=\"000000010000000000004000010b20201030400\" style=\"color:#44CFFF\">wrote<\/span><span data-hk=\"000000010000000000004000010b20201030500\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20201030600\" style=\"color:#C9A4FF\">self<\/span><span data-hk=\"000000010000000000004000010b20201030700\" style=\"color:#CFD4DC\">.plan_file):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201040100\" style=\"color:#FF54C0;fontStyle:italic\">            return<\/span><span data-hk=\"000000010000000000004000010b20201040200\" style=\"color:#CFD4DC\"> agent.<\/span><span data-hk=\"000000010000000000004000010b20201040300\" style=\"color:#44CFFF\">force_tool<\/span><span data-hk=\"000000010000000000004000010b20201040400\" style=\"color:#CFD4DC\">(<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201050100\" style=\"color:#B99AFF\">                \"write\"<\/span><span data-hk=\"000000010000000000004000010b20201050200\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201060100\" style=\"color:#9BE8FF;fontStyle:italic\">                until<\/span><span data-hk=\"000000010000000000004000010b20201060200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b20201060300\" style=\"color:#FF54C0\">lambda<\/span><span data-hk=\"000000010000000000004000010b20201060400\" style=\"color:#B99AFF;fontStyle:italic\"> turn<\/span><span data-hk=\"000000010000000000004000010b20201060500\" style=\"color:#CFD4DC\">: turn.<\/span><span data-hk=\"000000010000000000004000010b20201060600\" style=\"color:#44CFFF\">wrote<\/span><span data-hk=\"000000010000000000004000010b20201060700\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20201060800\" style=\"color:#C9A4FF\">self<\/span><span data-hk=\"000000010000000000004000010b20201060900\" style=\"color:#CFD4DC\">.plan_file),<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201070100\" style=\"color:#9BE8FF;fontStyle:italic\">                reminder<\/span><span data-hk=\"000000010000000000004000010b20201070200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b20201070300\" style=\"color:#B99AFF\">\"Write the plan file before yielding.\"<\/span><span data-hk=\"000000010000000000004000010b20201070400\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201080100\" style=\"color:#9BE8FF;fontStyle:italic\">                retries<\/span><span data-hk=\"000000010000000000004000010b20201080200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b20201080300\" style=\"color:#B99AFF\">3<\/span><span data-hk=\"000000010000000000004000010b20201080400\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b20201090100\" style=\"color:#CFD4DC\">            )<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1000\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b202010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a110100\" style=\"color:#FF54C0;fontStyle:italic\">        if<\/span><span data-hk=\"000000010000000000004000010b202010a110200\" style=\"color:#FF54C0\"> not<\/span><span data-hk=\"000000010000000000004000010b202010a110300\" style=\"color:#CFD4DC\"> turn.<\/span><span data-hk=\"000000010000000000004000010b202010a110400\" style=\"color:#44CFFF\">called<\/span><span data-hk=\"000000010000000000004000010b202010a110500\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b202010a110600\" style=\"color:#B99AFF\">\"ask\"<\/span><span data-hk=\"000000010000000000004000010b202010a110700\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b202010a110800\" style=\"color:#FF54C0\">and<\/span><span data-hk=\"000000010000000000004000010b202010a110900\" style=\"color:#FF54C0\"> not<\/span><span data-hk=\"000000010000000000004000010b202010a110a1000\" style=\"color:#CFD4DC\"> turn.<\/span><span data-hk=\"000000010000000000004000010b202010a110a1100\" style=\"color:#44CFFF\">proposed_plan<\/span><span data-hk=\"000000010000000000004000010b202010a110a1200\" style=\"color:#CFD4DC\">():<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a120100\" style=\"color:#FF54C0;fontStyle:italic\">            return<\/span><span data-hk=\"000000010000000000004000010b202010a120200\" style=\"color:#CFD4DC\"> agent.<\/span><span data-hk=\"000000010000000000004000010b202010a120300\" style=\"color:#44CFFF\">force_tool<\/span><span data-hk=\"000000010000000000004000010b202010a120400\" style=\"color:#CFD4DC\">(<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a130100\" style=\"color:#B99AFF\">                \"required\"<\/span><span data-hk=\"000000010000000000004000010b202010a130200\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a140100\" style=\"color:#9BE8FF;fontStyle:italic\">                until<\/span><span data-hk=\"000000010000000000004000010b202010a140200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b202010a140300\" style=\"color:#FF54C0\">lambda<\/span><span data-hk=\"000000010000000000004000010b202010a140400\" style=\"color:#B99AFF;fontStyle:italic\"> turn<\/span><span data-hk=\"000000010000000000004000010b202010a140500\" style=\"color:#CFD4DC\">: turn.<\/span><span data-hk=\"000000010000000000004000010b202010a140600\" style=\"color:#44CFFF\">called<\/span><span data-hk=\"000000010000000000004000010b202010a140700\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b202010a140800\" style=\"color:#B99AFF\">\"ask\"<\/span><span data-hk=\"000000010000000000004000010b202010a140900\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b202010a140a1000\" style=\"color:#FF54C0;fontStyle:italic\">or<\/span><span data-hk=\"000000010000000000004000010b202010a140a1100\" style=\"color:#CFD4DC\"> turn.<\/span><span data-hk=\"000000010000000000004000010b202010a140a1200\" style=\"color:#44CFFF\">proposed_plan<\/span><span data-hk=\"000000010000000000004000010b202010a140a1300\" style=\"color:#CFD4DC\">(),<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1500\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a150100\" style=\"color:#9BE8FF;fontStyle:italic\">                reminder<\/span><span data-hk=\"000000010000000000004000010b202010a150200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b202010a150300\" style=\"color:#B99AFF\">\"Propose the plan, or ask the user what is missing.\"<\/span><span data-hk=\"000000010000000000004000010b202010a150400\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1600\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a160100\" style=\"color:#9BE8FF;fontStyle:italic\">                retries<\/span><span data-hk=\"000000010000000000004000010b202010a160200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b202010a160300\" style=\"color:#B99AFF\">3<\/span><span data-hk=\"000000010000000000004000010b202010a160400\" style=\"color:#CFD4DC\">,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1700\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a170100\" style=\"color:#CFD4DC\">            )<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b202010a1800\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b202010a1900\" class=\"line \"><span data-hk=\"000000010000000000004000010b202010a190100\" style=\"color:#FF54C0;fontStyle:italic\">        return<\/span><span data-hk=\"000000010000000000004000010b202010a190200\" style=\"color:#44CFFF\"> Yield<\/span><span data-hk=\"000000010000000000004000010b202010a190300\" style=\"color:#CFD4DC\">()<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b20300\">Now <code data-hk=\"000000010000000000004000010b2030100\">force_tool(\"write\")<\/code>, in its soft mode, pushes a small built-in Director that contributes the capability to the next inference request:<\/p>\n<pre data-hk=\"000000010000000000004000010b20400\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2040100\"><span data-hk=\"000000010000000000004000010b204010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401010100\" style=\"color:#FF54C0\">class<\/span><span data-hk=\"000000010000000000004000010b20401010200\" style=\"color:#C9A4FF\"> ForceTool<\/span><span data-hk=\"000000010000000000004000010b20401010300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20401010400\" style=\"color:#C9A4FF\">Director<\/span><span data-hk=\"000000010000000000004000010b20401010500\" style=\"color:#CFD4DC\">):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401020100\" style=\"color:#FF54C0\">    def<\/span><span data-hk=\"000000010000000000004000010b20401020200\" style=\"color:#44CFFF\"> prepare_inference<\/span><span data-hk=\"000000010000000000004000010b20401020300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20401020400\" style=\"color:#C9A4FF;fontStyle:italic\">self<\/span><span data-hk=\"000000010000000000004000010b20401020500\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b20401020600\" style=\"color:#B99AFF;fontStyle:italic\">request<\/span><span data-hk=\"000000010000000000004000010b20401020700\" style=\"color:#CFD4DC\">):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401030100\" style=\"color:#FF54C0;fontStyle:italic\">        return<\/span><span data-hk=\"000000010000000000004000010b20401030200\" style=\"color:#CFD4DC\"> request.<\/span><span data-hk=\"000000010000000000004000010b20401030300\" style=\"color:#44CFFF\">with_tool_choice<\/span><span data-hk=\"000000010000000000004000010b20401030400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20401030500\" style=\"color:#C9A4FF\">self<\/span><span data-hk=\"000000010000000000004000010b20401030600\" style=\"color:#CFD4DC\">.tool)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010400\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b204010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401050100\" style=\"color:#FF54C0\">    async<\/span><span data-hk=\"000000010000000000004000010b20401050200\" style=\"color:#FF54C0\"> def<\/span><span data-hk=\"000000010000000000004000010b20401050300\" style=\"color:#44CFFF\"> on_yield<\/span><span data-hk=\"000000010000000000004000010b20401050400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20401050500\" style=\"color:#C9A4FF;fontStyle:italic\">self<\/span><span data-hk=\"000000010000000000004000010b20401050600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b20401050700\" style=\"color:#B99AFF;fontStyle:italic\">agent<\/span><span data-hk=\"000000010000000000004000010b20401050800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b20401050900\" style=\"color:#B99AFF;fontStyle:italic\">turn<\/span><span data-hk=\"000000010000000000004000010b20401050a1000\" style=\"color:#CFD4DC\">):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401060100\" style=\"color:#FF54C0;fontStyle:italic\">        if<\/span><span data-hk=\"000000010000000000004000010b20401060200\" style=\"color:#C9A4FF\"> self<\/span><span data-hk=\"000000010000000000004000010b20401060300\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b20401060400\" style=\"color:#44CFFF\">until<\/span><span data-hk=\"000000010000000000004000010b20401060500\" style=\"color:#CFD4DC\">(turn):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401070100\" style=\"color:#FF54C0;fontStyle:italic\">            return<\/span><span data-hk=\"000000010000000000004000010b20401070200\" style=\"color:#44CFFF\"> Done<\/span><span data-hk=\"000000010000000000004000010b20401070300\" style=\"color:#CFD4DC\">()                    <\/span><span data-hk=\"000000010000000000004000010b20401070400\" style=\"color:#CFD4DC8F;fontStyle:italic\"># pop; offer the yield back to Plan<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401080100\" style=\"color:#FF54C0;fontStyle:italic\">        if<\/span><span data-hk=\"000000010000000000004000010b20401080200\" style=\"color:#C9A4FF\"> self<\/span><span data-hk=\"000000010000000000004000010b20401080300\" style=\"color:#CFD4DC\">.retries_left:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b20401090100\" style=\"color:#FF54C0;fontStyle:italic\">            return<\/span><span data-hk=\"000000010000000000004000010b20401090200\" style=\"color:#44CFFF\"> Continue<\/span><span data-hk=\"000000010000000000004000010b20401090300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20401090400\" style=\"color:#C9A4FF\">self<\/span><span data-hk=\"000000010000000000004000010b20401090500\" style=\"color:#CFD4DC\">.reminder)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b204010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b204010a100100\" style=\"color:#FF54C0;fontStyle:italic\">        return<\/span><span data-hk=\"000000010000000000004000010b204010a100200\" style=\"color:#44CFFF\"> Fail<\/span><span data-hk=\"000000010000000000004000010b204010a100300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b204010a100400\" style=\"color:#B99AFF\">\"tool requirement exhausted\"<\/span><span data-hk=\"000000010000000000004000010b204010a100500\" style=\"color:#CFD4DC\">)<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b20500\">Plan already has another Director below it on the stack:<\/p>\n<pre data-hk=\"000000010000000000004000010b20600\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2060100\"><span data-hk=\"000000010000000000004000010b206010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b20601010100\">Base \u2192 TodoReminder \u2192 Plan<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b20700\">A candidate yield reaches Plan first. While Plan is active, Plan either continues, pushes a child,<br \/>\nor yields directly to the user. It does not <code data-hk=\"000000010000000000004000010b2070100\">Pass<\/code>, so the outer TodoReminder never sees that yield.<\/p>\n<p data-hk=\"000000010000000000004000010b20800\">Extensions use the exact same interface:<\/p>\n<pre data-hk=\"000000010000000000004000010b20900\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2090100\"><span data-hk=\"000000010000000000004000010b209010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b20901010100\" style=\"color:#FF54C0;fontStyle:italic\">await<\/span><span data-hk=\"000000010000000000004000010b20901010200\" style=\"color:#CFD4DC\"> agent.<\/span><span data-hk=\"000000010000000000004000010b20901010300\" style=\"color:#44CFFF\">direct<\/span><span data-hk=\"000000010000000000004000010b20901010400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20901010500\" style=\"color:#44CFFF\">VerifyBeforeYield<\/span><span data-hk=\"000000010000000000004000010b20901010600\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b20901010700\" style=\"color:#B99AFF\">...<\/span><span data-hk=\"000000010000000000004000010b20901010800\" style=\"color:#CFD4DC\">))<\/span><\/span><\/code><\/pre>\n<pre data-hk=\"000000010000000000004000010b21000\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2100100\"><span data-hk=\"000000010000000000004000010b210010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b21001010100\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b21001010200\" style=\"color:#FF54C0\">directors<\/span><span data-hk=\"000000010000000000004000010b21001010300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b210010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b21001020100\" style=\"color:#CFD4DC\">  &lt;<\/span><span data-hk=\"000000010000000000004000010b21001020200\" style=\"color:#FF54C0\">todo-reminder<\/span><span data-hk=\"000000010000000000004000010b21001020300\" style=\"color:#9BE8FF\"> id<\/span><span data-hk=\"000000010000000000004000010b21001020400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b21001020500\" style=\"color:#B99AFF\">\"d1\"<\/span><span data-hk=\"000000010000000000004000010b21001020600\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b210010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b21001030100\" style=\"color:#CFD4DC\">    &lt;<\/span><span data-hk=\"000000010000000000004000010b21001030200\" style=\"color:#FF54C0\">plan<\/span><span data-hk=\"000000010000000000004000010b21001030300\" style=\"color:#9BE8FF\"> id<\/span><span data-hk=\"000000010000000000004000010b21001030400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b21001030500\" style=\"color:#B99AFF\">\"d2\"<\/span><span data-hk=\"000000010000000000004000010b21001030600\" style=\"color:#9BE8FF\"> plan-file<\/span><span data-hk=\"000000010000000000004000010b21001030700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b21001030800\" style=\"color:#B99AFF\">\"local:\/\/auth-plan.md\"<\/span><span data-hk=\"000000010000000000004000010b21001030900\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b210010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b21001040100\" style=\"color:#CFD4DC\">      &lt;<\/span><span data-hk=\"000000010000000000004000010b21001040200\" style=\"color:#FF54C0\">force-tool<\/span><span data-hk=\"000000010000000000004000010b21001040300\" style=\"color:#9BE8FF\"> id<\/span><span data-hk=\"000000010000000000004000010b21001040400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b21001040500\" style=\"color:#B99AFF\">\"d3\"<\/span><span data-hk=\"000000010000000000004000010b21001040600\" style=\"color:#9BE8FF\"> tool<\/span><span data-hk=\"000000010000000000004000010b21001040700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b21001040800\" style=\"color:#B99AFF\">\"write\"<\/span><span data-hk=\"000000010000000000004000010b21001040900\" style=\"color:#9BE8FF\"> attempts<\/span><span data-hk=\"000000010000000000004000010b21001040a1000\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b21001040a1100\" style=\"color:#B99AFF\">\"1\"<\/span><span data-hk=\"000000010000000000004000010b21001040a1200\" style=\"color:#9BE8FF\"> max-attempts<\/span><span data-hk=\"000000010000000000004000010b21001040a1300\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b21001040a1400\" style=\"color:#B99AFF\">\"3\"<\/span><span data-hk=\"000000010000000000004000010b21001040a1500\" style=\"color:#CFD4DC\">\/&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b210010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b21001050100\" style=\"color:#CFD4DC\">    &lt;\/<\/span><span data-hk=\"000000010000000000004000010b21001050200\" style=\"color:#FF54C0\">plan<\/span><span data-hk=\"000000010000000000004000010b21001050300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b210010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b21001060100\" style=\"color:#CFD4DC\">  &lt;\/<\/span><span data-hk=\"000000010000000000004000010b21001060200\" style=\"color:#FF54C0\">todo-reminder<\/span><span data-hk=\"000000010000000000004000010b21001060300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b210010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b21001070100\" style=\"color:#CFD4DC\">&lt;\/<\/span><span data-hk=\"000000010000000000004000010b21001070200\" style=\"color:#FF54C0\">directors<\/span><span data-hk=\"000000010000000000004000010b21001070300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b21100\">This is a full composition rather than another special mode. Plan owns the yield, temporarily pushes<br \/>\nForceTool, receives the same candidate yield back when the child is done, and either continues or<br \/>\nreturns it to the user.<\/p>\n<h3 data-hk=\"000000010000000000004000010b21200\" id=\"hooks-directors-and-inference\">Hooks, Directors, and inference<\/h3>\n<ul data-hk=\"000000010000000000004000010b21300\">\n<li data-hk=\"000000010000000000004000010b2130100\">A <strong data-hk=\"000000010000000000004000010b213010100\">hook<\/strong> observes or edits one inference or turn.<\/li>\n<li data-hk=\"000000010000000000004000010b2130200\">A <strong data-hk=\"000000010000000000004000010b213020100\">Director<\/strong> can keep control across turns and intercept yielding.<\/li>\n<li data-hk=\"000000010000000000004000010b2130300\">Directors meaningfully stack, nest, finish, and resume their parent.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b21400\">That is enough for plan, goal, vibe, autoresearch, reminders, and external verification behaviors to<br \/>\nuse the same agent-layer primitive\u2014without teaching each one the private flags of every other one.<\/p>\n<p data-hk=\"000000010000000000004000010b21500\"><code data-hk=\"000000010000000000004000010b2150100\">ForceTool<\/code> expresses a semantic request: \u201cthe next successful turn must call <code data-hk=\"000000010000000000004000010b2150200\">write<\/code>.\u201d It does not<br \/>\nknow whether the selected provider has native <code data-hk=\"000000010000000000004000010b2150300\">tool_choice<\/code>, whether forcing destroys a cache, or<br \/>\nwhether a local model needs an extra prompt. That translation belongs to the inference layer.<\/p>\n<p data-hk=\"000000010000000000004000010b21600\">The control plane can now say what should happen. The next chapter makes that request mean the same<br \/>\nthing across incompatible models and providers.<\/p>\n<h2 data-hk=\"000000010000000000004000010b21700\" id=\"the-inference\">The inference<\/h2>\n<aside data-hk=\"000000010000000000004000010b2180\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Model compatibility is structured knowledge with explicit precedence\u2014not provider-name branches scattered through code.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b21810\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b21900\">The control plane asks for semantic behavior: stream this model, force that capability, enforce this<br \/>\nshape, count these tokens. The inference layer has to translate those requests into whatever this<br \/>\nexact model, on this exact host, through this exact API can actually do.<\/p>\n<h3 data-hk=\"000000010000000000004000010b22000\" id=\"what-omp-taught-us-quirks-become-architecture\">What omp taught us: quirks become architecture<\/h3>\n<p data-hk=\"000000010000000000004000010b22100\">This one is easy to explain because there&#8217;s already a before\/after commit on omp v1.<\/p>\n<p data-hk=\"000000010000000000004000010b22200\">Before <code data-hk=\"000000010000000000004000010b2220100\">dd57045396<\/code>, OpenAI compatibility lived in one 880-line file centered on a giant builder. Open it and you were greeted with this:<\/p>\n<pre data-hk=\"000000010000000000004000010b22300\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2230100\"><span data-hk=\"000000010000000000004000010b223010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301010100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b22301010200\" style=\"color:#C9A4FF\"> isCerebras<\/span><span data-hk=\"000000010000000000004000010b22301010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b22301010400\" style=\"color:#44CFFF\">modelMatchesHost<\/span><span data-hk=\"000000010000000000004000010b22301010500\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b22301010600\" style=\"color:#9BE8FF\">hostModel<\/span><span data-hk=\"000000010000000000004000010b22301010700\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b22301010800\" style=\"color:#B99AFF\">\"cerebras\"<\/span><span data-hk=\"000000010000000000004000010b22301010900\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301020100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b22301020200\" style=\"color:#C9A4FF\"> isZai<\/span><span data-hk=\"000000010000000000004000010b22301020300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b22301020400\" style=\"color:#44CFFF\">modelMatchesHost<\/span><span data-hk=\"000000010000000000004000010b22301020500\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b22301020600\" style=\"color:#9BE8FF\">hostModel<\/span><span data-hk=\"000000010000000000004000010b22301020700\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b22301020800\" style=\"color:#B99AFF\">\"zai\"<\/span><span data-hk=\"000000010000000000004000010b22301020900\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301030100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b22301030200\" style=\"color:#C9A4FF\"> isKimiModel<\/span><span data-hk=\"000000010000000000004000010b22301030300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b22301030400\" style=\"color:#44CFFF\">isKimiModelId<\/span><span data-hk=\"000000010000000000004000010b22301030500\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b22301030600\" style=\"color:#9BE8FF\">spec<\/span><span data-hk=\"000000010000000000004000010b22301030700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b22301030800\" style=\"color:#9BE8FF\">id<\/span><span data-hk=\"000000010000000000004000010b22301030900\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301040100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b22301040200\" style=\"color:#C9A4FF\"> isMoonshotKimi<\/span><span data-hk=\"000000010000000000004000010b22301040300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b22301040400\" style=\"color:#9BE8FF\">isKimiModel<\/span><span data-hk=\"000000010000000000004000010b22301040500\" style=\"color:#CFD4DC\"> &amp;&amp; <\/span><span data-hk=\"000000010000000000004000010b22301040600\" style=\"color:#9BE8FF\">isMoonshotNative<\/span><span data-hk=\"000000010000000000004000010b22301040700\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301050100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b22301050200\" style=\"color:#C9A4FF\"> isAnthropicModel<\/span><span data-hk=\"000000010000000000004000010b22301050300\" style=\"color:#CFD4DC\"> =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301060100\" style=\"color:#44CFFF\">    modelMatchesHost<\/span><span data-hk=\"000000010000000000004000010b22301060200\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b22301060300\" style=\"color:#9BE8FF\">hostModel<\/span><span data-hk=\"000000010000000000004000010b22301060400\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b22301060500\" style=\"color:#B99AFF\">\"anthropic\"<\/span><span data-hk=\"000000010000000000004000010b22301060600\" style=\"color:#CFD4DC\">) ||<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301070100\" style=\"color:#44CFFF\">    isClaudeModelId<\/span><span data-hk=\"000000010000000000004000010b22301070200\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b22301070300\" style=\"color:#9BE8FF\">spec<\/span><span data-hk=\"000000010000000000004000010b22301070400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b22301070500\" style=\"color:#9BE8FF\">id<\/span><span data-hk=\"000000010000000000004000010b22301070600\" style=\"color:#CFD4DC\">) ||<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301080100\" style=\"color:#44CFFF\">    isAnthropicNamespacedModelId<\/span><span data-hk=\"000000010000000000004000010b22301080200\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b22301080300\" style=\"color:#9BE8FF\">spec<\/span><span data-hk=\"000000010000000000004000010b22301080400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b22301080500\" style=\"color:#9BE8FF\">id<\/span><span data-hk=\"000000010000000000004000010b22301080600\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b223010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b22301090100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ \u2026then DeepSeek, Qwen, MiMo, Grok, Mistral, OpenCode, local servers<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b22400\">Then those booleans feed other booleans, several nested ternaries, and finally one giant <code data-hk=\"000000010000000000004000010b2240100\">compat<\/code><br \/>\nobject. Is Kimi allowed to force a tool while thinking? Depends which Kimi, on which host, through<br \/>\nwhich API. Does this loopback URL mean llama.cpp, or LiteLLM proxying something else? Better add<br \/>\nanother carve-out.<\/p>\n<p data-hk=\"000000010000000000004000010b22500\">There is nothing wrong with any individual branch! Each one fixed a real provider bug. The problem<br \/>\nis that the same knowledge ended up encoded in several places:<\/p>\n<ul data-hk=\"000000010000000000004000010b22600\">\n<li data-hk=\"000000010000000000004000010b2260100\"><code data-hk=\"000000010000000000004000010b226010100\">compat\/openai.ts<\/code>: 880 lines<\/li>\n<li data-hk=\"000000010000000000004000010b2260200\"><code data-hk=\"000000010000000000004000010b226020100\">model-thinking.ts<\/code>: 977 lines<\/li>\n<li data-hk=\"000000010000000000004000010b2260300\"><code data-hk=\"000000010000000000004000010b226030100\">variant-collapse.ts<\/code>: 1,776 lines<\/li>\n<li data-hk=\"000000010000000000004000010b2260400\">separate Bedrock, Anthropic, and Devin compatibility builders<\/li>\n<li data-hk=\"000000010000000000004000010b2260500\">more name detection in discovery and provider serializers<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b22700\">What replaced them?<\/p>\n<pre data-hk=\"000000010000000000004000010b22800\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2280100\"><span data-hk=\"000000010000000000004000010b228010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b22801010100\">taxonomy\/   \"what model is this string?\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b228010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b22801020100\">classes\/    \"what is true of this model lineage?\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b228010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b22801030100\">providers\/  \"what does this host change?\"<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b22900\">So Anthropic thinking now reads like this:<\/p>\n<pre data-hk=\"000000010000000000004000010b23000\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2300100\"><span data-hk=\"000000010000000000004000010b230010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001010100\" style=\"color:#FF54C0\">class<\/span><span data-hk=\"000000010000000000004000010b23001010200\" style=\"color:#B99AFF\"> \"anthropic\"<\/span><span data-hk=\"000000010000000000004000010b23001010300\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001020100\" style=\"color:#FF54C0\">    on<\/span><span data-hk=\"000000010000000000004000010b23001020200\" style=\"color:#B99AFF\"> \"anthropic\"<\/span><span data-hk=\"000000010000000000004000010b23001020300\" style=\"color:#B99AFF\"> \"amazon-bedrock\"<\/span><span data-hk=\"000000010000000000004000010b23001020400\" style=\"color:#B99AFF\"> \"google-vertex\"<\/span><span data-hk=\"000000010000000000004000010b23001020500\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001030100\" style=\"color:#FF54C0\">        family<\/span><span data-hk=\"000000010000000000004000010b23001030200\" style=\"color:#B99AFF\"> \"sonnet\"<\/span><span data-hk=\"000000010000000000004000010b23001030300\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001040100\" style=\"color:#FF54C0\">            revision<\/span><span data-hk=\"000000010000000000004000010b23001040200\" style=\"color:#B99AFF\"> \"&gt;=3.7 &lt;4.6\"<\/span><span data-hk=\"000000010000000000004000010b23001040300\" style=\"color:#CFD4DC\"> {<\/span><span data-hk=\"000000010000000000004000010b23001040400\" style=\"color:#FF54C0\"> thinking-mode<\/span><span data-hk=\"000000010000000000004000010b23001040500\" style=\"color:#B99AFF\"> \"budget\"<\/span><span data-hk=\"000000010000000000004000010b23001040600\" style=\"color:#CFD4DC\"> }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001050100\" style=\"color:#CFD4DC\">        }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001060100\" style=\"color:#FF54C0\">        revision<\/span><span data-hk=\"000000010000000000004000010b23001060200\" style=\"color:#B99AFF\"> \"&gt;=4.7\"<\/span><span data-hk=\"000000010000000000004000010b23001060300\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001070100\" style=\"color:#FF54C0\">            thinking-mode<\/span><span data-hk=\"000000010000000000004000010b23001070200\" style=\"color:#B99AFF\"> \"anthropic-adaptive\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001080100\" style=\"color:#CFD4DC\">        }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b23001090100\" style=\"color:#CFD4DC\">    }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b230010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b230010a100100\" style=\"color:#CFD4DC\">}<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b23100\">That&#8217;s the actual knowledge we were trying to express! Sonnet revisions before 4.6 use budget<br \/>\nthinking; Anthropic 4.7+ uses adaptive thinking; only claim this on hosts where we checked it.<\/p>\n<p data-hk=\"000000010000000000004000010b23200\">KDL itself is not magic. The compiler is what saved us from rebuilding the mess in a prettier<br \/>\nformat:<\/p>\n<ul data-hk=\"000000010000000000004000010b23300\">\n<li data-hk=\"000000010000000000004000010b2330100\">Unknown directive or value? Error.<\/li>\n<li data-hk=\"000000010000000000004000010b2330200\">Two equally specific rules setting the same thing? Error \u2014 file order does not secretly win.<\/li>\n<li data-hk=\"000000010000000000004000010b2330300\">No matching rule? Unknown, not &#8220;false&#8221;.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b23400\">Did this make providers less weird? Of course not. We still have compatibility axes named<br \/>\n<code data-hk=\"000000010000000000004000010b2340100\">requires-mistral-tool-ids<\/code>, <code data-hk=\"000000010000000000004000010b2340200\">qwen-preserve-thinking<\/code>, <code data-hk=\"000000010000000000004000010b2340300\">strip-deepseek-special-tokens<\/code>, and ten<br \/>\nways to spell &#8220;turn reasoning off&#8221;. Look at the names and weep.<\/p>\n<p data-hk=\"000000010000000000004000010b23500\">What it saved us from was expressing the next quirk as another branch in four different functions.<br \/>\nNow it&#8217;s one rule, in the place that owns the fact, with a compiler yelling if its precedence is<br \/>\nambiguous \u2014 and the inference layer can finally answer: <em data-hk=\"000000010000000000004000010b2350100\">what does this exact model, on this exact<br \/>\nhost, actually support?<\/em><\/p>\n<p data-hk=\"000000010000000000004000010b23600\">The win is not fewer quirks. It is one owner for each fact, explicit precedence, and an <code data-hk=\"000000010000000000004000010b2360100\">unknown<\/code><br \/>\nstate when the library has not established an answer. The rest of the harness stops rediscovering<br \/>\nmodel identity through provider-name branches.<\/p>\n<h3 data-hk=\"000000010000000000004000010b23700\" id=\"a-provider-is-more-than-stream\">A provider is more than <code data-hk=\"000000010000000000004000010b2370100\">stream<\/code><\/h3>\n<p data-hk=\"000000010000000000004000010b23800\">This was almost guaranteed to come back and haunt me the second I implemented my Pi plugin for<br \/>\nweb-search. In fact, the same pressure hit the minimalist origins of the repository too, as you can see<br \/>\nwith Pi&#8217;s new <a data-hk=\"000000010000000000004000010b2380100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/main\/packages\/ai\/src\/image-models.ts\">image<br \/>\nmodels<\/a><br \/>\nimplementation.<\/p>\n<p data-hk=\"000000010000000000004000010b23900\">Pi models providers as <code data-hk=\"000000010000000000004000010b2390100\">stream<\/code> and <code data-hk=\"000000010000000000004000010b2390200\">streamSimple<\/code> and that&#8217;s more or less it! Great for standing up a<br \/>\nprovider quickly, however not great for building more and more on top of it because:<\/p>\n<ul data-hk=\"000000010000000000004000010b24000\">\n<li data-hk=\"000000010000000000004000010b2400100\">What about Anthropic&#8217;s token-counting interface?<\/li>\n<li data-hk=\"000000010000000000004000010b2400200\">or, Codex&#8217;s WebRTC voice endpoint &amp; remote compaction?<\/li>\n<li data-hk=\"000000010000000000004000010b2400300\">or, Anthropic\/OpenAI web-search?<\/li>\n<li data-hk=\"000000010000000000004000010b2400400\">or, embeddings?<\/li>\n<li data-hk=\"000000010000000000004000010b2400500\">or, image\/video generation?<\/li>\n<li data-hk=\"000000010000000000004000010b2400600\">or, tokenization?<\/li>\n<li data-hk=\"000000010000000000004000010b2400700\">or, usage query?<\/li>\n<li data-hk=\"000000010000000000004000010b2400800\">or, model discovery?<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b24100\">Do you think every extension that does one of these also implements synchronized OAuth refresh<br \/>\nand retries correctly?<\/p>\n<p data-hk=\"000000010000000000004000010b24200\">Beyond that, having access to the bleeding-edge controls that the inference provider supports is a<br \/>\nmajor win, some examples:<\/p>\n<ul data-hk=\"000000010000000000004000010b24300\">\n<li data-hk=\"000000010000000000004000010b2430100\">Constrained sampling<\/li>\n<li data-hk=\"000000010000000000004000010b2430200\">Text verbosity options for OpenAI<\/li>\n<li data-hk=\"000000010000000000004000010b2430300\">Google&#8217;s context filter options<\/li>\n<li data-hk=\"000000010000000000004000010b2430400\">Forced tool calls<\/li>\n<li data-hk=\"000000010000000000004000010b2430500\">Developer role<\/li>\n<li data-hk=\"000000010000000000004000010b2430600\">Mid-session system prompts<\/li>\n<li data-hk=\"000000010000000000004000010b2430700\">&#8230;<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b24400\">Authentication refresh, retries, token counting, search, generation, discovery, and provider-native<br \/>\ncontrols are shared infrastructure. Leaving them to extensions guarantees several partial<br \/>\nimplementations of the same protocol.<\/p>\n<h3 data-hk=\"000000010000000000004000010b24500\" id=\"capability-policy-forced-tool-calls\">Capability policy: forced tool calls<\/h3>\n<p data-hk=\"000000010000000000004000010b24600\">A forced tool call shows why \u201csupporting a flag\u201d is not enough:<\/p>\n<ul data-hk=\"000000010000000000004000010b24700\">\n<li data-hk=\"000000010000000000004000010b2470100\"><strong data-hk=\"000000010000000000004000010b247010100\">Error on unsupported providers:<\/strong> no harness-native feature can use it without excluding a large<br \/>\npart of the model roster.<\/li>\n<li data-hk=\"000000010000000000004000010b2470200\"><strong data-hk=\"000000010000000000004000010b247020100\">Silently drop it:<\/strong> callers receive an unexpected best-effort path and have to invent their own<br \/>\nenforcement loop.<\/li>\n<li data-hk=\"000000010000000000004000010b2470300\"><strong data-hk=\"000000010000000000004000010b247030100\">Pass it through blindly:<\/strong> provider side effects become product bugs; Anthropic, for example,<br \/>\ncan turn the forced call into a cache miss over the conversation.<\/li>\n<li data-hk=\"000000010000000000004000010b2470400\"><strong data-hk=\"000000010000000000004000010b247040100\">Do not expose it:<\/strong> informed callers hack around the library and recreate all three failure modes.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b24800\">An ideal harness implementation:<\/p>\n<ol data-hk=\"000000010000000000004000010b24900\">\n<li data-hk=\"000000010000000000004000010b2490100\">Always inject a soft prompt telling the model that it must invoke the tool on its next turn.<br \/>\nThis is worth doing unconditionally: hosted APIs like OpenAI quietly prepend this nudge for you,<br \/>\nbut open-source inference engines don&#8217;t, so a model behind vLLM gets a hard constraint it was<br \/>\nnever told about, and flails when reasoning is enabled. The soft prompt levels that field.<\/li>\n<li data-hk=\"000000010000000000004000010b2490200\">Set the native flag only when it&#8217;s free. If the provider supports forced tool calls without<br \/>\nside effects, pass it through. If it carries a penalty, skip the flag and rely on the soft prompt<br \/>\nalone.<\/li>\n<li data-hk=\"000000010000000000004000010b2490300\">Escalate on non-compliance. If the model doesn&#8217;t call the tool, retry a bounded number of<br \/>\ntimes; as a last resort, set the native flag even where it costs something. Correctness wins over<br \/>\nthe cache once persuasion has failed.<\/li>\n<\/ol>\n<figure data-hk=\"000000010000000000004000010b250\"><!--$--><\/p>\n<div data-hk=\"000000010000000000004000010b2510\" class=\"st-mermaid \" role=\"img\" aria-label=\"Flowchart of the forced-tool-call strategy: always inject a soft prompt telling the model it must call the tool; set the native tool_choice flag only when the provider supports forcing without side effects; if the model still does not call the tool, bounded retries escalate to setting the flag despite its cost before surfacing failure to the caller.\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" id=\"forced-tool-call-0\" width=\"100%\" class=\"flowchart\" style=\"max-width: 755.3125px;\" viewbox=\"0 0 755.3125 1275.621826171875\" role=\"graphics-document document\" aria-roledescription=\"flowchart-v2\"><g><marker id=\"forced-tool-call-0_flowchart-v2-pointEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-pointStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"4.5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-pointEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"11.5\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"10.5\" markerheight=\"14\" orient=\"auto\"><path d=\"M 0 0 L 11.5 7 L 0 14 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-pointStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"1\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"11.5\" markerheight=\"14\" orient=\"auto\"><polygon points=\"0,7 11.5,14 11.5,0\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-circleEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"11\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-circleStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-1\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-circleEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refy=\"5\" refx=\"12.25\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-circleStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-2\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-crossEnd\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"12\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-crossStart\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"-1\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-crossEnd-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"17.7\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5;\"\/><\/marker><marker id=\"forced-tool-call-0_flowchart-v2-crossStart-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"-3.5\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5; stroke-dasharray: 1, 0;\"\/><\/marker><g class=\"root\"><g class=\"clusters\"\/><g class=\"edgePaths\"><path d=\"M267.715,76L267.715,76L267.715,102L267.715,102L267.715,124\" id=\"forced-tool-call-0-L_A_B_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_A_B_0\" data-points=\"W3sieCI6MjY3LjcxNDg0Mzc1LCJ5Ijo3Nn0seyJ4IjoyNjcuNzE0ODQzNzUsInkiOjEwMn0seyJ4IjoyNjcuNzE0ODQzNzUsInkiOjEyOH1d\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M267.715,214L267.715,214L267.715,240L267.715,240L267.715,262\" id=\"forced-tool-call-0-L_B_C_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_B_C_0\" data-points=\"W3sieCI6MjY3LjcxNDg0Mzc1LCJ5IjoyMTR9LHsieCI6MjY3LjcxNDg0Mzc1LCJ5IjoyNDB9LHsieCI6MjY3LjcxNDg0Mzc1LCJ5IjoyNjZ9XQ==\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M293.308,430.813L318.012,430.813L318.012,498.006L355.931,498.006L355.931,536.748\" id=\"forced-tool-call-0-L_C_E_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_E_0\" data-points=\"W3sieCI6MjkzLjMwNzY4MDAyOTkxMTc1LCJ5Ijo0MzAuODEzNDEzNzIwMDg4MjV9LHsieCI6MzE4LjAxMTcxODc1LCJ5Ijo0OTguMDA2MjUwMzgxNDY5N30seyJ4IjozNTguNzI5MTQ2MTY2NTk3OTYsInkiOjUzOS42MDYyNTA3NjI5Mzk1fV0=\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M221.234,409.925L137.203,409.925L137.203,498.006L137.203,498.006L137.203,544.606\" id=\"forced-tool-call-0-L_C_D_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_D_0\" data-points=\"W3sieCI6MjIxLjIzMzYxMTA1MDQ0MTM3LCJ5Ijo0MDkuOTI1MDE3MzAwNDQxM30seyJ4IjoxMzcuMjAzMTI1LCJ5Ijo0OTguMDA2MjUwMzgxNDY5N30seyJ4IjoxMzcuMjAzMTI1LCJ5Ijo1NDguNjA2MjUwNzYyOTM5NX1d\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M322.881,401.24L456.211,401.24L456.211,498.006L423.471,498.006L423.471,536.557\" id=\"forced-tool-call-0-L_C_E_2\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_E_2\" data-points=\"W3sieCI6MzIyLjg4MDcyMjE3Nzg4NjIsInkiOjQwMS4yNDAzNzE1NzIxMTM3Nn0seyJ4Ijo0NTYuMjEwOTM3NSwieSI6NDk4LjAwNjI1MDM4MTQ2OTd9LHsieCI6NDIwLjg4MjIzMzY1MDU5ODk1LCJ5Ijo1MzkuNjA2MjUwNzYyOTM5NX1d\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M137.203,598.606L137.203,598.606L137.203,633.606L200.087,633.606L200.087,658.779\" id=\"forced-tool-call-0-L_D_F_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_D_F_0\" data-points=\"W3sieCI6MTM3LjIwMzEyNSwieSI6NTk4LjYwNjI1MDc2MjkzOTV9LHsieCI6MTM3LjIwMzEyNSwieSI6NjMzLjYwNjI1MDc2MjkzOTV9LHsieCI6MjAzLjgwMDc4MTI1LCJ5Ijo2NjAuMjY1NzMyNTk2NDUxN31d\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M392.008,607.606L392.008,607.606L392.008,633.606L329.124,633.606L329.124,658.779\" id=\"forced-tool-call-0-L_E_F_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_E_F_0\" data-points=\"W3sieCI6MzkyLjAwNzgxMjUsInkiOjYwNy42MDYyNTA3NjI5Mzk1fSx7IngiOjM5Mi4wMDc4MTI1LCJ5Ijo2MzMuNjA2MjUwNzYyOTM5NX0seyJ4IjozMjUuNDEwMTU2MjUsInkiOjY2MC4yNjU3MzI1OTY0NTE3fV0=\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M238.82,709.606L212.004,709.606L212.004,735.606L212.004,735.606L212.004,757.606\" id=\"forced-tool-call-0-L_F_G_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_F_G_0\" data-points=\"W3sieCI6MjM4LjgyMDM4OTA5MzEzNzI3LCJ5Ijo3MDkuNjA2MjUwNzYyOTM5NX0seyJ4IjoyMTIuMDAzOTA2MjUsInkiOjczNS42MDYyNTA3NjI5Mzk1fSx7IngiOjIxMi4wMDM5MDYyNSwieSI6NzYxLjYwNjI1MDc2MjkzOTV9XQ==\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M180.559,884.568L134.898,884.568L134.898,951.013L134.898,951.013L134.898,1028.817\" id=\"forced-tool-call-0-L_G_H_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_G_H_0\" data-points=\"W3sieCI6MTgwLjU1OTA0MTQxNzU1MDUsInkiOjg4NC41Njc2MzU5MzA0ODk5fSx7IngiOjEzNC44OTg0Mzc1LCJ5Ijo5NTEuMDEyNTAwNzYyOTM5NX0seyJ4IjoxMzQuODk4NDM3NSwieSI6MTAzMi44MTcxODgyNjI5Mzk1fV0=\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M243.449,884.568L289.109,884.568L289.109,951.013L289.109,951.013L289.109,982.013\" id=\"forced-tool-call-0-L_G_I_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_G_I_0\" data-points=\"W3sieCI6MjQzLjQ0ODc3MTA4MjQ0OTUsInkiOjg4NC41Njc2MzU5MzA0ODk4fSx7IngiOjI4OS4xMDkzNzUsInkiOjk1MS4wMTI1MDA3NjI5Mzk1fSx7IngiOjI4OS4xMDkzNzUsInkiOjk4Ni4wMTI1MDA3NjI5Mzk1fV0=\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M289.109,1129.622L289.109,1129.622L289.109,1164.622L313.366,1164.622L313.366,1196.441\" id=\"forced-tool-call-0-L_I_J_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_I_J_0\" data-points=\"W3sieCI6Mjg5LjEwOTM3NSwieSI6MTEyOS42MjE4NzU3NjI5Mzk1fSx7IngiOjI4OS4xMDkzNzUsInkiOjExNjQuNjIxODc1NzYyOTM5NX0seyJ4IjozMTUuNzkxMzI2OTkyNzUzNiwieSI6MTE5OS42MjE4NzU3NjI5Mzk1fV0=\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M404.389,1199.622L468.91,1199.622L468.91,1164.622L468.91,1164.622L468.91,1057.817L468.91,1057.817L468.91,951.013L468.91,951.013L468.91,838.809L468.91,838.809L468.91,735.606L329.291,735.606L329.291,700.754\" id=\"forced-tool-call-0-L_J_F_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_J_F_0\" data-points=\"W3sieCI6NDA0LjM4ODgxMzQwNTc5NzEsInkiOjExOTkuNjIxODc1NzYyOTM5NX0seyJ4Ijo0NjguOTEwMTU2MjUsInkiOjExNjQuNjIxODc1NzYyOTM5NX0seyJ4Ijo0NjguOTEwMTU2MjUsInkiOjEwNTcuODE3MTg4MjYyOTM5NX0seyJ4Ijo0NjguOTEwMTU2MjUsInkiOjk1MS4wMTI1MDA3NjI5Mzk1fSx7IngiOjQ2OC45MTAxNTYyNSwieSI6ODM4LjgwOTM3NTc2MjkzOTV9LHsieCI6NDY4LjkxMDE1NjI1LCJ5Ijo3MzUuNjA2MjUwNzYyOTM5NX0seyJ4IjozMjUuNDEwMTU2MjUsInkiOjY5OS43ODQ3NTI1NDEwNzQxfV0=\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><path d=\"M343.603,1075.129L625.313,1075.129L625.313,1164.622L625.313,1164.622L625.313,1204.622\" id=\"forced-tool-call-0-L_I_K_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_I_K_0\" data-points=\"W3sieCI6MzQzLjYwMjY4MTA5MDczMjc0LCJ5IjoxMDc1LjEyODU2OTY3MjIwNjh9LHsieCI6NjI1LjMxMjUsInkiOjExNjQuNjIxODc1NzYyOTM5NX0seyJ4Ijo2MjUuMzEyNSwieSI6MTIwOC42MjE4NzU3NjI5Mzk1fV0=\" data-look=\"classic\" marker-end=\"url(#forced-tool-call-0_flowchart-v2-pointEnd)\"\/><\/g><g class=\"edgeLabels\"><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_A_B_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_B_C_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\" transform=\"translate(318.01171875, 498.0062503814697)\"><g class=\"label\" data-id=\"L_C_E_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-9.203125\" y=\"-0.9999990463256836\" width=\"18.40625\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">No<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(137.203125, 498.0062503814697)\"><g class=\"label\" data-id=\"L_C_D_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-77.609375\" y=\"-0.9999990463256836\" width=\"155.21875\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Yes,<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> side-effect<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> free<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(456.2109375, 498.0062503814697)\"><g class=\"label\" data-id=\"L_C_E_2\" transform=\"translate(0, -14.600001335144043)\"><g><rect class=\"background\" style=\"\" x=\"-99.203125\" y=\"-0.9999990463256836\" width=\"198.40625\" height=\"31.200000762939453\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Yes,<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> but<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> costly<\/tspan><\/tspan><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">(e.g.<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> Anthropic<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> cache<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> miss)<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_D_F_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_E_F_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_F_G_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\" transform=\"translate(134.8984375, 951.0125007629395)\"><g class=\"label\" data-id=\"L_G_H_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-12.8046875\" y=\"-0.9999990463256836\" width=\"25.609375\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Yes<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(289.109375, 951.0125007629395)\"><g class=\"label\" data-id=\"L_G_I_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-9.203125\" y=\"-0.9999990463256836\" width=\"18.40625\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">No<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(289.109375, 1164.6218757629395)\"><g class=\"label\" data-id=\"L_I_J_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-12.8046875\" y=\"-0.9999990463256836\" width=\"25.609375\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Yes<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_J_F_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\" transform=\"translate(625.3125, 1164.6218757629395)\"><g class=\"label\" data-id=\"L_I_K_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-9.203125\" y=\"-0.9999990463256836\" width=\"18.40625\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">No<\/tspan><\/tspan><\/text><\/g><\/g><\/g><\/g><g class=\"nodes\"><g class=\"node default\" id=\"forced-tool-call-0-flowchart-A-0\" data-look=\"classic\" transform=\"translate(267.71484375, 42)\"><rect class=\"basic label-container\" style=\"\" x=\"-132\" y=\"-34\" width=\"264\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -18)\"><rect\/><foreignobject width=\"200\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>Extension requests forced tool call<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-B-1\" data-look=\"classic\" transform=\"translate(267.71484375, 171)\"><rect class=\"basic label-container\" style=\"\" x=\"-132\" y=\"-43\" width=\"264\" height=\"86\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -27)\"><rect\/><foreignobject width=\"200\" height=\"54\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>Inject soft prompt:<br \/>&#8220;you must call tool X next turn&#8221;<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-C-3\" data-look=\"classic\" transform=\"translate(267.71484375, 361.203125)\"><polygon points=\"95.203125,0 190.40625,-95.203125 95.203125,-190.40625 0,-95.203125\" class=\"label-container\" transform=\"translate(-94.703125, 95.203125)\"\/><g class=\"label\" style=\"\" transform=\"translate(-61.203125, -18)\"><rect\/><foreignobject width=\"122.40625\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Provider supports<br \/>native forcing?<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-E-5\" data-look=\"classic\" transform=\"translate(392.0078125, 573.6062507629395)\"><rect class=\"basic label-container\" style=\"\" x=\"-89.6015625\" y=\"-34\" width=\"179.203125\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-57.6015625, -18)\"><rect\/><foreignobject width=\"115.203125\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Run turn with<br \/>soft prompt only<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-D-7\" data-look=\"classic\" transform=\"translate(137.203125, 573.6062507629395)\"><rect class=\"basic label-container\" style=\"\" x=\"-129.203125\" y=\"-25\" width=\"258.40625\" height=\"50\"\/><g class=\"label\" style=\"\" transform=\"translate(-97.203125, -9)\"><rect\/><foreignobject width=\"194.40625\" height=\"18\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Set native tool_choice flag<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-F-11\" data-look=\"classic\" transform=\"translate(264.60546875, 684.6062507629395)\"><rect class=\"basic label-container\" style=\"\" x=\"-60.8046875\" y=\"-25\" width=\"121.609375\" height=\"50\"\/><g class=\"label\" style=\"\" transform=\"translate(-28.8046875, -9)\"><rect\/><foreignobject width=\"57.609375\" height=\"18\"\/><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-G-15\" data-look=\"classic\" transform=\"translate(212.00390625, 838.8093757629395)\"><polygon points=\"77.203125,0 154.40625,-77.203125 77.203125,-154.40625 0,-77.203125\" class=\"label-container\" transform=\"translate(-76.703125, 77.203125)\"\/><g class=\"label\" style=\"\" transform=\"translate(-43.203125, -18)\"><rect\/><foreignobject width=\"86.40625\" height=\"36\"\/><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-H-17\" data-look=\"classic\" transform=\"translate(134.8984375, 1057.8171882629395)\"><rect class=\"basic label-container\" style=\"\" x=\"-46.40625\" y=\"-25\" width=\"92.8125\" height=\"50\"\/><g class=\"label\" style=\"\" transform=\"translate(-14.40625, -9)\"><rect\/><foreignobject width=\"28.8125\" height=\"18\"\/><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-I-19\" data-look=\"classic\" transform=\"translate(289.109375, 1057.8171882629395)\"><polygon points=\"71.8046875,0 143.609375,-71.8046875 71.8046875,-143.609375 0,-71.8046875\" class=\"label-container\" transform=\"translate(-71.3046875, 71.8046875)\"\/><g class=\"label\" style=\"\" transform=\"translate(-46.8046875, -9)\"><rect\/><foreignobject width=\"93.609375\" height=\"18\"\/><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-J-21\" data-look=\"classic\" transform=\"translate(341.7109375, 1233.6218757629395)\"><rect class=\"basic label-container\" style=\"\" x=\"-125.6015625\" y=\"-34\" width=\"251.203125\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-93.6015625, -18)\"><rect\/><foreignobject width=\"187.203125\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Retry \u2014 escalate:<br \/>set flag despite drawbacks<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"forced-tool-call-0-flowchart-K-25\" data-look=\"classic\" transform=\"translate(625.3125, 1233.6218757629395)\"><rect class=\"basic label-container\" style=\"\" x=\"-122\" y=\"-25\" width=\"244\" height=\"50\"\/><g class=\"label\" style=\"\" transform=\"translate(-90, -9)\"><rect\/><foreignobject width=\"180\" height=\"18\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Surface failure to caller<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><\/g><\/g><\/g><defs><filter id=\"forced-tool-call-0-drop-shadow\" height=\"130%\" width=\"130%\"><fedropshadow dx=\"4\" dy=\"4\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><defs><filter id=\"forced-tool-call-0-drop-shadow-small\" height=\"150%\" width=\"150%\"><fedropshadow dx=\"2\" dy=\"2\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><lineargradient id=\"forced-tool-call-0-gradient\" gradientunits=\"objectBoundingBox\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"><stop offset=\"0%\" stop-color=\"#2A2A35\" stop-opacity=\"1\"\/><stop offset=\"100%\" stop-color=\"#44CFFF\" stop-opacity=\"1\"\/><\/lineargradient><\/svg><\/div>\n<p><!--\/--><figcaption>The forced call starts as a soft prompt; the native flag goes on only when the provider supports it without side effects, and if the model still doesn&#8217;t call the tool, bounded retries escalate to setting the flag despite its cost before surfacing failure to the caller.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b25200\">This is the provider-side implementation of the Director from the previous chapter. <code data-hk=\"000000010000000000004000010b2520100\">ForceTool<\/code><br \/>\nstates the invariant; inference chooses the cheapest honest way to satisfy it and escalates when the<br \/>\nmodel does not comply.<\/p>\n<h3 data-hk=\"000000010000000000004000010b25300\" id=\"tool-schemas-are-model-facing-protocols\">Tool schemas are model-facing protocols<\/h3>\n<p data-hk=\"000000010000000000004000010b25400\">A tool&#8217;s <code data-hk=\"000000010000000000004000010b2540100\">parameters<\/code> field strictly defines its argument shape. That would be ideal for a human API;<br \/>\nmodels are not generic API clients. Their mistakes are often specific to the tool name and the<br \/>\nharnesses represented in training.<\/p>\n<p data-hk=\"000000010000000000004000010b25500\">RL-maxxed agents may call a familiar tool using another harness&#8217;s schema. Composer models sometimes<br \/>\nemit <code data-hk=\"000000010000000000004000010b2550100\">Grep<\/code> with their expected shape even when no <code data-hk=\"000000010000000000004000010b2550200\">Grep<\/code> tool exists. Codex may see<br \/>\n<code data-hk=\"000000010000000000004000010b2550300\">paths: string[]<\/code> and send one string delimited by <code data-hk=\"000000010000000000004000010b2550400\">;<\/code> or <code data-hk=\"000000010000000000004000010b2550500\">,<\/code>, according to the mood of the day.<\/p>\n<p data-hk=\"000000010000000000004000010b25600\">The library should therefore validate <strong data-hk=\"000000010000000000004000010b2560100\">and<\/strong> correct. Be strict about the tool&#8217;s semantic contract,<br \/>\nbut charitable about the model&#8217;s dialect: repair <code data-hk=\"000000010000000000004000010b2560200\">paths: \"a,b\"<\/code> into a list when the mapping is<br \/>\nunambiguous; otherwise return a structured, retryable error. A raw JSON Schema validator cannot own<br \/>\nthis layer by itself.<\/p>\n<h3 data-hk=\"000000010000000000004000010b25700\" id=\"strict-sampling-needs-budgets-and-dialects\">Strict sampling needs budgets and dialects<\/h3>\n<p data-hk=\"000000010000000000004000010b25800\">Constrained sampling was one of the first features we added to Pi:<\/p>\n<pre data-hk=\"000000010000000000004000010b25900\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b2590100\"><span data-hk=\"000000010000000000004000010b259010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b25901010100\" style=\"color:#44CFFF\">+   strict?: boolean;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b259010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b25901020100\" style=\"color:#44CFFF\">+   customFormat?: { syntax: \"lark\" | \"regex\"; definition: string };<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b259010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b25901030100\" style=\"color:#44CFFF\">+   customWireName?: string;<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b26000\">Pi followed a few months later with LARK and strict support, but exposed it as an opaque structure<br \/>\nfor the provider layer to pass through. Two system-wide constraints make that insufficient:<\/p>\n<ol data-hk=\"000000010000000000004000010b26100\">\n<li data-hk=\"000000010000000000004000010b2610100\"><strong data-hk=\"000000010000000000004000010b261010100\">Strict-schema capacity is a shared budget.<\/strong> Many providers cap the number of strict schemas.<br \/>\nEnough independently authored extensions can therefore make the provider reject every request.<br \/>\nThe user should not have to binary-search and patch plugins to recover the harness.<\/li>\n<li data-hk=\"000000010000000000004000010b2610200\"><strong data-hk=\"000000010000000000004000010b261020100\">Grammar dialect is provider-specific.<\/strong> Passing a LARK grammar to every provider can itself be<br \/>\ninvalid. An extension cannot maintain the compatibility map because users may route the same<br \/>\nmodel through native hosts, proxies, or custom providers.<\/li>\n<\/ol>\n<p data-hk=\"000000010000000000004000010b26200\">That is why the apparently \u201ccomplicated\u201d implementation belongs in the inference layer:<\/p>\n<figure data-hk=\"000000010000000000004000010b263\"><!--$--><\/p>\n<div data-hk=\"000000010000000000004000010b2640\" class=\"st-mermaid \" role=\"img\" aria-label=\"Flowchart of constrained-sampling handling: an extension declares a tool strict; if the provider lacks grammar enforcement or the strict-schema budget is exhausted, ship JSON Schema only with charitable client-side repair; otherwise normalize the schema per provider dialect and inject the grammar on the wire; invalid output is repaired client-side and surfaced to the model as a structured error for a retry.\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" id=\"constrained-sampling-0\" width=\"100%\" class=\"flowchart\" style=\"max-width: 542px;\" viewbox=\"0 0 542 1458.015625\" role=\"graphics-document document\" aria-roledescription=\"flowchart-v2\"><g><marker id=\"constrained-sampling-0_flowchart-v2-pointEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-pointStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"4.5\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"8\" markerheight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-pointEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"11.5\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"10.5\" markerheight=\"14\" orient=\"auto\"><path d=\"M 0 0 L 11.5 7 L 0 14 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-pointStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 11.5 14\" refx=\"1\" refy=\"7\" markerunits=\"userSpaceOnUse\" markerwidth=\"11.5\" markerheight=\"14\" orient=\"auto\"><polygon points=\"0,7 11.5,14 11.5,0\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-circleEnd\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"11\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-circleStart\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-1\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-circleEnd-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refy=\"5\" refx=\"12.25\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-circleStart-margin\" class=\"marker flowchart-v2\" viewbox=\"0 0 10 10\" refx=\"-2\" refy=\"5\" markerunits=\"userSpaceOnUse\" markerwidth=\"14\" markerheight=\"14\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 0; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-crossEnd\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"12\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-crossStart\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 11 11\" refx=\"-1\" refy=\"5.2\" markerunits=\"userSpaceOnUse\" markerwidth=\"11\" markerheight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-crossEnd-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"17.7\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5;\"\/><\/marker><marker id=\"constrained-sampling-0_flowchart-v2-crossStart-margin\" class=\"marker cross flowchart-v2\" viewbox=\"0 0 15 15\" refx=\"-3.5\" refy=\"7.5\" markerunits=\"userSpaceOnUse\" markerwidth=\"12\" markerheight=\"12\" orient=\"auto\"><path d=\"M 1,1 L 14,14 M 1,14 L 14,1\" class=\"arrowMarkerPath\" style=\"stroke-width: 2.5; stroke-dasharray: 1, 0;\"\/><\/marker><g class=\"root\"><g class=\"clusters\"\/><g class=\"edgePaths\"><path d=\"M276,76L276,76L276,102L276,102L276,124\" id=\"constrained-sampling-0-L_A_B_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_A_B_0\" data-points=\"W3sieCI6Mjc2LCJ5Ijo3Nn0seyJ4IjoyNzYsInkiOjEwMn0seyJ4IjoyNzYsInkiOjEyOH1d\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M221.255,285.255L125.398,285.255L125.398,375L125.398,375L125.398,496.203L125.398,496.203L125.398,617.406L130.611,617.406L130.611,648.461\" id=\"constrained-sampling-0-L_B_G_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_B_G_0\" data-points=\"W3sieCI6MjIxLjI1NDg2OTM5MDQ4ODk1LCJ5IjoyODUuMjU0ODY5MzkwNDg4OX0seyJ4IjoxMjUuMzk4NDM3NSwieSI6Mzc1fSx7IngiOjEyNS4zOTg0Mzc1LCJ5Ijo0OTYuMjAzMTI1fSx7IngiOjEyNS4zOTg0Mzc1LCJ5Ijo2MTcuNDA2MjV9LHsieCI6MTMxLjI3MjYyOTMxMDM0NDgzLCJ5Ijo2NTIuNDA2MjV9XQ==\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M314.612,301.388L356.789,301.388L356.789,375L356.789,375L356.789,406\" id=\"constrained-sampling-0-L_B_C_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_B_C_0\" data-points=\"W3sieCI6MzE0LjYxMTY0NTM1NTU5NTUsInkiOjMwMS4zODgzNTQ2NDQ0MDQ1fSx7IngiOjM1Ni43ODkwNjI1LCJ5IjozNzV9LHsieCI6MzU2Ljc4OTA2MjUsInkiOjQxMH1d\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M311.208,536.825L220.789,536.825L220.789,617.406L191.01,617.406L191.01,649.475\" id=\"constrained-sampling-0-L_C_G_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_G_0\" data-points=\"W3sieCI6MzExLjIwNzg3MDU5MTg1MzQ2LCJ5Ijo1MzYuODI1MDU4MDkxODUzNX0seyJ4IjoyMjAuNzg5MDYyNSwieSI6NjE3LjQwNjI1fSx7IngiOjE4OC4yODc3MTU1MTcyNDE0LCJ5Ijo2NTIuNDA2MjV9XQ==\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M383.767,555.428L412,555.428L412,617.406L412,617.406L412,666.406\" id=\"constrained-sampling-0-L_C_D_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_D_0\" data-points=\"W3sieCI6MzgzLjc2NzM4NDI5MTU1MDQsInkiOjU1NS40Mjc5MjgyMDg0NDk1fSx7IngiOjQxMiwieSI6NjE3LjQwNjI1fSx7IngiOjQxMiwieSI6NjcwLjQwNjI1fV0=\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M412,738.406L412,738.406L412,782.406L412,782.406L412,804.406\" id=\"constrained-sampling-0-L_D_E_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_D_E_0\" data-points=\"W3sieCI6NDEyLCJ5Ijo3MzguNDA2MjV9LHsieCI6NDEyLCJ5Ijo3ODIuNDA2MjV9LHsieCI6NDEyLCJ5Ijo4MDguNDA2MjV9XQ==\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M412,876.406L412,876.406L412,902.406L340.55,902.406L340.55,929.2\" id=\"constrained-sampling-0-L_E_F_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_E_F_0\" data-points=\"W3sieCI6NDEyLCJ5Ijo4NzYuNDA2MjV9LHsieCI6NDEyLCJ5Ijo5MDIuNDA2MjV9LHsieCI6MzM2LjgwNDY4NzUsInkiOjkzMC42MDQ0OTIxODc1fV0=\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M140,756.406L140,756.406L140,782.406L140,782.406L140,842.406L140,842.406L140,902.406L211.45,902.406L211.45,929.2\" id=\"constrained-sampling-0-L_G_F_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_G_F_0\" data-points=\"W3sieCI6MTQwLCJ5Ijo3NTYuNDA2MjV9LHsieCI6MTQwLCJ5Ijo3ODIuNDA2MjV9LHsieCI6MTQwLCJ5Ijo4NDIuNDA2MjV9LHsieCI6MTQwLCJ5Ijo5MDIuNDA2MjV9LHsieCI6MjE1LjE5NTMxMjUsInkiOjkzMC42MDQ0OTIxODc1fV0=\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M276,978.406L276,978.406L276,1004.406L276,1004.406L276,1026.406\" id=\"constrained-sampling-0-L_F_H_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_F_H_0\" data-points=\"W3sieCI6Mjc2LCJ5Ijo5NzguNDA2MjV9LHsieCI6Mjc2LCJ5IjoxMDA0LjQwNjI1fSx7IngiOjI3NiwieSI6MTAzMC40MDYyNX1d\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M241.206,1139.222L175.594,1139.222L175.594,1209.016L175.594,1209.016L175.594,1258.016\" id=\"constrained-sampling-0-L_H_I_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_H_I_0\" data-points=\"W3sieCI6MjQxLjIwNjI3OTY5MTIxMTQsInkiOjExMzkuMjIxOTA0NjkxMjExNH0seyJ4IjoxNzUuNTkzNzUsInkiOjEyMDkuMDE1NjI1fSx7IngiOjE3NS41OTM3NSwieSI6MTI2Mi4wMTU2MjV9XQ==\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M310.794,1139.222L376.406,1139.222L376.406,1209.016L376.406,1209.016L376.406,1240.016\" id=\"constrained-sampling-0-L_H_J_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_H_J_0\" data-points=\"W3sieCI6MzEwLjc5MzcyMDMwODc4ODYsInkiOjExMzkuMjIxOTA0NjkxMjExNH0seyJ4IjozNzYuNDA2MjUsInkiOjEyMDkuMDE1NjI1fSx7IngiOjM3Ni40MDYyNSwieSI6MTI0NC4wMTU2MjV9XQ==\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><path d=\"M376.406,1330.016L376.406,1330.016L376.406,1356.016L376.406,1356.016L376.406,1378.016\" id=\"constrained-sampling-0-L_J_K_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_J_K_0\" data-points=\"W3sieCI6Mzc2LjQwNjI1LCJ5IjoxMzMwLjAxNTYyNX0seyJ4IjozNzYuNDA2MjUsInkiOjEzNTYuMDE1NjI1fSx7IngiOjM3Ni40MDYyNSwieSI6MTM4Mi4wMTU2MjV9XQ==\" data-look=\"classic\" marker-end=\"url(#constrained-sampling-0_flowchart-v2-pointEnd)\"\/><\/g><g class=\"edgeLabels\"><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_A_B_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\" transform=\"translate(125.3984375, 496.203125)\"><g class=\"label\" data-id=\"L_B_G_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-9.203125\" y=\"-0.9999990463256836\" width=\"18.40625\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">No<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(356.7890625, 375)\"><g class=\"label\" data-id=\"L_B_C_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-12.8046875\" y=\"-0.9999990463256836\" width=\"25.609375\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Yes<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(220.7890625, 617.40625)\"><g class=\"label\" data-id=\"L_C_G_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-9.203125\" y=\"-0.9999990463256836\" width=\"18.40625\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">No<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(412, 617.40625)\"><g class=\"label\" data-id=\"L_C_D_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-81.21875\" y=\"-0.9999990463256836\" width=\"162.4375\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Yes,<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> and<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> priority<\/tspan><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\"> wins<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_D_E_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_E_F_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_G_F_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_F_H_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><g class=\"edgeLabel\" transform=\"translate(175.59375, 1209.015625)\"><g class=\"label\" data-id=\"L_H_I_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-12.8046875\" y=\"-0.9999990463256836\" width=\"25.609375\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">Yes<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\" transform=\"translate(376.40625, 1209.015625)\"><g class=\"label\" data-id=\"L_H_J_0\" transform=\"translate(0, -8.000000953674316)\"><g><rect class=\"background\" style=\"\" x=\"-9.203125\" y=\"-0.9999990463256836\" width=\"18.40625\" height=\"18\"\/><text y=\"-10.1\" text-anchor=\"middle\" style=\"\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"><tspan font-style=\"normal\" class=\"text-inner-tspan\" font-weight=\"normal\">No<\/tspan><\/tspan><\/text><\/g><\/g><\/g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_J_K_0\" transform=\"translate(0, 0)\"><text y=\"-10.1\" text-anchor=\"middle\"><tspan class=\"text-outer-tspan row\" x=\"0\" y=\"-0.1em\" dy=\"1.1em\" text-anchor=\"middle\"\/><\/text><\/g><\/g><g><rect class=\"background\" style=\"stroke: none\"\/><\/g><\/g><g class=\"nodes\"><g class=\"node default\" id=\"constrained-sampling-0-flowchart-A-0\" data-look=\"classic\" transform=\"translate(276, 42)\"><rect class=\"basic label-container\" style=\"\" x=\"-132\" y=\"-34\" width=\"264\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -18)\"><rect\/><foreignobject width=\"200\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>Extension declares tool as strict<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-B-1\" data-look=\"classic\" transform=\"translate(276, 234)\"><polygon points=\"106,0 212,-106 106,-212 0,-106\" class=\"label-container\" transform=\"translate(-105.5, 106)\"\/><g class=\"label\" style=\"\" transform=\"translate(-72, -18)\"><rect\/><foreignobject width=\"144\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Provider supports<br \/>grammar enforcement?<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-G-3\" data-look=\"classic\" transform=\"translate(140, 704.40625)\"><rect class=\"basic label-container\" style=\"\" x=\"-132\" y=\"-52\" width=\"264\" height=\"104\"\/><g class=\"label\" style=\"\" transform=\"translate(-100, -36)\"><rect\/><foreignobject width=\"200\" height=\"72\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><\/p>\n<p>Ship JSON Schema only;<br \/>unconstrained sampling +<br \/>charitable client-side repair<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-C-5\" data-look=\"classic\" transform=\"translate(356.7890625, 496.203125)\"><polygon points=\"86.203125,0 172.40625,-86.203125 86.203125,-172.40625 0,-86.203125\" class=\"label-container\" transform=\"translate(-85.703125, 86.203125)\"\/><g class=\"label\" style=\"\" transform=\"translate(-61.203125, -9)\"><rect\/><foreignobject width=\"122.40625\" height=\"18\"\/><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-D-9\" data-look=\"classic\" transform=\"translate(412, 704.40625)\"><rect class=\"basic label-container\" style=\"\" x=\"-104\" y=\"-34\" width=\"208\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-72, -18)\"><rect\/><foreignobject width=\"144\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Normalize schema<br \/>per provider dialect<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-E-11\" data-look=\"classic\" transform=\"translate(412, 842.40625)\"><rect class=\"basic label-container\" style=\"\" x=\"-122\" y=\"-34\" width=\"244\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-90, -18)\"><rect\/><foreignobject width=\"180\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Inject grammar constraint<br \/>on the wire<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-F-13\" data-look=\"classic\" transform=\"translate(276, 953.40625)\"><rect class=\"basic label-container\" style=\"\" x=\"-60.8046875\" y=\"-25\" width=\"121.609375\" height=\"50\"\/><g class=\"label\" style=\"\" transform=\"translate(-28.8046875, -9)\"><rect\/><foreignobject width=\"57.609375\" height=\"18\"\/><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-H-17\" data-look=\"classic\" transform=\"translate(276, 1102.2109375)\"><polygon points=\"71.8046875,0 143.609375,-71.8046875 71.8046875,-143.609375 0,-71.8046875\" class=\"label-container\" transform=\"translate(-71.3046875, 71.8046875)\"\/><g class=\"label\" style=\"\" transform=\"translate(-46.8046875, -9)\"><rect\/><foreignobject width=\"93.609375\" height=\"18\"\/><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-I-19\" data-look=\"classic\" transform=\"translate(175.59375, 1287.015625)\"><rect class=\"basic label-container\" style=\"\" x=\"-46.40625\" y=\"-25\" width=\"92.8125\" height=\"50\"\/><g class=\"label\" style=\"\" transform=\"translate(-14.40625, -9)\"><rect\/><foreignobject width=\"28.8125\" height=\"18\"\/><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-J-21\" data-look=\"classic\" transform=\"translate(376.40625, 1287.015625)\"><rect class=\"basic label-container\" style=\"\" x=\"-118.40625\" y=\"-43\" width=\"236.8125\" height=\"86\"\/><g class=\"label\" style=\"\" transform=\"translate(-86.40625, -27)\"><rect\/><foreignobject width=\"172.8125\" height=\"54\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Repair client-side,<br \/>surface structured error<br \/>to model<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><g class=\"node default\" id=\"constrained-sampling-0-flowchart-K-23\" data-look=\"classic\" transform=\"translate(376.40625, 1416.015625)\"><rect class=\"basic label-container\" style=\"\" x=\"-96.8046875\" y=\"-34\" width=\"193.609375\" height=\"68\"\/><g class=\"label\" style=\"\" transform=\"translate(-64.8046875, -18)\"><rect\/><foreignobject width=\"129.609375\" height=\"36\"><\/p>\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><\/p>\n<p>Model retries with<br \/>correction signal<\/p>\n<p><\/span><\/div>\n<p><\/foreignobject><\/g><\/g><\/g><\/g><\/g><defs><filter id=\"constrained-sampling-0-drop-shadow\" height=\"130%\" width=\"130%\"><fedropshadow dx=\"4\" dy=\"4\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><defs><filter id=\"constrained-sampling-0-drop-shadow-small\" height=\"150%\" width=\"150%\"><fedropshadow dx=\"2\" dy=\"2\" stddeviation=\"0\" flood-opacity=\"0.06\" flood-color=\"#000000\"\/><\/filter><\/defs><lineargradient id=\"constrained-sampling-0-gradient\" gradientunits=\"objectBoundingBox\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"><stop offset=\"0%\" stop-color=\"#2A2A35\" stop-opacity=\"1\"\/><stop offset=\"100%\" stop-color=\"#44CFFF\" stop-opacity=\"1\"\/><\/lineargradient><\/svg><\/div>\n<p><!--\/--><figcaption>What honoring <!--$--><code data-hk=\"000000010000000000004000010b26500\">strict<\/code><!--\/--> actually takes: provider capability, a strict-schema budget with priorities, per-dialect normalization, and a client-side repair path\u2014none of which an opaque pass-through struct can provide.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b26600\">The extension declares intent\u2014strictness, grammar, priority. The inference layer owns capability,<br \/>\nbudgets, dialect normalization, fallback, repair, and the final wire format.<\/p>\n<h3 data-hk=\"000000010000000000004000010b26700\" id=\"corrective-inference\">Corrective inference<\/h3>\n<p data-hk=\"000000010000000000004000010b26800\">Inference libraries also need to:<\/p>\n<ol data-hk=\"000000010000000000004000010b26900\">\n<li data-hk=\"000000010000000000004000010b2690100\">repair malformed JSON;<\/li>\n<li data-hk=\"000000010000000000004000010b2690200\">detect repetition loops in models such as Gemini and DeepSeek;<\/li>\n<li data-hk=\"000000010000000000004000010b2690300\">parse each model&#8217;s output dialect and synthesize canonical <code data-hk=\"000000010000000000004000010b269030100\">tool_call<\/code> and <code data-hk=\"000000010000000000004000010b269030200\">think<\/code> blocks when<br \/>\nstructured output leaks into text.<\/li>\n<\/ol>\n<figure data-hk=\"000000010000000000004000010b270\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/leaked-toolcall-wild.png\" width=\"807\" height=\"374\" alt=\"A leaked tool call rendered as prose in a chat transcript because the model's dialect was not parsed into a tool_call block\" loading=\"lazy\"\/><figcaption>A leaked tool call rendered as prose because the dialect was not parsed into a tool_call block.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b27100\">You can read my <a data-hk=\"000000010000000000004000010b2710100\" href=\"https:\/\/blog.can.ac\/2026\/08\/03\/the-minutiae-of-tool-calling\/\">prior post<\/a> about the<br \/>\ntool-calling side of this subject. Supporting a provider or model requires handling its individual<br \/>\nquirks alongside wiring up a URL.<\/p>\n<p data-hk=\"000000010000000000004000010b27200\">A provider adapter is not complete when it can open a stream. It is complete when the rest of the<br \/>\nharness receives one canonical turn despite malformed JSON, repetition, leaked reasoning, or a<br \/>\nmodel-specific tool-call dialect.<\/p>\n<h3 data-hk=\"000000010000000000004000010b27300\" id=\"compaction-is-scheduled-not-triggered\">Compaction is scheduled, not triggered<\/h3>\n<aside data-hk=\"000000010000000000004000010b2740\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Start the summary before the limit, from a journal snapshot; at the limit, commit it only if the snapshot still describes the branch.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b27410\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b27500\">The naive design turns out to also offers the worst UX here.The user waits for the largest request of the session at the exact moment they are most invested.<\/p>\n<p data-hk=\"000000010000000000004000010b27600\">Beyond using methods like <strong data-hk=\"000000010000000000004000010b2760100\"><a data-hk=\"000000010000000000004000010b276010100\" href=\"https:\/\/stencil.so\/blog\/snapcompact\">Snapcompact<\/a><\/strong> there is still a lot of room for improvement here.<\/p>\n<figure data-hk=\"000000010000000000004000010b277\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/compaction-wait.png\" width=\"560\" height=\"55\" alt=\"Claude's chat interface showing a spinner, a 43% progress bar, and the text: Compacting our conversation so we can keep chatting. This takes about 1-2 minutes.\" loading=\"lazy\"\/><figcaption>Even the frontier lab ships the naive design.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b27800\">What one should do instead is, speculatively kick-off the compaction process ~10% before the limit is reached. You essentially make the conversation branch into<br \/>\ntwo concurrent versions, one where the user, and the model, continue working; the other where the model is compacting the conversation.<\/p>\n<figure data-hk=\"000000010000000000004000010b279\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/compaction-async.png\" width=\"977\" height=\"77\" alt=\"omp's status line: model GPT-5.6-Sol, working directory pi, git branch main, and a context gauge at 3% of a 1M window with two tick marks placed short of the limit.\" loading=\"lazy\"\/><figcaption>See the layer icon showing when the speculative compaction triggers?<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b28000\">Once you receive the response, you then splice it inside the other branch, which also lets you preserve the momentum of the work as the model will not get confused by a handoff<br \/>\nmessage standing as the only message in the history, but instead, will see all the progress it <em data-hk=\"000000010000000000004000010b2800100\">should<\/em> have done anyway.<\/p>\n<p data-hk=\"000000010000000000004000010b28100\">Beyond the prompt, other methods worth considering include:<\/p>\n<ul data-hk=\"000000010000000000004000010b28200\">\n<li data-hk=\"000000010000000000004000010b2820100\"><strong data-hk=\"000000010000000000004000010b282010100\">Remote compaction<\/strong>: The provider doing it server-side. OpenAI&#8217;s API returns an opaque state<br \/>\nblob as a result, but since it has access to decrypted thinking, it can significantly improve the loss of context.<\/li>\n<li data-hk=\"000000010000000000004000010b2820200\"><strong data-hk=\"000000010000000000004000010b282020100\">Handoff<\/strong>: Instead of asking for a summary, try asking the model to &#8220;handoff&#8221; the work instead.<\/li>\n<li data-hk=\"000000010000000000004000010b2820300\"><strong data-hk=\"000000010000000000004000010b282030100\">Shake<\/strong>: Completely local, you can simply trim the heavy tool results from the history.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b28300\">Note that this is also something you should consider in your UI rendering vs. request rendering abstraction, as the user would expect all messages to remain as they are when looking at the history, but for the<br \/>\nmodel, none of those messages will exist; hence you should model each entry in the prompt history as a &#8220;fold&#8221; when creating the request <code data-hk=\"000000010000000000004000010b2830100\">fn(this, req) -&gt; req<\/code>, handling it within the <code data-hk=\"000000010000000000004000010b2830200\">&lt;Handoff&gt;<\/code> implementation of it.<\/p>\n<h3 data-hk=\"000000010000000000004000010b28400\" id=\"use-small-local-models-for-harness-work\">Use small local models for harness work<\/h3>\n<p data-hk=\"000000010000000000004000010b28500\">Tiny local models are super useful! Even if you really only work with the frontier models, I<br \/>\nrecommend you implement some embedded <code data-hk=\"000000010000000000004000010b2850100\">tiny<\/code> model (esp. check out LiquidAI models) as this will<br \/>\nsave you a lot of latency+money for classification tasks, as well as small tasks like generating a<br \/>\ntitle, translation, or judging how happy the user is with the way the conversation is going.<br \/>\nAnother use case of course is TTS\/STT where you can already get SoTA performance locally.<\/p>\n<p data-hk=\"000000010000000000004000010b28600\">This is not a second \u201cagent.\u201d It is a cheap internal capability for small tasks that should not<br \/>\npay frontier latency or cost.<\/p>\n<p data-hk=\"000000010000000000004000010b28700\">Once compatibility and repair are centralized, the permanent tool surface can stay small. The next<br \/>\nchapter is about what deserves a schema on every request\u2014and what emphatically does not.<\/p>\n<aside data-hk=\"000000010000000000004000010b2890\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Every permanent tool taxes every turn; keep the roster small and make its primitives deep.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b28910\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b29000\">The runtime chapter defined how work executes. The inference chapter defined how schemas survive<br \/>\nmodels and providers. We can finally ask the product question: which operations deserve to occupy<br \/>\nthe model&#8217;s permanent grammar?<\/p>\n<h3 data-hk=\"000000010000000000004000010b29100\" id=\"every-schema-has-a-tax\">Every schema has a tax<\/h3>\n<p data-hk=\"000000010000000000004000010b29200\">The best way to present most tools to the model is to <strong data-hk=\"000000010000000000004000010b2920100\">not put them in the permanent tool roster at all<\/strong>.<\/p>\n<p data-hk=\"000000010000000000004000010b29300\">A while back, I got a complaint about how omp was slower than codex on the same task, not token<br \/>\nwise, but when you measure wall-clock. I fully expected this to be a nothing-burger, but to my<br \/>\nsurprise, it was true, almost two times even!<\/p>\n<figure data-hk=\"000000010000000000004000010b294\"><!--$--><svg data-hk=\"000000010000000000004000010b2950\" viewbox=\"0 0 720 406\" role=\"img\" aria-label=\"Median wall time and prefix size for six harness variants: omp stock with no fixes runs 86.2s at 25.1k tokens, dropping to 59.5s after a todo-batching fix, 45.4s after the \/xdev rewrite cuts wire tool defs from 23 to 15, and 36.6s at a lean 5-tool floor; codex-cli and pi references sit near 42.2s and 37.0s\" style=\"width:100%;height:auto;font-family:'BerkeleyMono Nerd Font', 'Berkeley Mono', ui-monospace, monospace\"><rect x=\"196\" y=\"10\" width=\"18\" height=\"8\" fill=\"#44CFFF\"\/><text x=\"220\" y=\"18\" font-size=\"10\" fill=\"#A3A3AC\">MEDIAN WALL, SECONDS (sol:med)<\/text><rect x=\"464\" y=\"13\" width=\"18\" height=\"3\" fill=\"#63636D\"\/><text x=\"488\" y=\"18\" font-size=\"10\" fill=\"#A3A3AC\">PREFIX, K TOKENS<\/text><!--$--><line data-hk=\"000000010000000000004000010b29510\" x1=\"196\" y1=\"30\" x2=\"196\" y2=\"382\" stroke=\"#15151A\" stroke-width=\"1\"\/><text data-hk=\"000000010000000000004000010b29511\" x=\"196\" y=\"398\" text-anchor=\"middle\" font-size=\"10\" fill=\"#63636D\"><!--$-->0<!--\/-->s<\/text><line data-hk=\"000000010000000000004000010b29512\" x1=\"308.17391304347825\" y1=\"30\" x2=\"308.17391304347825\" y2=\"382\" stroke=\"#15151A\" stroke-width=\"1\"\/><text data-hk=\"000000010000000000004000010b29513\" x=\"308.17391304347825\" y=\"398\" text-anchor=\"middle\" font-size=\"10\" fill=\"#63636D\"><!--$-->20<!--\/-->s<\/text><line data-hk=\"000000010000000000004000010b29514\" x1=\"420.3478260869565\" y1=\"30\" x2=\"420.3478260869565\" y2=\"382\" stroke=\"#15151A\" stroke-width=\"1\"\/><text data-hk=\"000000010000000000004000010b29515\" x=\"420.3478260869565\" y=\"398\" text-anchor=\"middle\" font-size=\"10\" fill=\"#63636D\"><!--$-->40<!--\/-->s<\/text><line data-hk=\"000000010000000000004000010b29516\" x1=\"532.5217391304348\" y1=\"30\" x2=\"532.5217391304348\" y2=\"382\" stroke=\"#15151A\" stroke-width=\"1\"\/><text data-hk=\"000000010000000000004000010b29517\" x=\"532.5217391304348\" y=\"398\" text-anchor=\"middle\" font-size=\"10\" fill=\"#63636D\"><!--$-->60<!--\/-->s<\/text><line data-hk=\"000000010000000000004000010b29518\" x1=\"644.695652173913\" y1=\"30\" x2=\"644.695652173913\" y2=\"382\" stroke=\"#15151A\" stroke-width=\"1\"\/><text data-hk=\"000000010000000000004000010b29519\" x=\"644.695652173913\" y=\"398\" text-anchor=\"middle\" font-size=\"10\" fill=\"#63636D\"><!--$-->80<!--\/-->s<\/text><!--\/--><!--$--><g data-hk=\"000000010000000000004000010b29520\"><text x=\"186\" y=\"58\" text-anchor=\"end\" font-size=\"11\" fill=\"#F5F5F6\">omp \u00b7 stock, no fixes<\/text><text x=\"186\" y=\"71\" text-anchor=\"end\" font-size=\"9\" fill=\"#63636D\"><!--$-->23 defs<!--\/--> \u00b7 <!--$-->12\u201316<!--\/--> turns<\/text><rect x=\"196\" y=\"48\" width=\"483.4695652173914\" height=\"12\" fill=\"#44CFFF\"\/><!--$--><!--\/--><text x=\"685.4695652173914\" y=\"58\" font-size=\"11\" fill=\"#F5F5F6\"><!--$-->86.2<!--\/-->s<!--$--><!--\/--><\/text><rect x=\"196\" y=\"65\" width=\"417.79354838709673\" height=\"3\" fill=\"#63636D\"\/><text x=\"619.7935483870967\" y=\"70\" font-size=\"9\" fill=\"#63636D\"><!--$-->25.1k<!--\/--> tok<\/text><!--$--><!--\/--><\/g><g data-hk=\"000000010000000000004000010b29523\"><text x=\"186\" y=\"116\" text-anchor=\"end\" font-size=\"11\" fill=\"#F5F5F6\">omp \u00b7 todo-batched<\/text><text x=\"186\" y=\"129\" text-anchor=\"end\" font-size=\"9\" fill=\"#63636D\"><!--$-->23 defs, r9<!--\/--> \u00b7 <!--$-->6\u20138<!--\/--> turns<\/text><rect x=\"196\" y=\"106\" width=\"333.71739130434776\" height=\"12\" fill=\"#44CFFF\"\/><!--$--><!--\/--><text x=\"535.7173913043478\" y=\"116\" font-size=\"11\" fill=\"#F5F5F6\"><!--$-->59.5<!--\/-->s<!--$--><!--\/--><\/text><rect x=\"196\" y=\"123\" width=\"417.79354838709673\" height=\"3\" fill=\"#63636D\"\/><text x=\"619.7935483870967\" y=\"128\" font-size=\"9\" fill=\"#63636D\"><!--$-->25.1k<!--\/--> tok<\/text><!--$--><text data-hk=\"000000010000000000004000010b295250\" x=\"712\" y=\"94\" text-anchor=\"end\" font-size=\"10\" fill=\"#F5B04A\">\u2193 <!--$-->\u221226.7s \u00b7 todo-batching fix<!--\/--><\/text><!--\/--><\/g><g data-hk=\"000000010000000000004000010b29526\"><text x=\"186\" y=\"174\" text-anchor=\"end\" font-size=\"11\" fill=\"#F5F5F6\">omp \u00b7 \/xdev default<\/text><text x=\"186\" y=\"187\" text-anchor=\"end\" font-size=\"9\" fill=\"#63636D\"><!--$-->15 defs, r11<!--\/--> \u00b7 <!--$-->6\u20138<!--\/--> turns<\/text><rect x=\"196\" y=\"164\" width=\"254.63478260869562\" height=\"12\" fill=\"#44CFFF\"\/><!--$--><!--\/--><text x=\"456.6347826086956\" y=\"174\" font-size=\"11\" fill=\"#F5F5F6\"><!--$-->45.4<!--\/-->s<!--$--><!--\/--><\/text><rect x=\"196\" y=\"181\" width=\"342.89032258064515\" height=\"3\" fill=\"#63636D\"\/><text x=\"544.8903225806451\" y=\"186\" font-size=\"9\" fill=\"#63636D\"><!--$-->20.6k<!--\/--> tok<\/text><!--$--><text data-hk=\"000000010000000000004000010b295280\" x=\"712\" y=\"152\" text-anchor=\"end\" font-size=\"10\" fill=\"#F5B04A\">\u2193 <!--$-->\u221214.1s \u00b7 23\u219215 wire defs<!--\/--><\/text><!--\/--><\/g><g data-hk=\"000000010000000000004000010b29529\"><text x=\"186\" y=\"232\" text-anchor=\"end\" font-size=\"11\" fill=\"#F5F5F6\">omp \u00b7 lean floor<\/text><text x=\"186\" y=\"245\" text-anchor=\"end\" font-size=\"9\" fill=\"#63636D\"><!--$-->5 tools, r11<!--\/--> \u00b7 <!--$-->4\u20136<!--\/--> turns<\/text><rect x=\"196\" y=\"222\" width=\"205.2782608695652\" height=\"12\" fill=\"#44CFFF\"\/><!--$--><!--\/--><text x=\"407.2782608695652\" y=\"232\" font-size=\"11\" fill=\"#F5F5F6\"><!--$-->36.6<!--\/-->s<!--$--><!--\/--><\/text><rect x=\"196\" y=\"239\" width=\"251.34193548387094\" height=\"3\" fill=\"#63636D\"\/><text x=\"453.34193548387094\" y=\"244\" font-size=\"9\" fill=\"#63636D\"><!--$-->15.1k<!--\/--> tok<\/text><!--$--><text data-hk=\"000000010000000000004000010b2952a110\" x=\"712\" y=\"210\" text-anchor=\"end\" font-size=\"10\" fill=\"#F5B04A\">\u2193 <!--$-->\u22128.8s \u00b7 essential-5 only<!--\/--><\/text><!--\/--><\/g><g data-hk=\"000000010000000000004000010b2952a12\"><text x=\"186\" y=\"290\" text-anchor=\"end\" font-size=\"11\" fill=\"#F5F5F6\">codex-cli 0.144 (reference)<\/text><text x=\"186\" y=\"303\" text-anchor=\"end\" font-size=\"9\" fill=\"#63636D\"><!--$-->3 tools<!--\/--> \u00b7 <!--$-->4<!--\/--> turns<\/text><rect x=\"196\" y=\"280\" width=\"236.68695652173915\" height=\"12\" fill=\"#A3A3AC\"\/><!--$--><!--\/--><text x=\"438.68695652173915\" y=\"290\" font-size=\"11\" fill=\"#F5F5F6\"><!--$-->42.2<!--\/-->s<!--$--><!--\/--><\/text><rect x=\"196\" y=\"297\" width=\"204.73548387096776\" height=\"3\" fill=\"#63636D\"\/><text x=\"406.73548387096776\" y=\"302\" font-size=\"9\" fill=\"#63636D\"><!--$-->9.6\u201312.3k<!--\/--> tok<\/text><!--$--><!--\/--><\/g><g data-hk=\"000000010000000000004000010b2952a15\"><text x=\"186\" y=\"348\" text-anchor=\"end\" font-size=\"11\" fill=\"#F5F5F6\">pi (reference)<\/text><text x=\"186\" y=\"361\" text-anchor=\"end\" font-size=\"9\" fill=\"#63636D\"><!--$-->~5 tiny-schema tools<!--\/--> \u00b7 <!--$-->6<!--\/--> turns<\/text><rect x=\"196\" y=\"338\" width=\"207.52173913043475\" height=\"12\" fill=\"#A3A3AC\"\/><!--$--><!--\/--><text x=\"409.52173913043475\" y=\"348\" font-size=\"11\" fill=\"#F5F5F6\"><!--$-->37.0<!--\/-->s<!--$--><!--\/--><\/text><rect x=\"196\" y=\"355\" width=\"93.21290322580643\" height=\"3\" fill=\"#63636D\"\/><text x=\"295.21290322580643\" y=\"360\" font-size=\"9\" fill=\"#63636D\"><!--$-->5.6k<!--\/--> tok<\/text><!--$--><!--\/--><\/g><!--\/--><\/svg><!--\/--><figcaption>Median wall (thick bar, seconds) and request prefix (thin bar, k tokens) per variant \u00b7 task <!--$--><code data-hk=\"000000010000000000004000010b29600\">sol<\/code><!--\/-->, median of 6 runs, fresh session each \u00b7 cyan = omp variants, grey = external references \u00b7 annotations are deltas vs the row above.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b29700\">The culprit was the tool roster. Limit it to five essential tools and you get <code data-hk=\"000000010000000000004000010b2970100\">36.6s<\/code>, ahead of Codex&#8217;s<br \/>\n<code data-hk=\"000000010000000000004000010b2970200\">42.2s<\/code> and Pi&#8217;s <code data-hk=\"000000010000000000004000010b2970300\">37.0s<\/code>. Why? Tool grammar! Even if it&#8217;s just a text description to the model, it<br \/>\nis something that actively contributes to token generation with most frontier model providers, as it<br \/>\naffects the token generation process, driving them to always give you valid JSON (on top of the<br \/>\ntokens used to describe it).<\/p>\n<p data-hk=\"000000010000000000004000010b29800\">A tool is not some free win, just in case the model needs it; this is the idea about dynamic tool<br \/>\ndiscovery. But this dynamic approach comes with a cache invalidation as soon as you change the tool<br \/>\nroster, which is why we aren&#8217;t a big fan of it.<\/p>\n<p data-hk=\"000000010000000000004000010b29900\">Pi got one part right, and we always agreed with it: MCPs are horribly designed and do not belong<br \/>\nin the permanent tool layer. So how do we satisfy both the user who wants a Figma MCP and the<br \/>\ninference constraints?<\/p>\n<p data-hk=\"000000010000000000004000010b30000\">Dynamic tool discovery avoids the permanent grammar cost but invalidates the cache whenever the<br \/>\nroster changes. The better target is a stable, tiny grammar with a long tail reachable through<br \/>\nordinary composition.<\/p>\n<h3 data-hk=\"000000010000000000004000010b30100\" id=\"put-the-long-tail-behind-stable-surfaces\">Put the long tail behind stable surfaces<\/h3>\n<p data-hk=\"000000010000000000004000010b30200\">Meet the <code data-hk=\"000000010000000000004000010b3020100\">dyn<\/code> CLI! This is not a real CLI of course, but a builtin exposed by our Bash<br \/>\nimplementation, giving the model a stable discovery protocol, and a convenient way to use it through<br \/>\nBash, or through <code data-hk=\"000000010000000000004000010b3020200\">Eval<\/code> as a Python function.<\/p>\n<pre data-hk=\"000000010000000000004000010b30300\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b3030100\"><span data-hk=\"000000010000000000004000010b303010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b30301010100\" style=\"color:#44CFFF\">dyn<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b303010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b30301020100\" style=\"color:#44CFFF\">dyn<\/span><span data-hk=\"000000010000000000004000010b30301020200\" style=\"color:#B99AFF\"> --q<\/span><span data-hk=\"000000010000000000004000010b30301020300\" style=\"color:#B99AFF\"> github<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b303010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b30301030100\" style=\"color:#44CFFF\">dyn<\/span><span data-hk=\"000000010000000000004000010b30301030200\" style=\"color:#B99AFF\"> github\/list_prs<\/span><span data-hk=\"000000010000000000004000010b30301030300\" style=\"color:#B99AFF\"> --state<\/span><span data-hk=\"000000010000000000004000010b30301030400\" style=\"color:#B99AFF\"> open<\/span><span data-hk=\"000000010000000000004000010b30301030500\" style=\"color:#CFD4DC\"> | <\/span><span data-hk=\"000000010000000000004000010b30301030600\" style=\"color:#44CFFF\">jq<\/span><span data-hk=\"000000010000000000004000010b30301030700\" style=\"color:#B99AFF\"> '.[] | .title'<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b303010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b30301040100\" style=\"color:#44CFFF\">cat<\/span><span data-hk=\"000000010000000000004000010b30301040200\" style=\"color:#B99AFF\"> query.sql<\/span><span data-hk=\"000000010000000000004000010b30301040300\" style=\"color:#CFD4DC\"> | <\/span><span data-hk=\"000000010000000000004000010b30301040400\" style=\"color:#44CFFF\">dyn<\/span><span data-hk=\"000000010000000000004000010b30301040500\" style=\"color:#B99AFF\"> database\/query<\/span><span data-hk=\"000000010000000000004000010b30301040600\" style=\"color:#B99AFF\"> -<\/span><span data-hk=\"000000010000000000004000010b30301040700\" style=\"color:#B99AFF\"> --params<\/span><span data-hk=\"000000010000000000004000010b30301040800\" style=\"color:#B99AFF\"> limit=5<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b303010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b30301050100\" style=\"color:#44CFFF\">dyn<\/span><span data-hk=\"000000010000000000004000010b30301050200\" style=\"color:#B99AFF\"> image_gen<\/span><span data-hk=\"000000010000000000004000010b30301050300\" style=\"color:#B99AFF\"> \"blueprint of a frog\"<\/span><span data-hk=\"000000010000000000004000010b30301050400\" style=\"color:#CFD4DC\"> &gt; <\/span><span data-hk=\"000000010000000000004000010b30301050500\" style=\"color:#B99AFF\">result.json<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b30400\">Once it finds an interesting tool, just like tool search, it can use <code data-hk=\"000000010000000000004000010b3040100\">--help<\/code> to get the details:<\/p>\n<pre data-hk=\"000000010000000000004000010b30500\"><code data-hk=\"000000010000000000004000010b3050100\">$ dyn github\/create_pr --help\ndyn github\/create_pr &lt;title&gt; [OPTIONS]\n\nArguments:\n  &lt;title&gt;\n\nOptions:\n  -d, --draft \/ --no-draft\n  -r, --reviewers &lt;TEXT&gt;[,\u2026]  (repeatable)\n  -p, --pr-meta.priority &lt;INTEGER&gt;\n  -m, --pr-meta.notify \/ --no-pr-meta.notify\n  -j, --json &lt;JSON&gt;\n  -h, --help\n<\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b30600\">This is synthesized from the JSON schema of course, which is all you need to generate a nice CLI<br \/>\nmapping already.<\/p>\n<p data-hk=\"000000010000000000004000010b30700\">Large inputs are where this becomes especially nice:<\/p>\n<pre data-hk=\"000000010000000000004000010b30800\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b3080100\"><span data-hk=\"000000010000000000004000010b308010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b30801010100\" style=\"color:#44CFFF\">dyn<\/span><span data-hk=\"000000010000000000004000010b30801010200\" style=\"color:#B99AFF\"> database\/query<\/span><span data-hk=\"000000010000000000004000010b30801010300\" style=\"color:#B99AFF\"> \"SELECT 1\"<\/span><span data-hk=\"000000010000000000004000010b30801010400\" style=\"color:#CFD4DC8F;fontStyle:italic\">       # literal<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b308010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b30801020100\" style=\"color:#44CFFF\">dyn<\/span><span data-hk=\"000000010000000000004000010b30801020200\" style=\"color:#B99AFF\"> database\/query<\/span><span data-hk=\"000000010000000000004000010b30801020300\" style=\"color:#B99AFF\"> @query.sql<\/span><span data-hk=\"000000010000000000004000010b30801020400\" style=\"color:#CFD4DC8F;fontStyle:italic\">       # file contents<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b308010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b30801030100\" style=\"color:#44CFFF\">cat<\/span><span data-hk=\"000000010000000000004000010b30801030200\" style=\"color:#B99AFF\"> query.sql<\/span><span data-hk=\"000000010000000000004000010b30801030300\" style=\"color:#CFD4DC\"> | <\/span><span data-hk=\"000000010000000000004000010b30801030400\" style=\"color:#44CFFF\">dyn<\/span><span data-hk=\"000000010000000000004000010b30801030500\" style=\"color:#B99AFF\"> database\/query<\/span><span data-hk=\"000000010000000000004000010b30801030600\" style=\"color:#B99AFF\"> -<\/span><span data-hk=\"000000010000000000004000010b30801030700\" style=\"color:#CFD4DC8F;fontStyle:italic\"> # stdin<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b30900\">One edge case to handle: what about image-returning tools? Well, how does omp display images to you?<br \/>\nSixel or the Kitty protocol, right? Why not parse the same output in the <code data-hk=\"000000010000000000004000010b3090100\">Bash<\/code> tool and attach the images!<br \/>\nNow you also get to look at remote images through ssh, sweet.<\/p>\n<p data-hk=\"000000010000000000004000010b31000\">There is a second option when all those operations belong to one API: expose a code surface.<br \/>\nBrowser keeps <code data-hk=\"000000010000000000004000010b3100100\">open<\/code> \/ <code data-hk=\"000000010000000000004000010b3100200\">run<\/code> \/ <code data-hk=\"000000010000000000004000010b3100300\">close<\/code> and runs code against a persistent tab; Computer exposes<br \/>\n<code data-hk=\"000000010000000000004000010b3100400\">desktop<\/code>, <code data-hk=\"000000010000000000004000010b3100500\">wait<\/code>, and <code data-hk=\"000000010000000000004000010b3100600\">assert<\/code> in a persistent session. One stable schema, operations composed<br \/>\ninside one call. <strong data-hk=\"000000010000000000004000010b3100700\">Bounded operation set: schema. Open-ended operation set: code surface.<\/strong><\/p>\n<p data-hk=\"000000010000000000004000010b31100\">The two forms serve different shapes of API. A bounded operation set can remain a schema; an<br \/>\nopen-ended operation set wants a code or command surface where several operations compose inside one<br \/>\ncall. Neither requires changing the permanent roster after discovery.<\/p>\n<h3 data-hk=\"000000010000000000004000010b31200\" id=\"contract-hygiene-intent-and-version\">Contract hygiene: intent and version<\/h3>\n<p data-hk=\"000000010000000000004000010b31300\">One small change to the contract is worth calling out: every tool gets an <code data-hk=\"000000010000000000004000010b3130100\">i<\/code> intent argument.<br \/>\nIt arrives while arguments stream, so <code data-hk=\"000000010000000000004000010b3130200\">renderCall<\/code> can show what the model thinks it is doing before<br \/>\nthe call completes. The journal gets a readable summary too, without every tool inventing<br \/>\n<code data-hk=\"000000010000000000004000010b3130300\">reason<\/code> \/ <code data-hk=\"000000010000000000004000010b3130400\">purpose<\/code>.<\/p>\n<p data-hk=\"000000010000000000004000010b31400\">People should <strong data-hk=\"000000010000000000004000010b3140100\">version their tools<\/strong>.<\/p>\n<p data-hk=\"000000010000000000004000010b31500\">It makes traces much easier to use: you can parse a frequently changed tool&#8217;s I\/O and evaluate its<br \/>\nsuccess rate over time without guessing which contract produced each call.<\/p>\n<p data-hk=\"000000010000000000004000010b31600\">Name, version, intent, input, output, diagnostics, and usage are protocol data. Once traces are used<br \/>\nfor evaluation or repair, guessing any of them becomes avoidable technical debt.<\/p>\n<h3 data-hk=\"000000010000000000004000010b31700\" id=\"deep-builtins\">Deep builtins<\/h3>\n<p data-hk=\"000000010000000000004000010b31800\">A small roster only works when its primitives are broad for a semantic reason\u2014not because unrelated<br \/>\nfeatures were dumped into one switch statement. omp&#8217;s builtins are useful examples.<\/p>\n<h4 data-hk=\"000000010000000000004000010b31900\" id=\"read-materialize-a-resource\">Read: materialize a resource<\/h4>\n<p data-hk=\"000000010000000000004000010b32000\">The most boring tool in <code data-hk=\"000000010000000000004000010b3200100\">omp<\/code> actually packs what would be 20 tools in others.<\/p>\n<ul data-hk=\"000000010000000000004000010b32100\">\n<li data-hk=\"000000010000000000004000010b3210100\">You can read directories, no need for <code data-hk=\"000000010000000000004000010b321010100\">Ls<\/code>.<\/li>\n<li data-hk=\"000000010000000000004000010b3210200\">Instead of an additional <code data-hk=\"000000010000000000004000010b321020100\">ReadNotebook<\/code> tool, you get nice output by default when you read an<br \/>\n<code data-hk=\"000000010000000000004000010b321020200\">.ipynb<\/code> file.<\/li>\n<li data-hk=\"000000010000000000004000010b3210300\"><code data-hk=\"000000010000000000004000010b321030100\">.pdf<\/code>, <code data-hk=\"000000010000000000004000010b321030200\">.docx<\/code>, <code data-hk=\"000000010000000000004000010b321030300\">.pptx<\/code>, <code data-hk=\"000000010000000000004000010b321030400\">.xlsx<\/code>, <code data-hk=\"000000010000000000004000010b321030500\">.epub<\/code>? You get extracted markdown.<\/li>\n<li data-hk=\"000000010000000000004000010b3210400\"><code data-hk=\"000000010000000000004000010b321040100\">.cpuprofil, .sample.txt<\/code>? You guessed it! You get a bottleneck summary.<\/li>\n<li data-hk=\"000000010000000000004000010b3210500\"><code data-hk=\"000000010000000000004000010b321050100\">.sqlite<\/code>, <code data-hk=\"000000010000000000004000010b321050200\">.sqlite3<\/code>, <code data-hk=\"000000010000000000004000010b321050300\">.db<\/code>, <code data-hk=\"000000010000000000004000010b321050400\">.db3<\/code>? You can list tables, inspect schemas, rows, or even query.<\/li>\n<li data-hk=\"000000010000000000004000010b3210600\">Images return either the image or metadata without vision. To preview an SVG, add <code data-hk=\"000000010000000000004000010b321060100\">:img<\/code>.<\/li>\n<li data-hk=\"000000010000000000004000010b3210700\">Archives can be addressed without unpacking them\u2014not only ZIP and TAR, but JARs, wheels, and ASAR.<\/li>\n<li data-hk=\"000000010000000000004000010b3210800\">The same projections work for an online resource at <code data-hk=\"000000010000000000004000010b321080100\">http:\/\/...<\/code>, with ranges read on demand;<br \/>\nordinary web pages become markdown, just like <code data-hk=\"000000010000000000004000010b321080200\">web_fetch<\/code>.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b32200\">This isn&#8217;t really polymorphism for the sake of being clever. These are all the same operation from<br \/>\nthe model&#8217;s perspective:<\/p>\n<blockquote data-hk=\"000000010000000000004000010b32300\">\n<p data-hk=\"000000010000000000004000010b3230100\">Materialize this resource into the most useful representation I can reason about.<\/p>\n<\/blockquote>\n<p data-hk=\"000000010000000000004000010b32400\">For code, it can also return a structural summary, replacing large declaration bodies with an<br \/>\nellipsis. The model need not pull an entire large file into context merely to find class <code data-hk=\"000000010000000000004000010b3240100\">X<\/code>.<\/p>\n<p data-hk=\"000000010000000000004000010b32500\"><code data-hk=\"000000010000000000004000010b3250100\">:raw<\/code> bypasses the projections when the bytes matter. <code data-hk=\"000000010000000000004000010b3250200\">:conflicts<\/code> gives one line per unresolved<br \/>\nmerge-conflict block instead of making the model hunt through the whole file.<\/p>\n<p data-hk=\"000000010000000000004000010b32600\">Ranges can be open-ended, length-based, or disjoint:<\/p>\n<pre data-hk=\"000000010000000000004000010b32700\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b3270100\"><span data-hk=\"000000010000000000004000010b327010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b32701010100\">:50<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b327010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b32701020100\">:50-<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b327010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b32701030100\">:50-200<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b327010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b32701040100\">:50+150<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b327010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b32701050100\">:5-16,960-973<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b327010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b32701060100\">:raw:50-100<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b327010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b32701070100\">:50-100:raw<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b32800\">Then there are the non-web URLs:<\/p>\n<pre data-hk=\"000000010000000000004000010b32900\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b3290100\"><span data-hk=\"000000010000000000004000010b329010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901010100\">artifact:\/\/&lt;id&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901020100\">agent:\/\/&lt;id&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901030100\">history:\/\/&lt;id&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901040100\">issue:\/\/123<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901050100\">pr:\/\/123\/diff\/2<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901060100\">skill:\/\/react<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901070100\">rule:\/\/foo<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901080100\">memory:\/\/...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b32901090100\">local:\/\/...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b329010a100100\">vault:\/\/...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b329010a110100\">security:\/\/...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010b329010a120100\">omp:\/\/...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010b329010a130100\">xd:\/\/browser<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010b329010a140100\">ssh:\/\/host\/path<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b329010a1500\" class=\"line \"><span data-hk=\"000000010000000000004000010b329010a150100\">mcp:\/\/...<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b33000\">Repository information, MCP resources, subagent transcripts, skills, memory, local scratchspace,<br \/>\nomp documentation, and even remote machines over SSH all fit the same internal URL subsystem. We<br \/>\nrecommend this design.<\/p>\n<p data-hk=\"000000010000000000004000010b33100\"><code data-hk=\"000000010000000000004000010b3310100\">Read<\/code> also handles less visible recovery: resolving an incorrect absolute path from a unique<br \/>\nworkspace suffix, expanding <code data-hk=\"000000010000000000004000010b3310200\">~<\/code> on Windows, and avoiding other turn-wasting path errors.<\/p>\n<p data-hk=\"000000010000000000004000010b33200\">Could this have been:<\/p>\n<pre data-hk=\"000000010000000000004000010b33300\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b3330100\"><span data-hk=\"000000010000000000004000010b333010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b33301010100\" style=\"color:#FF54C0\">return<\/span><span data-hk=\"000000010000000000004000010b33301010200\" style=\"color:#FF54C0\"> await<\/span><span data-hk=\"000000010000000000004000010b33301010300\" style=\"color:#9BE8FF\"> Bun<\/span><span data-hk=\"000000010000000000004000010b33301010400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b33301010500\" style=\"color:#44CFFF\">file<\/span><span data-hk=\"000000010000000000004000010b33301010600\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b33301010700\" style=\"color:#9BE8FF\">path<\/span><span data-hk=\"000000010000000000004000010b33301010800\" style=\"color:#CFD4DC\">).<\/span><span data-hk=\"000000010000000000004000010b33301010900\" style=\"color:#44CFFF\">text<\/span><span data-hk=\"000000010000000000004000010b33301010a1000\" style=\"color:#CFD4DC\">();<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b33400\">Yes. Extension authors would then implement their own readers, or the model would find shell<br \/>\nworkarounds, while the harness exposed similarly shaped functionality under separate names such as<br \/>\n<code data-hk=\"000000010000000000004000010b3340100\">web_fetch<\/code>.<\/p>\n<p data-hk=\"000000010000000000004000010b33500\">That is not less complexity. It is the same complexity, copied into shell commands, prompts,<br \/>\nextensions, and failed tool calls, where nobody owns it and everybody implements 30% of it slightly<br \/>\ndifferently.<\/p>\n<p data-hk=\"000000010000000000004000010b33600\"><code data-hk=\"000000010000000000004000010b3360100\">Read<\/code> is complicated so reading isn&#8217;t.<\/p>\n<p data-hk=\"000000010000000000004000010b33700\">The complexity has one owner. The operation stays stable while resource-specific projection moves<br \/>\nbehind it.<\/p>\n<h4 data-hk=\"000000010000000000004000010b33800\" id=\"bash-a-policy-aware-command-language\">Bash: a policy-aware command language<\/h4>\n<p data-hk=\"000000010000000000004000010b33900\">The Bash tool should not simply shell out to Bash. This sounds unhinged.<\/p>\n<p data-hk=\"000000010000000000004000010b34000\">omp ships a complete bash parser, interpreter, as well as a full set of coreutils, in-process; this<br \/>\nhas been a good choice for simple reasons:<\/p>\n<ul data-hk=\"000000010000000000004000010b34100\">\n<li data-hk=\"000000010000000000004000010b3410100\">You keep the model&#8217;s muscle memory. It can reach for <code data-hk=\"000000010000000000004000010b341010100\">grep<\/code>; because omp is the interpreter, we<br \/>\ncan intercept the command and route suitable arguments to our ripgrep engine. Nobody spends<br \/>\ncontext begging the model to use <code data-hk=\"000000010000000000004000010b341010200\">rg<\/code> in <code data-hk=\"000000010000000000004000010b341010300\">AGENTS.md<\/code>.<\/li>\n<li data-hk=\"000000010000000000004000010b3410200\">Platform neutrality comes almost for free. No WSL or Git Bash: omp can execute most Bash<br \/>\ninvocations in-process on Windows. Nuff said.<\/li>\n<li data-hk=\"000000010000000000004000010b3410300\">The console remains stateful across calls, including variables, exit codes, <code data-hk=\"000000010000000000004000010b341030100\">$!<\/code>, and so on.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b34200\">The more interesting advantage appears when Claude calls it with something like this:<\/p>\n<pre data-hk=\"000000010000000000004000010b34300\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b3430100\"><span data-hk=\"000000010000000000004000010b343010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301010100\" style=\"color:#9BE8FF\">INC<\/span><span data-hk=\"000000010000000000004000010b34301010200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b34301010300\" style=\"color:#B99AFF\">\"\u2026\/10.0.22621.0\"<\/span><span data-hk=\"000000010000000000004000010b34301010400\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301010500\" style=\"color:#FF54C0\">declare<\/span><span data-hk=\"000000010000000000004000010b34301010600\" style=\"color:#B99AFF\"> -A<\/span><span data-hk=\"000000010000000000004000010b34301010700\" style=\"color:#9BE8FF\"> R<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301020100\" style=\"color:#FF54C0\">for<\/span><span data-hk=\"000000010000000000004000010b34301020200\" style=\"color:#9BE8FF\"> d<\/span><span data-hk=\"000000010000000000004000010b34301020300\" style=\"color:#FF54C0\"> in<\/span><span data-hk=\"000000010000000000004000010b34301020400\" style=\"color:#B99AFF\"> um<\/span><span data-hk=\"000000010000000000004000010b34301020500\" style=\"color:#B99AFF\"> shared<\/span><span data-hk=\"000000010000000000004000010b34301020600\" style=\"color:#B99AFF\"> ucrt<\/span><span data-hk=\"000000010000000000004000010b34301020700\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301020800\" style=\"color:#FF54C0\">do<\/span><span data-hk=\"000000010000000000004000010b34301020900\" style=\"color:#FF54C0\"> while<\/span><span data-hk=\"000000010000000000004000010b34301020a1000\" style=\"color:#9BE8FF\"> IFS<\/span><span data-hk=\"000000010000000000004000010b34301020a1100\" style=\"color:#CFD4DC\">= read <\/span><span data-hk=\"000000010000000000004000010b34301020a1200\" style=\"color:#B99AFF\">-r<\/span><span data-hk=\"000000010000000000004000010b34301020a1300\" style=\"color:#B99AFF\"> f<\/span><span data-hk=\"000000010000000000004000010b34301020a1400\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301020a1500\" style=\"color:#FF54C0\">do<\/span><span data-hk=\"000000010000000000004000010b34301020a1600\" style=\"color:#9BE8FF\"> b<\/span><span data-hk=\"000000010000000000004000010b34301020a1700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b34301020a1800\" style=\"color:#B99AFF\">\"${<\/span><span data-hk=\"000000010000000000004000010b34301020a1900\" style=\"color:#9BE8FF\">f<\/span><span data-hk=\"000000010000000000004000010b34301020a2000\" style=\"color:#CFD4DC\">##*\/<\/span><span data-hk=\"000000010000000000004000010b34301020a2100\" style=\"color:#B99AFF\">}\"<\/span><span data-hk=\"000000010000000000004000010b34301020a2200\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301020a2300\" style=\"color:#44CFFF\">R[<\/span><span data-hk=\"000000010000000000004000010b34301020a2400\" style=\"color:#44CFFF\">\"${<\/span><span data-hk=\"000000010000000000004000010b34301020a2500\" style=\"color:#9BE8FF\">b<\/span><span data-hk=\"000000010000000000004000010b34301020a2600\" style=\"color:#44CFFF\">,,}\"<\/span><span data-hk=\"000000010000000000004000010b34301020a2700\" style=\"color:#44CFFF\">]<\/span><span data-hk=\"000000010000000000004000010b34301020a2800\" style=\"color:#B99AFF\">=<\/span><span data-hk=\"000000010000000000004000010b34301020a2900\" style=\"color:#44CFFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301020a3000\" style=\"color:#9BE8FF\">$f<\/span><span data-hk=\"000000010000000000004000010b34301020a3100\" style=\"color:#44CFFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301020a3200\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301020a3300\" style=\"color:#FF54C0\">done<\/span><span data-hk=\"000000010000000000004000010b34301020a3400\" style=\"color:#CFD4DC\"> \\<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301030100\" style=\"color:#CFD4DC\">  &lt; <\/span><span data-hk=\"000000010000000000004000010b34301030200\" style=\"color:#B99AFF\">&lt;(<\/span><span data-hk=\"000000010000000000004000010b34301030300\" style=\"color:#44CFFF\">find<\/span><span data-hk=\"000000010000000000004000010b34301030400\" style=\"color:#B99AFF\"> \"<\/span><span data-hk=\"000000010000000000004000010b34301030500\" style=\"color:#9BE8FF\">$INC<\/span><span data-hk=\"000000010000000000004000010b34301030600\" style=\"color:#B99AFF\">\/<\/span><span data-hk=\"000000010000000000004000010b34301030700\" style=\"color:#9BE8FF\">$d<\/span><span data-hk=\"000000010000000000004000010b34301030800\" style=\"color:#B99AFF\">\" -maxdepth 1 -type f -name \"*.[hH]\")<\/span><span data-hk=\"000000010000000000004000010b34301030900\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301030a1000\" style=\"color:#FF54C0\">done<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301040100\" style=\"color:#9BE8FF\">n<\/span><span data-hk=\"000000010000000000004000010b34301040200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b34301040300\" style=\"color:#B99AFF\">0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301050100\" style=\"color:#FF54C0\">while<\/span><span data-hk=\"000000010000000000004000010b34301050200\" style=\"color:#9BE8FF\"> IFS<\/span><span data-hk=\"000000010000000000004000010b34301050300\" style=\"color:#CFD4DC\">= read <\/span><span data-hk=\"000000010000000000004000010b34301050400\" style=\"color:#B99AFF\">-r<\/span><span data-hk=\"000000010000000000004000010b34301050500\" style=\"color:#B99AFF\"> ref<\/span><span data-hk=\"000000010000000000004000010b34301050600\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301050700\" style=\"color:#FF54C0\">do<\/span><span data-hk=\"000000010000000000004000010b34301050800\" style=\"color:#FF54C0\"> case<\/span><span data-hk=\"000000010000000000004000010b34301050900\" style=\"color:#B99AFF\"> \"<\/span><span data-hk=\"000000010000000000004000010b34301050a1000\" style=\"color:#9BE8FF\">$ref<\/span><span data-hk=\"000000010000000000004000010b34301050a1100\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301050a1200\" style=\"color:#FF54C0\"> in<\/span><span data-hk=\"000000010000000000004000010b34301050a1300\" style=\"color:#CFD4DC\"> *<\/span><span data-hk=\"000000010000000000004000010b34301050a1400\" style=\"color:#CFD4DC\">\/<\/span><span data-hk=\"000000010000000000004000010b34301050a1500\" style=\"color:#CFD4DC\">*<\/span><span data-hk=\"000000010000000000004000010b34301050a1600\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b34301050a1700\" style=\"color:#FF54C0\">continue<\/span><span data-hk=\"000000010000000000004000010b34301050a1800\" style=\"color:#CFD4DC\">;; <\/span><span data-hk=\"000000010000000000004000010b34301050a1900\" style=\"color:#FF54C0\">esac<\/span><span data-hk=\"000000010000000000004000010b34301050a2000\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301050a2100\" style=\"color:#9BE8FF\">r<\/span><span data-hk=\"000000010000000000004000010b34301050a2200\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b34301050a2300\" style=\"color:#B99AFF\">\"${<\/span><span data-hk=\"000000010000000000004000010b34301050a2400\" style=\"color:#9BE8FF\">R<\/span><span data-hk=\"000000010000000000004000010b34301050a2500\" style=\"color:#B99AFF\">[${<\/span><span data-hk=\"000000010000000000004000010b34301050a2600\" style=\"color:#9BE8FF\">ref<\/span><span data-hk=\"000000010000000000004000010b34301050a2700\" style=\"color:#B99AFF\">,,}]<\/span><span data-hk=\"000000010000000000004000010b34301050a2800\" style=\"color:#CFD4DC\">:-<\/span><span data-hk=\"000000010000000000004000010b34301050a2900\" style=\"color:#B99AFF\">}\"<\/span><span data-hk=\"000000010000000000004000010b34301050a3000\" style=\"color:#CFD4DC\">; \\<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301060100\" style=\"color:#CFD4DC\">  [ -n <\/span><span data-hk=\"000000010000000000004000010b34301060200\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301060300\" style=\"color:#9BE8FF\">$r<\/span><span data-hk=\"000000010000000000004000010b34301060400\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301060500\" style=\"color:#CFD4DC\"> ] || <\/span><span data-hk=\"000000010000000000004000010b34301060600\" style=\"color:#FF54C0\">continue<\/span><span data-hk=\"000000010000000000004000010b34301060700\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301060800\" style=\"color:#9BE8FF\">rd<\/span><span data-hk=\"000000010000000000004000010b34301060900\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b34301060a1000\" style=\"color:#B99AFF\">\"${<\/span><span data-hk=\"000000010000000000004000010b34301060a1100\" style=\"color:#9BE8FF\">r<\/span><span data-hk=\"000000010000000000004000010b34301060a1200\" style=\"color:#CFD4DC\">%\/*<\/span><span data-hk=\"000000010000000000004000010b34301060a1300\" style=\"color:#B99AFF\">}\"<\/span><span data-hk=\"000000010000000000004000010b34301060a1400\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301060a1500\" style=\"color:#9BE8FF\">rn<\/span><span data-hk=\"000000010000000000004000010b34301060a1600\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b34301060a1700\" style=\"color:#B99AFF\">\"${<\/span><span data-hk=\"000000010000000000004000010b34301060a1800\" style=\"color:#9BE8FF\">r<\/span><span data-hk=\"000000010000000000004000010b34301060a1900\" style=\"color:#CFD4DC\">##*\/<\/span><span data-hk=\"000000010000000000004000010b34301060a2000\" style=\"color:#B99AFF\">}\"<\/span><span data-hk=\"000000010000000000004000010b34301060a2100\" style=\"color:#CFD4DC\">; \\<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301070100\" style=\"color:#FF54C0\">  if<\/span><span data-hk=\"000000010000000000004000010b34301070200\" style=\"color:#CFD4DC\"> [ <\/span><span data-hk=\"000000010000000000004000010b34301070300\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070400\" style=\"color:#9BE8FF\">$ref<\/span><span data-hk=\"000000010000000000004000010b34301070500\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070600\" style=\"color:#CFD4DC\"> != <\/span><span data-hk=\"000000010000000000004000010b34301070700\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070800\" style=\"color:#9BE8FF\">$rn<\/span><span data-hk=\"000000010000000000004000010b34301070900\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070a1000\" style=\"color:#CFD4DC\"> ] &amp;&amp; [ ! -e <\/span><span data-hk=\"000000010000000000004000010b34301070a1100\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070a1200\" style=\"color:#9BE8FF\">$rd<\/span><span data-hk=\"000000010000000000004000010b34301070a1300\" style=\"color:#B99AFF\">\/<\/span><span data-hk=\"000000010000000000004000010b34301070a1400\" style=\"color:#9BE8FF\">$ref<\/span><span data-hk=\"000000010000000000004000010b34301070a1500\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070a1600\" style=\"color:#CFD4DC\"> ]; <\/span><span data-hk=\"000000010000000000004000010b34301070a1700\" style=\"color:#FF54C0\">then<\/span><span data-hk=\"000000010000000000004000010b34301070a1800\" style=\"color:#44CFFF\"> ln<\/span><span data-hk=\"000000010000000000004000010b34301070a1900\" style=\"color:#B99AFF\"> -s<\/span><span data-hk=\"000000010000000000004000010b34301070a2000\" style=\"color:#B99AFF\"> \"<\/span><span data-hk=\"000000010000000000004000010b34301070a2100\" style=\"color:#9BE8FF\">$rn<\/span><span data-hk=\"000000010000000000004000010b34301070a2200\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070a2300\" style=\"color:#B99AFF\"> \"<\/span><span data-hk=\"000000010000000000004000010b34301070a2400\" style=\"color:#9BE8FF\">$rd<\/span><span data-hk=\"000000010000000000004000010b34301070a2500\" style=\"color:#B99AFF\">\/<\/span><span data-hk=\"000000010000000000004000010b34301070a2600\" style=\"color:#9BE8FF\">$ref<\/span><span data-hk=\"000000010000000000004000010b34301070a2700\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b34301070a2800\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b34301070a2900\" style=\"color:#9BE8FF\">n<\/span><span data-hk=\"000000010000000000004000010b34301070a3000\" style=\"color:#CFD4DC\">=$((<\/span><span data-hk=\"000000010000000000004000010b34301070a3100\" style=\"color:#44CFFF\">n+1<\/span><span data-hk=\"000000010000000000004000010b34301070a3200\" style=\"color:#CFD4DC\">)); <\/span><span data-hk=\"000000010000000000004000010b34301070a3300\" style=\"color:#FF54C0\">fi<\/span><span data-hk=\"000000010000000000004000010b34301070a3400\" style=\"color:#CFD4DC\">; \\<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301080100\" style=\"color:#FF54C0\">done<\/span><span data-hk=\"000000010000000000004000010b34301080200\" style=\"color:#CFD4DC\"> &lt; <\/span><span data-hk=\"000000010000000000004000010b34301080300\" style=\"color:#B99AFF\">&lt;(<\/span><span data-hk=\"000000010000000000004000010b34301080400\" style=\"color:#44CFFF\">grep<\/span><span data-hk=\"000000010000000000004000010b34301080500\" style=\"color:#B99AFF\"> -rhoiE \"#[[:space:]]*include[[:space:]]*&lt;[^&gt;]+&gt;\" \"<\/span><span data-hk=\"000000010000000000004000010b34301080600\" style=\"color:#9BE8FF\">$INC<\/span><span data-hk=\"000000010000000000004000010b34301080700\" style=\"color:#B99AFF\">\/um\" \"<\/span><span data-hk=\"000000010000000000004000010b34301080800\" style=\"color:#9BE8FF\">$INC<\/span><span data-hk=\"000000010000000000004000010b34301080900\" style=\"color:#B99AFF\">\/shared\" \"<\/span><span data-hk=\"000000010000000000004000010b34301080a1000\" style=\"color:#9BE8FF\">$INC<\/span><span data-hk=\"000000010000000000004000010b34301080a1100\" style=\"color:#B99AFF\">\/ucrt\" <\/span><span data-hk=\"000000010000000000004000010b34301080a1200\" style=\"color:#CFD4DC\">\\<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b343010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b34301090100\" style=\"color:#CFD4DC\">  |<\/span><span data-hk=\"000000010000000000004000010b34301090200\" style=\"color:#44CFFF\"> sed<\/span><span data-hk=\"000000010000000000004000010b34301090300\" style=\"color:#B99AFF\"> -E \"s\/.*&lt;([^&gt;]+)&gt;.*\/\\1\/\" <\/span><span data-hk=\"000000010000000000004000010b34301090400\" style=\"color:#CFD4DC\">|<\/span><span data-hk=\"000000010000000000004000010b34301090500\" style=\"color:#44CFFF\"> sort<\/span><span data-hk=\"000000010000000000004000010b34301090600\" style=\"color:#B99AFF\"> -u)<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b34400\">Can you tell me what this is doing within 5 seconds? (If you said yes, you&#8217;re lying)<\/p>\n<p data-hk=\"000000010000000000004000010b34500\">Whatever your opinion on tool approval, this is horrible: nobody will read it. Anthropic&#8217;s recent<br \/>\nresearch points the same way, with auto mode\u2014another Claude reading the command\u2014beating humans by<br \/>\nquite far.<\/p>\n<p data-hk=\"000000010000000000004000010b34600\">When omp interprets the command itself, it can ask at the moment execution reaches <code data-hk=\"000000010000000000004000010b3460100\">ln<\/code>; everything<br \/>\nbefore that is read-only. It can skip even that prompt when the user has already allowed writes to<br \/>\nthe directory.<\/p>\n<p data-hk=\"000000010000000000004000010b34700\">This shifts the harness from being the TSA screen of \u201cBash\u201d to being a capability approver:<br \/>\n\u201cMay I use Git to push?\u201d Common commands such as <code data-hk=\"000000010000000000004000010b3470100\">find<\/code>, <code data-hk=\"000000010000000000004000010b3470200\">cat<\/code>, and <code data-hk=\"000000010000000000004000010b3470300\">ln<\/code> run in-process, query the<br \/>\naccess model just in time, and inherit the user&#8217;s existing read\/write policy.<\/p>\n<p data-hk=\"000000010000000000004000010b34800\">Because the host interprets common commands, approval can occur at the capability boundary that<br \/>\nmatters\u2014<code data-hk=\"000000010000000000004000010b3480100\">git push<\/code>, a write outside the workspace, a network request\u2014not at the unreadable shell<br \/>\nstring boundary. The runtime policy from chapter three becomes enforceable without discarding the<br \/>\nmodel&#8217;s shell muscle memory.<\/p>\n<h4 data-hk=\"000000010000000000004000010b34900\" id=\"autoqa-give-agents-a-bug-report-path\">AutoQA: give agents a bug-report path<\/h4>\n<p data-hk=\"000000010000000000004000010b35000\">We added this tool a month into our fork, before Anthropic added an equivalent to theirs.<\/p>\n<p data-hk=\"000000010000000000004000010b35100\">You know how you usually provide a way for users to report their issues with your product somewhere?<br \/>\nThis is the equivalent of that, but for the agents. This lets you collect, fully autonomously,<br \/>\ninformation about what they liked about a tool, what they found confusing, and what they saw act<br \/>\nerroneously.<\/p>\n<p data-hk=\"000000010000000000004000010b35200\">Now the quality of the reports is not quite <em data-hk=\"000000010000000000004000010b3520100\">great<\/em>, Codex for instance, loves to complain about<br \/>\nexternal edits to files by blaming the <code data-hk=\"000000010000000000004000010b3520200\">Read<\/code> or LSP tool when it doesn&#8217;t rename things<br \/>\nproperly (<em data-hk=\"000000010000000000004000010b3520300\">not my fault man, ask the TypeScript guys<\/em>), but, it is very easy to filter them out, and<br \/>\nonce you do, you get a tremendous amount of signal about which tool fails and how it can be<br \/>\nimproved.<\/p>\n<p data-hk=\"000000010000000000004000010b35300\">AutoQA closes the loop between tool design and deployed behavior. It is noisy, but once obvious<br \/>\nmisattributions are filtered, it reveals which operation confuses models, which projection hides<br \/>\nneeded data, and which repair belongs in the harness.<\/p>\n<p data-hk=\"000000010000000000004000010b35400\">Tools now have a bounded runtime, a stable discovery surface, and structured state. The user should<br \/>\nnot need every tool author\u2014often Claude\u2014to become a terminal rendering and security expert merely to<br \/>\nshow that state safely.<\/p>\n<h2 data-hk=\"000000010000000000004000010b35500\" id=\"the-interface\">The interface<\/h2>\n<div data-hk=\"000000010000000000004000010b3560\" class=\"post-stats\">\n<p><span class=\"post-stat-value\">267s \u2192 90ms<\/span><span class=\"post-stat-label\">render time, one session<\/span><\/p>\n<p><span class=\"post-stat-value\">13%<\/span><span class=\"post-stat-label\">of profiled CPU in one .includes<\/span><\/p>\n<p><span class=\"post-stat-value\">98.7s<\/span><span class=\"post-stat-label\">spent re-wrapping in wrapAnsi<\/span><\/p>\n<p><span class=\"post-stat-value\">0<\/span><span class=\"post-stat-label\">images in that session<\/span><\/p>\n<\/div>\n<aside data-hk=\"000000010000000000004000010b3570\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>An ANSI-escaped array of strings and <code data-hk=\"000000010000000000004000010b357100\">render()<\/code> do not make a good rendering primitive.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b35720\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b35800\">The session DOM and tool state stream give every client the same facts. They do not, by themselves,<br \/>\nproduce a safe, fast, consistent interface. A renderer can still turn those facts into re-parsed<br \/>\nstrings, extension-specific styling conventions, and irreversible scrollback bugs.<\/p>\n<h3 data-hk=\"000000010000000000004000010b35900\" id=\"what-omp-taught-us-strings-compound\">What omp taught us: strings compound<\/h3>\n<p data-hk=\"000000010000000000004000010b36000\">This was in fact the topic of one of my first PRs to<br \/>\n<a data-hk=\"000000010000000000004000010b3600100\" href=\"https:\/\/github.com\/earendil-works\/pi\/pull\/1084\">pi-mono<\/a>. Before the change, if you went ahead and<br \/>\nprofiled Pi for the duration of a task, and looked at the CPU usage, the list would be entirely<br \/>\noccupied by, you guessed it, the renderer!<\/p>\n<figure data-hk=\"000000010000000000004000010b361\"><!--$--><canvas data-hk=\"000000010000000000004000010b3620\" class=\"st-chart\" style=\"height:340px;display:block;width:100%\" aria-hidden=\"\"\/><!--\/--><figcaption>Renderer-dominated CPU profile of a Pi session \u2014 treemap of self time. String scanning (red) alone burns a fifth of the session. \u00b7 hover a tile for the code it profiles.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b36300\">Being a TypeScript CLI makes some of this inevitable (the fact that strings are UTF-16 internally alone<br \/>\nmeans you go through a relatively expensive transcoding step on every single frame, unless you&#8217;re<br \/>\npassing around Uint8Arrays to represent text like a maniac).<\/p>\n<p data-hk=\"000000010000000000004000010b36400\">But it&#8217;s the contract itself that makes this expense compound. You want to embed a child component?<br \/>\nNow you have to deal with:<\/p>\n<ul data-hk=\"000000010000000000004000010b36500\">\n<li data-hk=\"000000010000000000004000010b3650100\">Sanitizing said <code data-hk=\"000000010000000000004000010b365010100\">string<\/code> &amp; discarding or decoding-past ANSI escapes<\/li>\n<li data-hk=\"000000010000000000004000010b3650200\">Dealing with padding, truncation, and calculation of every line<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b36600\">This also doesn&#8217;t get any better with the fact that images can be passed, along one of these lines,<br \/>\nas base64 text. The <code data-hk=\"000000010000000000004000010b3660100\">.includes<\/code> check for whether a line is an image line alone accounted for 20% of<br \/>\nthe total CPU cycles spent in a session. That&#8217;s a steep bill (and this session didn&#8217;t even have any<br \/>\nimages!).<\/p>\n<p data-hk=\"000000010000000000004000010b36700\">This is only the graph of the JS side of the business. The rendering pipeline under this setup is a<br \/>\nheap grooming machine: you keep allocating, decomposing and throwing away strings and arrays of<br \/>\nstrings\u2014concatenated, split, truncated, padded, again and again, every single step of the way. Not<br \/>\ngud.<\/p>\n<p data-hk=\"000000010000000000004000010b36800\">The same contract also leaves extensions without a shared design language. If you have used <em data-hk=\"000000010000000000004000010b3680100\">any<\/em><br \/>\nPi extension, you know there is no way to make them follow a common guideline beyond asking Clawd<br \/>\nto restyle each one\u2014and then maintaining the result.<\/p>\n<p data-hk=\"000000010000000000004000010b36900\">There is no contract for whether or not you should use curved borders, whether or not Nerd Font icons<br \/>\nare OK to use, whether or not it will use the colors you like for conveying the semantics of what it<br \/>\nis doing. You will find that:<\/p>\n<ul data-hk=\"000000010000000000004000010b37000\">\n<li data-hk=\"000000010000000000004000010b3700100\">99% of the time, it will do the bare minimum (i.e. truncate\/line-wrap text), and all your tools<br \/>\nwill be indistinguishable gray rectangles.<\/li>\n<li data-hk=\"000000010000000000004000010b3700200\">1% of the time, it will try so hard to look fancy, that it will look out of context,<br \/>\nwhen the rest of your setup is minimalist.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b37100\">A community renderer from the Pi catalog shows what this contract does to the<br \/>\nthings that reach a user:<\/p>\n<pre data-hk=\"000000010000000000004000010b37200\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b3720100\"><span data-hk=\"000000010000000000004000010b372010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201010100\" style=\"color:#FF54C0\">  if<\/span><span data-hk=\"000000010000000000004000010b37201010200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b37201010300\" style=\"color:#9BE8FF\">cq<\/span><span data-hk=\"000000010000000000004000010b37201010400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201010500\" style=\"color:#9BE8FF\">sources<\/span><span data-hk=\"000000010000000000004000010b37201010600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201010700\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b37201010800\" style=\"color:#CFD4DC\"> &gt; <\/span><span data-hk=\"000000010000000000004000010b37201010900\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b37201010a1000\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201020100\" style=\"color:#9BE8FF\">    lines<\/span><span data-hk=\"000000010000000000004000010b37201020200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201020300\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b37201020400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201020500\" style=\"color:#B99AFF\">\"\"<\/span><span data-hk=\"000000010000000000004000010b37201020600\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201030100\" style=\"color:#FF54C0\">    for<\/span><span data-hk=\"000000010000000000004000010b37201030200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b37201030300\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b37201030400\" style=\"color:#C9A4FF\"> s<\/span><span data-hk=\"000000010000000000004000010b37201030500\" style=\"color:#FF54C0\"> of<\/span><span data-hk=\"000000010000000000004000010b37201030600\" style=\"color:#9BE8FF\"> cq<\/span><span data-hk=\"000000010000000000004000010b37201030700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201030800\" style=\"color:#9BE8FF\">sources<\/span><span data-hk=\"000000010000000000004000010b37201030900\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201040100\" style=\"color:#FF54C0\">      const<\/span><span data-hk=\"000000010000000000004000010b37201040200\" style=\"color:#C9A4FF\"> domain<\/span><span data-hk=\"000000010000000000004000010b37201040300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b37201040400\" style=\"color:#9BE8FF\">s<\/span><span data-hk=\"000000010000000000004000010b37201040500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201040600\" style=\"color:#9BE8FF\">url<\/span><span data-hk=\"000000010000000000004000010b37201040700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201040800\" style=\"color:#44CFFF\">replace<\/span><span data-hk=\"000000010000000000004000010b37201040900\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201040a1000\" style=\"color:#B99AFF\">\/<\/span><span data-hk=\"000000010000000000004000010b37201040a1100\" style=\"color:#FF54C0\">^<\/span><span data-hk=\"000000010000000000004000010b37201040a1200\" style=\"color:#CFD4DC\">https<\/span><span data-hk=\"000000010000000000004000010b37201040a1300\" style=\"color:#B99AFF\">?<\/span><span data-hk=\"000000010000000000004000010b37201040a1400\" style=\"color:#CFD4DC\">:\\\/\\\/<\/span><span data-hk=\"000000010000000000004000010b37201040a1500\" style=\"color:#B99AFF\">\/<\/span><span data-hk=\"000000010000000000004000010b37201040a1600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b37201040a1700\" style=\"color:#B99AFF\">\"\"<\/span><span data-hk=\"000000010000000000004000010b37201040a1800\" style=\"color:#CFD4DC\">).<\/span><span data-hk=\"000000010000000000004000010b37201040a1900\" style=\"color:#44CFFF\">replace<\/span><span data-hk=\"000000010000000000004000010b37201040a2000\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201040a2100\" style=\"color:#B99AFF\">\/<\/span><span data-hk=\"000000010000000000004000010b37201040a2200\" style=\"color:#CFD4DC\">\\\/<\/span><span data-hk=\"000000010000000000004000010b37201040a2300\" style=\"color:#9BE8FF\">.<\/span><span data-hk=\"000000010000000000004000010b37201040a2400\" style=\"color:#B99AFF\">*<\/span><span data-hk=\"000000010000000000004000010b37201040a2500\" style=\"color:#FF54C0\">$<\/span><span data-hk=\"000000010000000000004000010b37201040a2600\" style=\"color:#B99AFF\">\/<\/span><span data-hk=\"000000010000000000004000010b37201040a2700\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b37201040a2800\" style=\"color:#B99AFF\">\"\"<\/span><span data-hk=\"000000010000000000004000010b37201040a2900\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201050100\" style=\"color:#FF54C0\">      const<\/span><span data-hk=\"000000010000000000004000010b37201050200\" style=\"color:#C9A4FF\"> title<\/span><span data-hk=\"000000010000000000004000010b37201050300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b37201050400\" style=\"color:#9BE8FF\">s<\/span><span data-hk=\"000000010000000000004000010b37201050500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201050600\" style=\"color:#9BE8FF\">title<\/span><span data-hk=\"000000010000000000004000010b37201050700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201050800\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b37201050900\" style=\"color:#CFD4DC\"> &gt; <\/span><span data-hk=\"000000010000000000004000010b37201050a1000\" style=\"color:#B99AFF\">50<\/span><span data-hk=\"000000010000000000004000010b37201050a1100\" style=\"color:#FF54C0\"> ?<\/span><span data-hk=\"000000010000000000004000010b37201050a1200\" style=\"color:#9BE8FF\"> s<\/span><span data-hk=\"000000010000000000004000010b37201050a1300\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201050a1400\" style=\"color:#9BE8FF\">title<\/span><span data-hk=\"000000010000000000004000010b37201050a1500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201050a1600\" style=\"color:#44CFFF\">slice<\/span><span data-hk=\"000000010000000000004000010b37201050a1700\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201050a1800\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b37201050a1900\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b37201050a2000\" style=\"color:#B99AFF\">47<\/span><span data-hk=\"000000010000000000004000010b37201050a2100\" style=\"color:#CFD4DC\">) + <\/span><span data-hk=\"000000010000000000004000010b37201050a2200\" style=\"color:#B99AFF\">\"...\"<\/span><span data-hk=\"000000010000000000004000010b37201050a2300\" style=\"color:#FF54C0\"> :<\/span><span data-hk=\"000000010000000000004000010b37201050a2400\" style=\"color:#9BE8FF\"> s<\/span><span data-hk=\"000000010000000000004000010b37201050a2500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201050a2600\" style=\"color:#9BE8FF\">title<\/span><span data-hk=\"000000010000000000004000010b37201050a2700\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201060100\" style=\"color:#9BE8FF\">      lines<\/span><span data-hk=\"000000010000000000004000010b37201060200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201060300\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b37201060400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201060500\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b37201060600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201060700\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b37201060800\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201060900\" style=\"color:#B99AFF\">\"muted\"<\/span><span data-hk=\"000000010000000000004000010b37201060a1000\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b37201060a1100\" style=\"color:#B99AFF\">` <\/span><span data-hk=\"000000010000000000004000010b37201060a1200\" style=\"color:#CFD4DC\">\\u25b8<\/span><span data-hk=\"000000010000000000004000010b37201060a1300\" style=\"color:#FF54C0\"> ${<\/span><span data-hk=\"000000010000000000004000010b37201060a1400\" style=\"color:#9BE8FF\">title<\/span><span data-hk=\"000000010000000000004000010b37201060a1500\" style=\"color:#FF54C0\">}<\/span><span data-hk=\"000000010000000000004000010b37201060a1600\" style=\"color:#B99AFF\">`<\/span><span data-hk=\"000000010000000000004000010b37201060a1700\" style=\"color:#CFD4DC\">) + <\/span><span data-hk=\"000000010000000000004000010b37201060a1800\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b37201060a1900\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201060a2000\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b37201060a2100\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201060a2200\" style=\"color:#B99AFF\">\"dim\"<\/span><span data-hk=\"000000010000000000004000010b37201060a2300\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b37201060a2400\" style=\"color:#B99AFF\">` <\/span><span data-hk=\"000000010000000000004000010b37201060a2500\" style=\"color:#CFD4DC\">\\u00b7<\/span><span data-hk=\"000000010000000000004000010b37201060a2600\" style=\"color:#FF54C0\"> ${<\/span><span data-hk=\"000000010000000000004000010b37201060a2700\" style=\"color:#9BE8FF\">domain<\/span><span data-hk=\"000000010000000000004000010b37201060a2800\" style=\"color:#FF54C0\">}<\/span><span data-hk=\"000000010000000000004000010b37201060a2900\" style=\"color:#B99AFF\">`<\/span><span data-hk=\"000000010000000000004000010b37201060a3000\" style=\"color:#CFD4DC\">));<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201070100\" style=\"color:#CFD4DC\">    }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201080100\" style=\"color:#CFD4DC\">  }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b37201090100\" style=\"color:#9BE8FF\">  lines<\/span><span data-hk=\"000000010000000000004000010b37201090200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b37201090300\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b37201090400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b37201090500\" style=\"color:#B99AFF\">\"\"<\/span><span data-hk=\"000000010000000000004000010b37201090600\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a100100\" style=\"color:#CFD4DC\">} <\/span><span data-hk=\"000000010000000000004000010b372010a100200\" style=\"color:#FF54C0\">else<\/span><span data-hk=\"000000010000000000004000010b372010a100300\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a110100\" style=\"color:#FF54C0\">  const<\/span><span data-hk=\"000000010000000000004000010b372010a110200\" style=\"color:#C9A4FF\"> textContent<\/span><span data-hk=\"000000010000000000004000010b372010a110300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b372010a110400\" style=\"color:#9BE8FF\">result<\/span><span data-hk=\"000000010000000000004000010b372010a110500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a110600\" style=\"color:#9BE8FF\">content<\/span><span data-hk=\"000000010000000000004000010b372010a110700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a110800\" style=\"color:#44CFFF\">find<\/span><span data-hk=\"000000010000000000004000010b372010a110900\" style=\"color:#CFD4DC\">((<\/span><span data-hk=\"000000010000000000004000010b372010a110a1000\" style=\"color:#9BE8FF;fontStyle:italic\">c<\/span><span data-hk=\"000000010000000000004000010b372010a110a1100\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b372010a110a1200\" style=\"color:#FF54C0\">=&gt;<\/span><span data-hk=\"000000010000000000004000010b372010a110a1300\" style=\"color:#9BE8FF\"> c<\/span><span data-hk=\"000000010000000000004000010b372010a110a1400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a110a1500\" style=\"color:#9BE8FF\">type<\/span><span data-hk=\"000000010000000000004000010b372010a110a1600\" style=\"color:#CFD4DC\"> === <\/span><span data-hk=\"000000010000000000004000010b372010a110a1700\" style=\"color:#B99AFF\">\"text\"<\/span><span data-hk=\"000000010000000000004000010b372010a110a1800\" style=\"color:#CFD4DC\">)?.<\/span><span data-hk=\"000000010000000000004000010b372010a110a1900\" style=\"color:#9BE8FF\">text<\/span><span data-hk=\"000000010000000000004000010b372010a110a2000\" style=\"color:#CFD4DC\"> || <\/span><span data-hk=\"000000010000000000004000010b372010a110a2100\" style=\"color:#B99AFF\">\"\"<\/span><span data-hk=\"000000010000000000004000010b372010a110a2200\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a120100\" style=\"color:#FF54C0\">  const<\/span><span data-hk=\"000000010000000000004000010b372010a120200\" style=\"color:#C9A4FF\"> preview<\/span><span data-hk=\"000000010000000000004000010b372010a120300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b372010a120400\" style=\"color:#9BE8FF\">textContent<\/span><span data-hk=\"000000010000000000004000010b372010a120500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a120600\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b372010a120700\" style=\"color:#CFD4DC\"> &gt; <\/span><span data-hk=\"000000010000000000004000010b372010a120800\" style=\"color:#B99AFF\">500<\/span><span data-hk=\"000000010000000000004000010b372010a120900\" style=\"color:#FF54C0\"> ?<\/span><span data-hk=\"000000010000000000004000010b372010a120a1000\" style=\"color:#9BE8FF\"> textContent<\/span><span data-hk=\"000000010000000000004000010b372010a120a1100\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a120a1200\" style=\"color:#44CFFF\">slice<\/span><span data-hk=\"000000010000000000004000010b372010a120a1300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a120a1400\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b372010a120a1500\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a120a1600\" style=\"color:#B99AFF\">500<\/span><span data-hk=\"000000010000000000004000010b372010a120a1700\" style=\"color:#CFD4DC\">) + <\/span><span data-hk=\"000000010000000000004000010b372010a120a1800\" style=\"color:#B99AFF\">\"...\"<\/span><span data-hk=\"000000010000000000004000010b372010a120a1900\" style=\"color:#FF54C0\"> :<\/span><span data-hk=\"000000010000000000004000010b372010a120a2000\" style=\"color:#9BE8FF\"> textContent<\/span><span data-hk=\"000000010000000000004000010b372010a120a2100\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a130100\" style=\"color:#FF54C0\">  for<\/span><span data-hk=\"000000010000000000004000010b372010a130200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b372010a130300\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b372010a130400\" style=\"color:#C9A4FF\"> line<\/span><span data-hk=\"000000010000000000004000010b372010a130500\" style=\"color:#FF54C0\"> of<\/span><span data-hk=\"000000010000000000004000010b372010a130600\" style=\"color:#9BE8FF\"> preview<\/span><span data-hk=\"000000010000000000004000010b372010a130700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a130800\" style=\"color:#44CFFF\">split<\/span><span data-hk=\"000000010000000000004000010b372010a130900\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a130a1000\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b372010a130a1100\" style=\"color:#CFD4DC\">\\n<\/span><span data-hk=\"000000010000000000004000010b372010a130a1200\" style=\"color:#B99AFF\">\"<\/span><span data-hk=\"000000010000000000004000010b372010a130a1300\" style=\"color:#CFD4DC\">)) <\/span><span data-hk=\"000000010000000000004000010b372010a130a1400\" style=\"color:#9BE8FF\">lines<\/span><span data-hk=\"000000010000000000004000010b372010a130a1500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a130a1600\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b372010a130a1700\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a130a1800\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b372010a130a1900\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a130a2000\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b372010a130a2100\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a130a2200\" style=\"color:#B99AFF\">\"dim\"<\/span><span data-hk=\"000000010000000000004000010b372010a130a2300\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a130a2400\" style=\"color:#9BE8FF\">line<\/span><span data-hk=\"000000010000000000004000010b372010a130a2500\" style=\"color:#CFD4DC\">));<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a140100\" style=\"color:#CFD4DC\">}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1500\" class=\"line \"\/>\n<span data-hk=\"000000010000000000004000010b372010a1600\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a160100\" style=\"color:#FF54C0\">if<\/span><span data-hk=\"000000010000000000004000010b372010a160200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b372010a160300\" style=\"color:#9BE8FF\">details<\/span><span data-hk=\"000000010000000000004000010b372010a160400\" style=\"color:#CFD4DC\">?.<\/span><span data-hk=\"000000010000000000004000010b372010a160500\" style=\"color:#9BE8FF\">fetchUrls<\/span><span data-hk=\"000000010000000000004000010b372010a160600\" style=\"color:#CFD4DC\">?.<\/span><span data-hk=\"000000010000000000004000010b372010a160700\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b372010a160800\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1700\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a170100\" style=\"color:#FF54C0\">  if<\/span><span data-hk=\"000000010000000000004000010b372010a170200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b372010a170300\" style=\"color:#9BE8FF\">details<\/span><span data-hk=\"000000010000000000004000010b372010a170400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a170500\" style=\"color:#9BE8FF\">curated<\/span><span data-hk=\"000000010000000000004000010b372010a170600\" style=\"color:#CFD4DC\">) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1800\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a180100\" style=\"color:#9BE8FF\">    lines<\/span><span data-hk=\"000000010000000000004000010b372010a180200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a180300\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b372010a180400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a180500\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b372010a180600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a180700\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b372010a180800\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a180900\" style=\"color:#B99AFF\">\"muted\"<\/span><span data-hk=\"000000010000000000004000010b372010a180a1000\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a180a1100\" style=\"color:#B99AFF\">`Fetching <\/span><span data-hk=\"000000010000000000004000010b372010a180a1200\" style=\"color:#FF54C0\">${<\/span><span data-hk=\"000000010000000000004000010b372010a180a1300\" style=\"color:#9BE8FF\">details<\/span><span data-hk=\"000000010000000000004000010b372010a180a1400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a180a1500\" style=\"color:#9BE8FF\">fetchUrls<\/span><span data-hk=\"000000010000000000004000010b372010a180a1600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a180a1700\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b372010a180a1800\" style=\"color:#FF54C0\">}<\/span><span data-hk=\"000000010000000000004000010b372010a180a1900\" style=\"color:#B99AFF\"> URLs in background`<\/span><span data-hk=\"000000010000000000004000010b372010a180a2000\" style=\"color:#CFD4DC\">));<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a1900\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a190100\" style=\"color:#CFD4DC\">  } <\/span><span data-hk=\"000000010000000000004000010b372010a190200\" style=\"color:#FF54C0\">else<\/span><span data-hk=\"000000010000000000004000010b372010a190300\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2000\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a200100\" style=\"color:#9BE8FF\">    lines<\/span><span data-hk=\"000000010000000000004000010b372010a200200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a200300\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b372010a200400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a200500\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b372010a200600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a200700\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b372010a200800\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a200900\" style=\"color:#B99AFF\">\"muted\"<\/span><span data-hk=\"000000010000000000004000010b372010a200a1000\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a200a1100\" style=\"color:#B99AFF\">\"Fetching:\"<\/span><span data-hk=\"000000010000000000004000010b372010a200a1200\" style=\"color:#CFD4DC\">));<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2100\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a210100\" style=\"color:#FF54C0\">    for<\/span><span data-hk=\"000000010000000000004000010b372010a210200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b372010a210300\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b372010a210400\" style=\"color:#C9A4FF\"> u<\/span><span data-hk=\"000000010000000000004000010b372010a210500\" style=\"color:#FF54C0\"> of<\/span><span data-hk=\"000000010000000000004000010b372010a210600\" style=\"color:#9BE8FF\"> details<\/span><span data-hk=\"000000010000000000004000010b372010a210700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a210800\" style=\"color:#9BE8FF\">fetchUrls<\/span><span data-hk=\"000000010000000000004000010b372010a210900\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a210a1000\" style=\"color:#44CFFF\">slice<\/span><span data-hk=\"000000010000000000004000010b372010a210a1100\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a210a1200\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b372010a210a1300\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a210a1400\" style=\"color:#B99AFF\">5<\/span><span data-hk=\"000000010000000000004000010b372010a210a1500\" style=\"color:#CFD4DC\">)) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2200\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a220100\" style=\"color:#FF54C0\">      const<\/span><span data-hk=\"000000010000000000004000010b372010a220200\" style=\"color:#C9A4FF\"> display<\/span><span data-hk=\"000000010000000000004000010b372010a220300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b372010a220400\" style=\"color:#9BE8FF\">u<\/span><span data-hk=\"000000010000000000004000010b372010a220500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a220600\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b372010a220700\" style=\"color:#CFD4DC\"> &gt; <\/span><span data-hk=\"000000010000000000004000010b372010a220800\" style=\"color:#B99AFF\">60<\/span><span data-hk=\"000000010000000000004000010b372010a220900\" style=\"color:#FF54C0\"> ?<\/span><span data-hk=\"000000010000000000004000010b372010a220a1000\" style=\"color:#9BE8FF\"> u<\/span><span data-hk=\"000000010000000000004000010b372010a220a1100\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a220a1200\" style=\"color:#44CFFF\">slice<\/span><span data-hk=\"000000010000000000004000010b372010a220a1300\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a220a1400\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b372010a220a1500\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a220a1600\" style=\"color:#B99AFF\">57<\/span><span data-hk=\"000000010000000000004000010b372010a220a1700\" style=\"color:#CFD4DC\">) + <\/span><span data-hk=\"000000010000000000004000010b372010a220a1800\" style=\"color:#B99AFF\">\"...\"<\/span><span data-hk=\"000000010000000000004000010b372010a220a1900\" style=\"color:#FF54C0\"> :<\/span><span data-hk=\"000000010000000000004000010b372010a220a2000\" style=\"color:#9BE8FF\"> u<\/span><span data-hk=\"000000010000000000004000010b372010a220a2100\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2300\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a230100\" style=\"color:#9BE8FF\">      lines<\/span><span data-hk=\"000000010000000000004000010b372010a230200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a230300\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b372010a230400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a230500\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b372010a230600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a230700\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b372010a230800\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a230900\" style=\"color:#B99AFF\">\"dim\"<\/span><span data-hk=\"000000010000000000004000010b372010a230a1000\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a230a1100\" style=\"color:#B99AFF\">\"  \"<\/span><span data-hk=\"000000010000000000004000010b372010a230a1200\" style=\"color:#CFD4DC\"> + <\/span><span data-hk=\"000000010000000000004000010b372010a230a1300\" style=\"color:#9BE8FF\">display<\/span><span data-hk=\"000000010000000000004000010b372010a230a1400\" style=\"color:#CFD4DC\">));<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2400\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a240100\" style=\"color:#CFD4DC\">    }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2500\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a250100\" style=\"color:#FF54C0\">    if<\/span><span data-hk=\"000000010000000000004000010b372010a250200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b372010a250300\" style=\"color:#9BE8FF\">details<\/span><span data-hk=\"000000010000000000004000010b372010a250400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a250500\" style=\"color:#9BE8FF\">fetchUrls<\/span><span data-hk=\"000000010000000000004000010b372010a250600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a250700\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b372010a250800\" style=\"color:#CFD4DC\"> &gt; <\/span><span data-hk=\"000000010000000000004000010b372010a250900\" style=\"color:#B99AFF\">5<\/span><span data-hk=\"000000010000000000004000010b372010a250a1000\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b372010a250a1100\" style=\"color:#9BE8FF\">lines<\/span><span data-hk=\"000000010000000000004000010b372010a250a1200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a250a1300\" style=\"color:#44CFFF\">push<\/span><span data-hk=\"000000010000000000004000010b372010a250a1400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a250a1500\" style=\"color:#9BE8FF\">theme<\/span><span data-hk=\"000000010000000000004000010b372010a250a1600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a250a1700\" style=\"color:#44CFFF\">fg<\/span><span data-hk=\"000000010000000000004000010b372010a250a1800\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b372010a250a1900\" style=\"color:#B99AFF\">\"dim\"<\/span><span data-hk=\"000000010000000000004000010b372010a250a2000\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b372010a250a2100\" style=\"color:#B99AFF\">`  ... and <\/span><span data-hk=\"000000010000000000004000010b372010a250a2200\" style=\"color:#FF54C0\">${<\/span><span data-hk=\"000000010000000000004000010b372010a250a2300\" style=\"color:#9BE8FF\">details<\/span><span data-hk=\"000000010000000000004000010b372010a250a2400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a250a2500\" style=\"color:#9BE8FF\">fetchUrls<\/span><span data-hk=\"000000010000000000004000010b372010a250a2600\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b372010a250a2700\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b372010a250a2800\" style=\"color:#CFD4DC\"> - <\/span><span data-hk=\"000000010000000000004000010b372010a250a2900\" style=\"color:#B99AFF\">5<\/span><span data-hk=\"000000010000000000004000010b372010a250a3000\" style=\"color:#FF54C0\">}<\/span><span data-hk=\"000000010000000000004000010b372010a250a3100\" style=\"color:#B99AFF\"> more`<\/span><span data-hk=\"000000010000000000004000010b372010a250a3200\" style=\"color:#CFD4DC\">));<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2600\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a260100\" style=\"color:#CFD4DC\">  }<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b372010a2700\" class=\"line \"><span data-hk=\"000000010000000000004000010b372010a270100\" style=\"color:#CFD4DC\">}<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b37300\">There is quite a bit wrong here:<\/p>\n<ol data-hk=\"000000010000000000004000010b37400\">\n<li data-hk=\"000000010000000000004000010b3740100\">It&#8217;s slicing text by codepoints rather than visible width, so it will break out of its line and<br \/>\nsmash everything below it once you resize under 40 columns<\/li>\n<li data-hk=\"000000010000000000004000010b3740200\">There is no awareness of the terminal width, so even if you have space, you get an ellipsis!<\/li>\n<li data-hk=\"000000010000000000004000010b3740300\">Most importantly, it ignores the first rule of Pi components &amp; does not sanitize external input,<br \/>\nmeaning the thing it&#8217;s fetching can just feed it the right ANSI escapes and replace your entire<br \/>\nUI with a picture of a duck.<br \/>\n<a data-hk=\"000000010000000000004000010b374030100\" href=\"https:\/\/www.sentinelone.com\/vulnerability-database\/cve-2023-32712\/\">Definitely<\/a><br \/>\n<a data-hk=\"000000010000000000004000010b374030200\" href=\"https:\/\/socprime.com\/active-threats\/cve-2025-55752\/\">nothing<\/a><br \/>\n<a data-hk=\"000000010000000000004000010b374030300\" href=\"https:\/\/github.com\/boxdot\/gurk-rs\/issues\/384\">else<\/a><br \/>\n<a data-hk=\"000000010000000000004000010b374030400\" href=\"https:\/\/www.packetlabs.net\/posts\/weaponizing-ansi-escape-sequences\/\">can<\/a> be done with this!<\/li>\n<\/ol>\n<p data-hk=\"000000010000000000004000010b37500\">This sort of thing is natural when you push the complexity down onto the unsuspecting developer \u2014<br \/>\noften Claude.<\/p>\n<p data-hk=\"000000010000000000004000010b37600\">An LLM is not going to remember every internal detail of your harness each time it is asked to &#8220;make<br \/>\ntool UI pls&#8221;. Hell, I don&#8217;t really want to either sometimes, and the smoke test will pass as usable.<\/p>\n<p data-hk=\"000000010000000000004000010b37700\">The performance, security, and consistency problems have the same cause: an already-rendered string<br \/>\nis being used as layout tree, style tree, content, transport, and terminal program at once.<\/p>\n<h3 data-hk=\"000000010000000000004000010b37800\" id=\"what-omp-changes-a-one-pass-primitive\">What omp\u00b2 changes: a one-pass primitive<\/h3>\n<p data-hk=\"000000010000000000004000010b37900\">The lowest-level consumers (i.e. not you, unless you make a PR) push <em data-hk=\"000000010000000000004000010b3790100\">RichText<\/em><br \/>\n<code data-hk=\"000000010000000000004000010b3790200\">(Style, String)<\/code> into the abstract pipeline <code data-hk=\"000000010000000000004000010b3790300\">(&amp;mut impl Out)<\/code> handed to them.<\/p>\n<p data-hk=\"000000010000000000004000010b38000\">This cuts the 267 seconds of render time to 90ms:<\/p>\n<figure data-hk=\"000000010000000000004000010b381\"><!--$--><svg data-hk=\"000000010000000000004000010b38200\" class=\"st-sketch\" viewbox=\"0 0 1000 772\" role=\"img\" aria-label=\"Render pipeline: before, N + N\u00b7M buffers per frame; after, a single-pass sink with an O(cache) RichText replay\" font-family=\"var(--st-font-sketch)\"><defs><pattern id=\"pl-dots\" width=\"22\" height=\"22\" patternunits=\"userSpaceOnUse\"><circle cx=\"11\" cy=\"11\" r=\"1.1\" fill=\"#2E333C\"\/><\/pattern><\/defs><rect width=\"1000\" height=\"772\" fill=\"#121419\"\/><rect width=\"1000\" height=\"772\" fill=\"url(#pl-dots)\"\/><!--$--><text data-hk=\"000000010000000000004000010b3820100\" x=\"500\" y=\"48\" font-size=\"26\" fill=\"#DBD8CF\" text-anchor=\"middle\" letter-spacing=\"2\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">RENDER ONCE, REPLAY FOREVER<\/text><path data-hk=\"000000010000000000004000010b3820110\" d=\"M219.6 59.1C397.5 59 594.7 60 780.9 60.3M219.2 59.6C460.8 61 638.4 61.7 780.3 59.7\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"2\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b382020\" x=\"48\" y=\"112\" font-size=\"16\" fill=\"#F4644A\" stroke=\"#F4644A\" stroke-width=\"0.8\">before<\/text><text data-hk=\"000000010000000000004000010b382030\" x=\"130\" y=\"112\" font-size=\"13\" fill=\"#9AA2AD\">render(): string[]<\/text><rect data-hk=\"000000010000000000004000010b382040\" x=\"49.5\" y=\"145.5\" width=\"117\" height=\"39\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b382041\" d=\"M49.1 142.5C84.8 145.1 135.5 143.9 167.3 142.7M48.2 145.4C86.1 145.8 136.9 144.6 168.3 143.4M169.4 143.6C167.5 159.8 168.6 181.4 166.8 186.7M168.2 143.8C168.6 161.6 168.8 173.4 167.9 186.6M168.7 185.7C127.9 187 86.1 185.6 48.1 184.6M169.3 184.6C108.4 187.1 81.8 186.9 47.2 186.7M48.3 185.7C47.3 170.6 47.3 153.6 48.6 142.9M48.5 186.2C47.2 165 48.2 156 47.8 141.5\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b382050\" x=\"108\" y=\"170\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">string[]<\/text><rect data-hk=\"000000010000000000004000010b382060\" x=\"249.5\" y=\"145.5\" width=\"117\" height=\"39\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b382061\" d=\"M246.4 143C284.1 142.9 330.4 144.1 367 142.8M246.6 143.1C285 146 345.1 144.9 369.5 143.4M367.8 144.3C369 160.1 367.8 173.6 368.9 185.4M367.8 142.9C370.1 158 367.8 177.8 367 185.9M369.4 186.8C319.3 186.9 282.3 187.7 246 185M369.3 185C327.2 187.7 266.7 187.5 245.3 187M248.5 186.6C246.7 167.8 246.8 152.3 248.9 143.8M248.4 187.3C248.3 168.9 249.1 157.8 248 144.1\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b382070\" x=\"308\" y=\"170\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">string[]&#8217;<\/text><rect data-hk=\"000000010000000000004000010b382080\" x=\"449.5\" y=\"145.5\" width=\"117\" height=\"39\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b382081\" d=\"M446.4 143.3C507.3 143 544.8 143.4 568 144M447.4 144.8C494.6 141.9 545.4 144.1 567.9 145.2M566.5 142.2C568.8 157.1 567.5 178.5 566.8 186.2M567.8 143.3C566.9 163.3 568.8 175.9 569.4 186.8M570.6 185.9C514.5 185.4 465.5 187.9 445.9 186.2M568.6 184.9C533.4 187.9 479.4 185.7 447.6 186.7M449.1 189.6C447.9 166.6 447.4 158.5 448 141.4M448.4 187.8C449.7 169.5 446.3 149.5 449 142.6\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b382090\" x=\"508\" y=\"170\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">string[]&#8221;<\/text><rect data-hk=\"000000010000000000004000010b3820a100\" x=\"649.5\" y=\"145.5\" width=\"117\" height=\"39\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b3820a101\" d=\"M645.6 142.7C694.7 143.5 743.6 143.6 771 143.5M647.6 145.5C692.6 143.1 748.3 143.8 771.5 144.8M768.8 142C766.7 157.1 767.9 177.4 768.6 186.3M766.6 142.2C769.4 163.3 766.7 178 768.9 186M770.3 187.3C730.3 185 680.4 185.8 645.4 186.6M770.8 186.3C713.4 187.7 687.5 186.4 645.3 186.4M646.7 188.1C646.9 174 648.7 151.2 646.6 144.2M647.4 187.2C648.9 169.7 649.1 154.6 649.4 142\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a110\" x=\"708\" y=\"170\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\">string[]&#8221;&#8217;<\/text><rect data-hk=\"000000010000000000004000010b3820a120\" x=\"849.5\" y=\"145.5\" width=\"101\" height=\"39\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b3820a121\" d=\"M847.7 143.8C896.3 143.1 927.1 143.1 955.3 143.8M847.3 143.2C895.9 143.2 923.7 144 953 145.5M951.6 143.8C952.3 162 950.1 174.1 951.3 187.3M951.3 142.4C953.9 156.5 952.2 177.8 952.3 187.1M953.2 185.8C908.7 186.9 868.1 184.9 847.6 186.8M953.5 187.4C912.4 183.1 882.2 184.6 846.4 186.2M848.9 186.8C847 168 847.9 152 848.4 145M848.1 186.6C847.3 166.2 848.6 150 847.5 142.9\" fill=\"none\" stroke=\"#F4644A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a130\" x=\"900\" y=\"163\" font-size=\"13\" fill=\"#DBD8CF\" text-anchor=\"middle\">parent<\/text><text data-hk=\"000000010000000000004000010b3820a140\" x=\"900\" y=\"179\" font-size=\"13\" fill=\"#DBD8CF\" text-anchor=\"middle\">string[]<\/text><path data-hk=\"000000010000000000004000010b3820a150\" d=\"M167.2 164.2C200 164.2 218.3 165.7 243.4 166.1M168.9 165C200.2 164.7 220.5 164.1 244.2 163.1M243.9 164.8C239.9 166.8 236.4 168.2 234.1 169.7M243.7 165.2C239.2 167.5 237.4 168.1 233.9 169.4M243.7 165C239.9 163.6 237.6 162.2 233.8 160.6M243.8 164.8C240.3 164 236.6 161.5 233.7 160.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b3820a160\" d=\"M367.5 163.8C400.9 165.7 427.8 164.5 443.8 162.6M367.1 165C406.6 164.6 421.7 167.2 443.5 166.4M444.3 165.1C440.6 166.4 435.6 168.8 433.8 169.8M444.1 164.8C438.7 167.2 435.5 168.7 433.8 169.8M444.1 165.3C440 163.2 435.8 161.2 433.7 160.2M443.8 164.9C439.8 163.6 437.2 162.1 434.1 160.2\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b3820a170\" d=\"M567.1 164.3C598.6 165 623.4 164.8 644.9 163.1M567.9 164.9C597.6 165.2 618.8 166.3 645.9 166.1M644.1 165.2C640.1 166.6 635.5 168.6 634.1 169.7M644.2 165.3C639.4 166.9 637.1 168.8 633.6 169.2M643.7 165.1C639.7 163.1 637 162.2 634.1 160.8M644.2 164.7C639.3 162.8 635.7 160.8 633.9 160.5\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b3820a180\" d=\"M766.4 166.5C803.9 164.4 823.9 164.7 842.8 164.7M767.7 163.7C796.3 164.3 825 162.6 844.4 164M844 165.3C839.3 166.4 836.9 168.3 833.7 169.3M844.2 165.3C839.3 167.5 836.3 168.9 833.8 169.4M843.8 165.1C840.4 163.1 837.2 162.1 834.3 160.4M843.8 165.2C839.5 162.9 835.9 161.5 834.1 160.6\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a190\" x=\"206\" y=\"138\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\" transform=\"rotate(-1.5 206 138)\">parse<\/text><text data-hk=\"000000010000000000004000010b3820a200\" x=\"406\" y=\"138\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\" transform=\"rotate(1 406 138)\">wrap<\/text><text data-hk=\"000000010000000000004000010b3820a210\" x=\"606\" y=\"138\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\" transform=\"rotate(-1 606 138)\">pad<\/text><text data-hk=\"000000010000000000004000010b3820a220\" x=\"806\" y=\"138\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\" transform=\"rotate(1.5 806 138)\">concat<\/text><text data-hk=\"000000010000000000004000010b3820a230\" x=\"206\" y=\"202\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\">alloc<\/text><text data-hk=\"000000010000000000004000010b3820a240\" x=\"406\" y=\"202\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\">alloc<\/text><text data-hk=\"000000010000000000004000010b3820a250\" x=\"606\" y=\"202\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\">alloc<\/text><text data-hk=\"000000010000000000004000010b3820a260\" x=\"806\" y=\"202\" font-size=\"13\" fill=\"#F4644A\" text-anchor=\"middle\">alloc<\/text><text data-hk=\"000000010000000000004000010b3820a270\" x=\"48\" y=\"236\" font-size=\"13\" fill=\"#9AA2AD\">N components \u00d7 M transforms \u2014 every buffer re-parsed, re-measured, thrown away. Every frame.<\/text><path data-hk=\"000000010000000000004000010b3820a280\" d=\"M47.4 274.6C427.3 271.2 639.7 275.7 950.7 273.2M46.7 272.6C455.2 275.1 638.7 274.8 952.1 274.4\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a290\" x=\"48\" y=\"324\" font-size=\"16\" fill=\"#4ADE80\" stroke=\"#4ADE80\" stroke-width=\"0.8\">after<\/text><text data-hk=\"000000010000000000004000010b3820a300\" x=\"122\" y=\"324\" font-size=\"13\" fill=\"#9AA2AD\">push run(style, &amp;str) into a sink<\/text><text data-hk=\"000000010000000000004000010b3820a310\" x=\"48\" y=\"392\" font-size=\"14\" fill=\"#DBD8CF\">markdown<\/text><text data-hk=\"000000010000000000004000010b3820a320\" x=\"48\" y=\"422\" font-size=\"14\" fill=\"#DBD8CF\">latex \u00b7 syntax<\/text><text data-hk=\"000000010000000000004000010b3820a330\" x=\"48\" y=\"452\" font-size=\"14\" fill=\"#44CFFF\">decompose(ansi)<\/text><text data-hk=\"000000010000000000004000010b3820a340\" x=\"48\" y=\"480\" font-size=\"13\" fill=\"#9AA2AD\">external text, parsed once<\/text><path data-hk=\"000000010000000000004000010b3820a350\" d=\"M179 389Q221.2 396.8 235.5 405.4L249.8 414.1M181 388.5Q220.8 397.1 234.8 405.3L248.9 413.4M250.2 413.9C246.5 413.2 241.8 413.2 239.4 412.3M249.9 414.3C245.1 413.3 242.7 413.4 238.9 412.6M250.3 413.7C247.7 411.2 245.9 407.1 244.2 404.9M250.2 413.9C247.4 410.1 245 406.8 244 404.9\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b3820a360\" d=\"M176.1 418.9C203.8 417.9 230.2 416.6 249.6 417.8M178.5 417C202 418.6 234.3 418.9 250.7 419.3M249.9 418.9C245.4 421 242 422.6 239.8 423.6M250.1 419.1C246.6 420.3 243.3 421.9 240.1 423.5M250.2 419.1C245.1 416.8 241.2 415 240.3 414.2M249.7 418.8C245.7 417.4 242 415.7 240 414.7\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b3820a370\" d=\"M185.1 448.3Q223 441.4 235.9 432.9L248.7 424.3M187.1 448.9Q222.7 440.9 236.2 432L249.7 423.1M250.3 424C247.7 426.7 245.3 431.3 243.7 432.9M249.8 424.2C247.9 427.2 244.9 431.6 243.9 433.5M249.7 424.2C245.2 424.7 242.5 425.5 239.3 425.5M250.1 424C246.3 424.7 240.9 425.4 238.9 425.4\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010b3820a380\" x=\"257.5\" y=\"397.5\" width=\"313\" height=\"45\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b3820a381\" d=\"M254.5 396C407.3 397.3 478.5 394.3 573.3 396.3M254.5 395.3C400.3 396.1 519 394.1 573 396.4M570.7 393.8C573 409.5 574.3 431.4 573.1 444.7M571.7 394.5C572.7 419.5 573.6 433.7 572.5 445.5M574.8 444.5C422.5 443.4 302.4 443.5 254.9 442.9M574 444.6C456 441.5 359 440.5 255.2 443.6M254.8 444.3C254.9 427.7 257.6 403.7 257 394.9M255.8 445.4C255.5 428.3 257.1 408.8 255.3 395\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b3820a390\" d=\"M362.9 398.3C363.8 413.4 361.5 427.3 363.4 440.8M363 396.9C363.1 412.7 362.2 429 362.6 441.8\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"1\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><path data-hk=\"000000010000000000004000010b3820a400\" d=\"M467.9 398.9C468.1 414.4 468.4 425.8 469.4 442.9M467.5 396.6C466.6 419.5 467.9 434.4 467.2 441.1\" fill=\"none\" stroke=\"#44CFFF\" stroke-width=\"1\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><text data-hk=\"000000010000000000004000010b3820a410\" x=\"309\" y=\"426\" font-size=\"13.5\" fill=\"#44CFFF\" text-anchor=\"middle\">.wrap(w)<\/text><text data-hk=\"000000010000000000004000010b3820a420\" x=\"415\" y=\"426\" font-size=\"13.5\" fill=\"#44CFFF\" text-anchor=\"middle\">.clip(w,&#8217;\u2026&#8217;)<\/text><text data-hk=\"000000010000000000004000010b3820a430\" x=\"520\" y=\"426\" font-size=\"13.5\" fill=\"#44CFFF\" text-anchor=\"middle\">.restyle(f)<\/text><text data-hk=\"000000010000000000004000010b3820a440\" x=\"414\" y=\"472\" font-size=\"13\" fill=\"#4ADE80\" text-anchor=\"middle\" transform=\"rotate(-0.7 414 472)\">single pass \u00b7 no intermediate row buffers<\/text><path data-hk=\"000000010000000000004000010b3820a450\" d=\"M572.4 418C614.2 419.7 640.4 421.7 661 421.4M571.5 422.1C604.9 421.8 635.5 420.1 659 418.6M660.1 420.3C657.3 421.3 653.1 423.4 649.7 424.7M660.4 420C655.9 422 651.6 423.3 649.7 424.3M659.9 420C654.8 418.3 652.5 417 650.2 415.7M659.9 419.7C656.2 418.2 653.2 416.9 649.8 415.9\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><path data-hk=\"000000010000000000004000010b3820a460\" d=\"M791.1 420.4C820.6 419.4 842.9 420.8 869.6 421.6M792.7 420.9C824.5 422 851.1 418.2 867.8 422M868.3 420.2C863.8 421.7 860.4 423.4 858.3 424.6M867.7 420C864.9 421.7 860.9 422.8 857.7 424.3M868.1 420.1C864.8 418.8 860.2 416.6 858.3 415.5M868.1 420.2C863.2 417.8 861.1 417 858.2 415.7\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><rect data-hk=\"000000010000000000004000010b3820a470\" x=\"665.5\" y=\"397.5\" width=\"121\" height=\"45\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b3820a471\" d=\"M663.6 396.4C706.6 395.4 757.7 393.6 788.3 396.3M662 395.5C717.6 397.4 768.2 397 788.7 397.2M788.8 393.8C790.3 408.7 789.3 431.1 786.6 444M788.2 393.1C788.5 419 787.1 429.4 789.1 444.7M788.7 443.6C738.8 445 701.8 443.3 661.8 444.9M788.7 443.5C742.1 445.4 704.9 442.6 662.1 443.3M664.1 444.4C664 423.2 664.5 406.9 665.3 394.7M662.5 446.7C664 420.2 662.8 407 664.5 392.9\" fill=\"none\" stroke=\"#DBD8CF\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a480\" x=\"726\" y=\"426\" font-size=\"14\" fill=\"#DBD8CF\" text-anchor=\"middle\" stroke=\"#DBD8CF\" stroke-width=\"0.8\">Frame<\/text><text data-hk=\"000000010000000000004000010b3820a490\" x=\"830\" y=\"410\" font-size=\"13\" fill=\"#9AA2AD\" text-anchor=\"middle\">diff<\/text><rect data-hk=\"000000010000000000004000010b3820a500\" x=\"873.5\" y=\"397.5\" width=\"77\" height=\"45\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b3820a501\" d=\"M872.9 395.9C896 396.5 927.3 396.4 955 396.7M873 396C900.9 397.4 932.6 396 953.4 395.4M953.3 397C952.9 410.1 951 432.4 952.1 443.2M952.7 395.4C953 417.8 952.5 427.9 951.2 443.9M954.4 443.1C925.4 445.8 882.8 444.4 870.7 444.7M952.7 444.5C929.4 446.3 883.8 444.8 869.4 442.8M870.9 444.8C871.9 427.7 870.9 409.1 873.2 393.8M871.5 446.7C871.8 425.4 870.7 409.4 871.2 395\" fill=\"none\" stroke=\"#4ADE80\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a510\" x=\"912\" y=\"426\" font-size=\"14\" fill=\"#4ADE80\" text-anchor=\"middle\" stroke=\"#4ADE80\" stroke-width=\"0.8\">stdout<\/text><text data-hk=\"000000010000000000004000010b3820a520\" x=\"952\" y=\"472\" font-size=\"13\" fill=\"#9AA2AD\" text-anchor=\"end\">ANSI written here, once<\/text><path data-hk=\"000000010000000000004000010b3820a530\" d=\"M615.1 419Q607.6 481.4 586.6 498.3Q565.6 515.1 543.1 530.1L520.5 545.2M613.2 419Q607.1 481.7 586.8 498.7Q566.5 515.8 542.8 530.4L519.1 544.9M520.1 544.3C522.6 540 524 537.9 526.2 534.8M519.7 543.7C522.9 540.6 525.4 536.6 526.5 535.1M520 543.8C525.5 543.7 528.7 542.6 530.6 542.3M519.7 543.8C524.1 544 527.7 543 530.6 542.4\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a540\" x=\"628\" y=\"498\" font-size=\"13\" fill=\"#F5B04A\" transform=\"rotate(-2 628 498)\">.tee(cache)<\/text><rect data-hk=\"000000010000000000004000010b3820a550\" x=\"257.5\" y=\"545.5\" width=\"313\" height=\"121\" rx=\"0\" fill=\"#1A1E25\"\/><path data-hk=\"000000010000000000004000010b3820a551\" d=\"M254.2 543.7C362 542 521.3 543.3 573.1 544M255.4 542.8C351.7 541.4 510.2 547 572.5 543.7M572.4 543.4C571.6 588 571.1 643.7 572.4 667.4M572.9 542.6C572.8 589.7 570.8 624.8 570.8 669.3M574.7 668.1C446.3 668.8 323.5 668.4 255.1 668.6M573 669C468.1 664.4 320.1 670 254.6 667M255.5 668.2C256.2 614.7 257.6 585.2 257.3 542.3M255.9 669.2C257 609.7 254.5 564.1 256.2 540.9\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"1.5\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a560\" x=\"280\" y=\"576\" font-size=\"15\" fill=\"#F5B04A\" stroke=\"#F5B04A\" stroke-width=\"0.8\">RichText<\/text><text data-hk=\"000000010000000000004000010b3820a570\" x=\"280\" y=\"604\" font-size=\"13.5\" fill=\"#DBD8CF\">pool: String<\/text><text data-hk=\"000000010000000000004000010b3820a580\" x=\"280\" y=\"626\" font-size=\"13.5\" fill=\"#DBD8CF\">runs: [(Style, ..end)]<\/text><text data-hk=\"000000010000000000004000010b3820a590\" x=\"280\" y=\"648\" font-size=\"13.5\" fill=\"#DBD8CF\">rows: [(run_end, width)]<\/text><text data-hk=\"000000010000000000004000010b3820a600\" x=\"256\" y=\"694\" font-size=\"13\" fill=\"#9AA2AD\">clear() keeps capacity \u2014 streaming re-renders allocate nothing<\/text><path data-hk=\"000000010000000000004000010b3820a610\" d=\"M575.1 606.4Q675.8 596.8 699.2 558.9Q722.7 520.9 724.7 485L726.7 449.2M575.6 607Q676.1 597 699.5 559.5Q722.9 522.1 724.3 485.4L725.7 448.8M726.1 449.9C727.6 454.5 729.3 458.6 729.8 460.3M726.1 449.6C727.4 454.7 728.8 457.2 729.8 460M725.9 450.3C724.1 453.2 722.9 456.3 721.3 459.8M726.3 450.1C723.9 454.3 721.7 458.5 721.2 459.6\" fill=\"none\" stroke=\"#F5B04A\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-dasharray=\"6 5\"\/><text data-hk=\"000000010000000000004000010b3820a620\" x=\"746\" y=\"566\" font-size=\"13\" fill=\"#F5B04A\" transform=\"rotate(-1 746 566)\">replay()<\/text><text data-hk=\"000000010000000000004000010b3820a630\" x=\"746\" y=\"584\" font-size=\"13\" fill=\"#9AA2AD\">next frame, no re-render<\/text><path data-hk=\"000000010000000000004000010b3820a640\" d=\"M48.8 717.8C459.1 721 764.8 719.3 952 718.1M47 718.8C378.3 718.9 635.3 718.9 952.6 717.4\" fill=\"none\" stroke=\"#9AA2AD\" stroke-width=\"1\" stroke-linecap=\"round\"\/><text data-hk=\"000000010000000000004000010b3820a650\" x=\"500\" y=\"750\" font-size=\"15.5\" fill=\"#DBD8CF\" text-anchor=\"middle\"><tspan data-hk=\"000000010000000000004000010b3820a651\" fill=\"#F4644A\">N + N\u00b7M buffers per frame<\/tspan>\u00a0\u00a0-&gt;\u00a0\u00a0<tspan data-hk=\"000000010000000000004000010b3820a652\" fill=\"#4ADE80\">O(cache)<\/tspan><\/text><!--\/--><\/svg><!--\/--><figcaption>Before: <!--$--><code data-hk=\"000000010000000000004000010b38300\">render(): string[]<\/code><!--\/--> \u2014 N components \u00d7 M transforms, every buffer re-parsed, re-measured, and re-allocated, every frame. After: RichText runs stream through the abstract pipeline in a single pass into the frame diff.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b38400\">The temporaries, the ANSI parsing, the grapheme handling: ENTIRELY GONE from every layer below the<br \/>\nframe renderer, obviously!<\/p>\n<p data-hk=\"000000010000000000004000010b38500\">Why would we pad your component and pass it down when we can just&#8230; stream the padding, and then one<br \/>\nof your lines, and repeat? Why would we make you render a 255 line diff in full color and then<br \/>\n<code data-hk=\"000000010000000000004000010b3850100\">.slice(0, 3)<\/code> just to truncate that into another array of string buffers when we can just&#8230; drop<br \/>\nyour stream after the ellipsis, or break it into lines as a part of the transformation ourselves?<\/p>\n<p data-hk=\"000000010000000000004000010b38600\">The low-level primitive owns measurement and transformation once. Higher layers should never parse<br \/>\nANSI to discover the structure they themselves emitted.<\/p>\n<h3 data-hk=\"000000010000000000004000010b38700\" id=\"a-typed-component-model\">A typed component model<\/h3>\n<p data-hk=\"000000010000000000004000010b38800\">Next, the <code data-hk=\"000000010000000000004000010b3880100\">string[]<\/code> will be replaced by a proper component model. The higher-level consumers will<br \/>\nsimply stack boxes and enjoy their LSP showing them the way:<\/p>\n<figure data-hk=\"000000010000000000004000010b389\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/component-model-lint.png\" width=\"817\" height=\"139\" alt=\"Editor showing omp\u00b2 component markup where nesting a &lt;text&gt; element inside &lt;text&gt; is flagged: elements are not allowed inside &lt;text&gt;\" loading=\"lazy\"\/><figcaption>The markup is typed: nesting an element inside <!--$--><code data-hk=\"000000010000000000004000010b39000\">&lt;text&gt;<\/code><!--\/--> is a lint error at edit time, not a mangled frame at run time.<\/figcaption><\/figure>\n<figure data-hk=\"000000010000000000004000010b391\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/component-markup-render.png\" width=\"845\" height=\"308\" alt=\"omp\u00b2 TUI rendering markup live: a box with a title row, an icon, a horizontal magenta-to-cyan gradient on text, and a rendered LaTeX fraction one half\" loading=\"lazy\"\/><figcaption>Markup in, frame out: <!--$--><code data-hk=\"000000010000000000004000010b39200\">&lt;box&gt;<\/code><!--\/-->, <!--$--><code data-hk=\"000000010000000000004000010b39300\">&lt;row&gt;<\/code><!--\/-->\/<!--$--><code data-hk=\"000000010000000000004000010b39400\">&lt;col&gt;<\/code><!--\/-->, an <!--$--><code data-hk=\"000000010000000000004000010b39500\">&lt;ico:new\/&gt;<\/code><!--\/--> icon, a horizontal <!--$--><code data-hk=\"000000010000000000004000010b39600\">magenta..cyan<\/code><!--\/--> gradient, and a live-rendered \u00bd from <!--$--><code data-hk=\"000000010000000000004000010b39700\">$$ \\frac{1}{2} $$<\/code><!--\/-->.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b39800\">Now, I may not like working with the frontend, but damn do I like a good abstraction. <code data-hk=\"000000010000000000004000010b3980100\">(Element, Props, Children)<\/code> is literally all you need, coupled with a layout engine, to make this wonderful in<br \/>\ncomparison.<\/p>\n<p data-hk=\"000000010000000000004000010b39900\">The DOM chapter promised that a tool element could be rendered by any actor. This is the concrete<br \/>\nshape of that promise:<\/p>\n<p data-hk=\"000000010000000000004000010b40000\">This is what the <code data-hk=\"000000010000000000004000010b4000100\">Read<\/code> component looks like. Not half bad, is it?<\/p>\n<pre data-hk=\"000000010000000000004000010b40100\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b4010100\"><span data-hk=\"000000010000000000004000010b401010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101010100\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b40101010200\" style=\"color:#FFFFFF\">box<\/span><span data-hk=\"000000010000000000004000010b40101010300\" style=\"color:#C9A4FF\"> bc<\/span><span data-hk=\"000000010000000000004000010b40101010400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101010500\" style=\"color:#B99AFF\">muted<\/span><span data-hk=\"000000010000000000004000010b40101010600\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101020100\" style=\"color:#CFD4DC\">\t&lt;<\/span><span data-hk=\"000000010000000000004000010b40101020200\" style=\"color:#FFFFFF\">row<\/span><span data-hk=\"000000010000000000004000010b40101020300\" style=\"color:#C9A4FF\"> kind<\/span><span data-hk=\"000000010000000000004000010b40101020400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101020500\" style=\"color:#B99AFF\">title<\/span><span data-hk=\"000000010000000000004000010b40101020600\" style=\"color:#C9A4FF\"> gap<\/span><span data-hk=\"000000010000000000004000010b40101020700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101020800\" style=\"color:#B99AFF\">1<\/span><span data-hk=\"000000010000000000004000010b40101020900\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101030100\" style=\"color:#CFD4DC\">\t\t&lt;<\/span><span data-hk=\"000000010000000000004000010b40101030200\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b40101030300\" style=\"color:#CFD4DC\">&gt;\u2022&lt;\/<\/span><span data-hk=\"000000010000000000004000010b40101030400\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b40101030500\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101040100\" style=\"color:#CFD4DC\">\t\t&lt;<\/span><span data-hk=\"000000010000000000004000010b40101040200\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b40101040300\" style=\"color:#C9A4FF\"> bold<\/span><span data-hk=\"000000010000000000004000010b40101040400\" style=\"color:#CFD4DC\">&gt;Read&lt;\/<\/span><span data-hk=\"000000010000000000004000010b40101040500\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b40101040600\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101050100\" style=\"color:#CFD4DC\">\t\t&lt;<\/span><span data-hk=\"000000010000000000004000010b40101050200\" style=\"color:#FF54C0\">a<\/span><span data-hk=\"000000010000000000004000010b40101050300\" style=\"color:#C9A4FF\"> href<\/span><span data-hk=\"000000010000000000004000010b40101050400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101050500\" style=\"color:#B99AFF\">{input.path}<\/span><span data-hk=\"000000010000000000004000010b40101050600\" style=\"color:#CFD4DC\">&gt;{input.label}&lt;\/<\/span><span data-hk=\"000000010000000000004000010b40101050700\" style=\"color:#FF54C0\">a<\/span><span data-hk=\"000000010000000000004000010b40101050800\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101060100\" style=\"color:#CFD4DC\">\t\t{#if status=error}&lt;<\/span><span data-hk=\"000000010000000000004000010b40101060200\" style=\"color:#FFFFFF\">badge<\/span><span data-hk=\"000000010000000000004000010b40101060300\" style=\"color:#C9A4FF\"> tone<\/span><span data-hk=\"000000010000000000004000010b40101060400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101060500\" style=\"color:#B99AFF\">error<\/span><span data-hk=\"000000010000000000004000010b40101060600\" style=\"color:#CFD4DC\">&gt;exit {code}&lt;\/<\/span><span data-hk=\"000000010000000000004000010b40101060700\" style=\"color:#FFFFFF\">badge<\/span><span data-hk=\"000000010000000000004000010b40101060800\" style=\"color:#CFD4DC\">&gt;{\/if}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101070100\" style=\"color:#CFD4DC\">\t&lt;\/<\/span><span data-hk=\"000000010000000000004000010b40101070200\" style=\"color:#FFFFFF\">row<\/span><span data-hk=\"000000010000000000004000010b40101070300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101080100\" style=\"color:#CFD4DC\">\t{#if result.head}&lt;<\/span><span data-hk=\"000000010000000000004000010b40101080200\" style=\"color:#FF54C0\">pre<\/span><span data-hk=\"000000010000000000004000010b40101080300\" style=\"color:#C9A4FF\"> lang<\/span><span data-hk=\"000000010000000000004000010b40101080400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101080500\" style=\"color:#B99AFF\">{result.lang}<\/span><span data-hk=\"000000010000000000004000010b40101080600\" style=\"color:#C9A4FF\"> wrap<\/span><span data-hk=\"000000010000000000004000010b40101080700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101080800\" style=\"color:#B99AFF\">word<\/span><span data-hk=\"000000010000000000004000010b40101080900\" style=\"color:#C9A4FF\"> start<\/span><span data-hk=\"000000010000000000004000010b40101080a1000\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b40101080a1100\" style=\"color:#B99AFF\">{result.start}<\/span><span data-hk=\"000000010000000000004000010b40101080a1200\" style=\"color:#CFD4DC\">&gt;{result.head}&lt;\/<\/span><span data-hk=\"000000010000000000004000010b40101080a1300\" style=\"color:#FF54C0\">pre<\/span><span data-hk=\"000000010000000000004000010b40101080a1400\" style=\"color:#CFD4DC\">&gt;{\/if}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b40101090100\" style=\"color:#CFD4DC\">\t{#if @expanded}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a100100\" style=\"color:#CFD4DC\">\t\t{#if result.blob}&lt;<\/span><span data-hk=\"000000010000000000004000010b401010a100200\" style=\"color:#FF54C0\">pre<\/span><span data-hk=\"000000010000000000004000010b401010a100300\" style=\"color:#C9A4FF\"> lang<\/span><span data-hk=\"000000010000000000004000010b401010a100400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b401010a100500\" style=\"color:#B99AFF\">{result.lang}<\/span><span data-hk=\"000000010000000000004000010b401010a100600\" style=\"color:#C9A4FF\"> numbers<\/span><span data-hk=\"000000010000000000004000010b401010a100700\" style=\"color:#C9A4FF\"> start<\/span><span data-hk=\"000000010000000000004000010b401010a100800\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b401010a100900\" style=\"color:#B99AFF\">{result.start}<\/span><span data-hk=\"000000010000000000004000010b401010a100a1000\" style=\"color:#C9A4FF\"> blob<\/span><span data-hk=\"000000010000000000004000010b401010a100a1100\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b401010a100a1200\" style=\"color:#B99AFF\">{result.blob}<\/span><span data-hk=\"000000010000000000004000010b401010a100a1300\" style=\"color:#CFD4DC\">&gt;&lt;\/<\/span><span data-hk=\"000000010000000000004000010b401010a100a1400\" style=\"color:#FF54C0\">pre<\/span><span data-hk=\"000000010000000000004000010b401010a100a1500\" style=\"color:#CFD4DC\">&gt;{\/if}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a110100\" style=\"color:#CFD4DC\">\t{\/if}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a120100\" style=\"color:#CFD4DC\">\t{#each diag as d}&lt;<\/span><span data-hk=\"000000010000000000004000010b401010a120200\" style=\"color:#FFFFFF\">callout<\/span><span data-hk=\"000000010000000000004000010b401010a120300\" style=\"color:#C9A4FF\"> tone<\/span><span data-hk=\"000000010000000000004000010b401010a120400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b401010a120500\" style=\"color:#B99AFF\">{d.severity}<\/span><span data-hk=\"000000010000000000004000010b401010a120600\" style=\"color:#CFD4DC\">&gt;{d.msg}&lt;\/<\/span><span data-hk=\"000000010000000000004000010b401010a120700\" style=\"color:#FFFFFF\">callout<\/span><span data-hk=\"000000010000000000004000010b401010a120800\" style=\"color:#CFD4DC\">&gt;{\/each}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a130100\" style=\"color:#CFD4DC\">\t{#if result.src}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a140100\" style=\"color:#CFD4DC\">\t\t&lt;<\/span><span data-hk=\"000000010000000000004000010b401010a140200\" style=\"color:#FF54C0\">hr<\/span><span data-hk=\"000000010000000000004000010b401010a140300\" style=\"color:#C9A4FF\"> title<\/span><span data-hk=\"000000010000000000004000010b401010a140400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b401010a140500\" style=\"color:#9BE8FF\">\"Output\"<\/span><span data-hk=\"000000010000000000004000010b401010a140600\" style=\"color:#CFD4DC\">\/&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1500\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a150100\" style=\"color:#CFD4DC\">\t\t&lt;<\/span><span data-hk=\"000000010000000000004000010b401010a150200\" style=\"color:#FFFFFF\">row<\/span><span data-hk=\"000000010000000000004000010b401010a150300\" style=\"color:#C9A4FF\"> gap<\/span><span data-hk=\"000000010000000000004000010b401010a150400\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b401010a150500\" style=\"color:#B99AFF\">1<\/span><span data-hk=\"000000010000000000004000010b401010a150600\" style=\"color:#C9A4FF\"> fg<\/span><span data-hk=\"000000010000000000004000010b401010a150700\" style=\"color:#CFD4DC\">=<\/span><span data-hk=\"000000010000000000004000010b401010a150800\" style=\"color:#B99AFF\">muted<\/span><span data-hk=\"000000010000000000004000010b401010a150900\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1600\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a160100\" style=\"color:#CFD4DC\">\t\t\t&lt;<\/span><span data-hk=\"000000010000000000004000010b401010a160200\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b401010a160300\" style=\"color:#CFD4DC\">&gt;\u27e8Resolved path:&lt;\/<\/span><span data-hk=\"000000010000000000004000010b401010a160400\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b401010a160500\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1700\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a170100\" style=\"color:#CFD4DC\">\t\t\t&lt;<\/span><span data-hk=\"000000010000000000004000010b401010a170200\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b401010a170300\" style=\"color:#CFD4DC\">&gt;{result.src}\u27e9&lt;\/<\/span><span data-hk=\"000000010000000000004000010b401010a170400\" style=\"color:#FFFFFF\">text<\/span><span data-hk=\"000000010000000000004000010b401010a170500\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1800\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a180100\" style=\"color:#CFD4DC\">\t\t&lt;\/<\/span><span data-hk=\"000000010000000000004000010b401010a180200\" style=\"color:#FFFFFF\">row<\/span><span data-hk=\"000000010000000000004000010b401010a180300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a1900\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a190100\" style=\"color:#CFD4DC\">\t{\/if}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a2000\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a200100\" style=\"color:#CFD4DC\">\t{@render usage}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b401010a2100\" class=\"line \"><span data-hk=\"000000010000000000004000010b401010a210100\" style=\"color:#CFD4DC\">&lt;\/<\/span><span data-hk=\"000000010000000000004000010b401010a210200\" style=\"color:#FFFFFF\">box<\/span><span data-hk=\"000000010000000000004000010b401010a210300\" style=\"color:#CFD4DC\">&gt;<\/span><\/span><\/code><\/pre>\n<p data-hk=\"000000010000000000004000010b40200\">The tool author describes structure and semantics. The TUI, web client, snapshot test, and remote<br \/>\ninspector decide how that structure is laid out on their own surface.<\/p>\n<h3 data-hk=\"000000010000000000004000010b40300\" id=\"presentation-policy-belongs-to-the-renderer\">Presentation policy belongs to the renderer<\/h3>\n<p data-hk=\"000000010000000000004000010b40400\">The component model buys two useful properties for free:<\/p>\n<ol data-hk=\"000000010000000000004000010b40500\">\n<li data-hk=\"000000010000000000004000010b4050100\"><code data-hk=\"000000010000000000004000010b405010100\">&lt;ico:new\/&gt;<\/code> gives every plugin a convenient icon while respecting the user&#8217;s ASCII, Unicode, or<br \/>\nNerd Font choice. Borders work the same way.<\/li>\n<li data-hk=\"000000010000000000004000010b4050200\">Semantic colors no longer require a theme object threaded through every renderer. Claude can ask<br \/>\nfor <code data-hk=\"000000010000000000004000010b405020100\">info<\/code> instead of choosing a literal color and hoping it fits the user&#8217;s theme.<\/li>\n<\/ol>\n<figure data-hk=\"000000010000000000004000010b406\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/theme-gradient-markup.png\" width=\"867\" height=\"195\" alt=\"omp\u00b2 markup using border=round bc=info and fg=red..blue, rendered as a rounded box in the theme's info color with a gradient glyph\" loading=\"lazy\"\/><figcaption><!--$--><code data-hk=\"000000010000000000004000010b40700\">border=round bc=\"info\"<\/code><!--\/--> resolves to the theme&#8217;s semantic color; <!--$--><code data-hk=\"000000010000000000004000010b40800\">fg=\"red..blue\"<\/code><!--\/--> is a gradient. No theme object threaded anywhere.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b40900\">You also need to own the pace of the text stream. Claude and Codex emit chunks at very different<br \/>\ncadences\u2014one a few words at a time, the other a few characters. Smoothing those differences changes<br \/>\nhow responsive the harness feels: steady motion reads as progress; bursts followed by stalls do not.<br \/>\nHeh.<\/p>\n<p data-hk=\"000000010000000000004000010b41000\">Semantic icons, borders, colors, truncation, and stream pacing now have one owner. Extensions ask for<br \/>\n<code data-hk=\"000000010000000000004000010b4100100\">info<\/code>, <code data-hk=\"000000010000000000004000010b4100200\">error<\/code>, or <code data-hk=\"000000010000000000004000010b4100300\">&lt;ico:new\/&gt;<\/code>; they do not thread a theme object through every function or choose<br \/>\na Nerd Font glyph on behalf of every user.<\/p>\n<h3 data-hk=\"000000010000000000004000010b41100\" id=\"verification-is-part-of-the-interface\">Verification is part of the interface<\/h3>\n<p data-hk=\"000000010000000000004000010b41200\">In the current &#8220;meta&#8221;, the biggest ROI investment that also costs you nothing is asking the agent<br \/>\nto implement a debug protocol for any kind of interactive TUI \/ GUI. If &#8220;how to verify&#8221; is unknown<br \/>\nand unspecified, the agent will side-channel a look-alike, meaning it will create a test file that<br \/>\ndoesn&#8217;t really check anything in most cases.<\/p>\n<p data-hk=\"000000010000000000004000010b41300\">By defining what &#8220;verification&#8221; means and giving it a convenient shape in advance, you drop the<br \/>\nfriction by a considerable amount, which means it becomes an active part of the development loop.<\/p>\n<figure data-hk=\"000000010000000000004000010b414\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/tui-debug-tool.png\" width=\"722\" height=\"523\" alt=\"Two TUI Debug tool calls: one injects eight synthetic key events into a session named chat, the other dumps the headless layout tree with component names, positions, and focusable flags\" loading=\"lazy\"\/><\/figure>\n<p data-hk=\"000000010000000000004000010b41500\">The shape is not really important, and can always be updated: it could be a custom tool, a Python<br \/>\npackage, or an API, but it&#8217;s an absolute must to provide a non-destructive, off-screen,<br \/>\nmulti-instance <em data-hk=\"000000010000000000004000010b4150100\">thing<\/em> that prevents the agent from redefining (and usually downgrading) the<br \/>\ndefinition of success.<\/p>\n<p data-hk=\"000000010000000000004000010b41600\">In other words, the debug protocol becomes the machine-readable definition of what the UI is\u2014not<br \/>\nmerely a test helper.<\/p>\n<h3 data-hk=\"000000010000000000004000010b41700\" id=\"the-transcript-is-a-protocol\">The transcript is a protocol<\/h3>\n<p data-hk=\"000000010000000000004000010b41800\">The actual impossible part of the TUI is having 0 GH issues about how it&#8217;s broken. People are<br \/>\nidealistic creatures about what they don&#8217;t know, and unfortunately many do not know that the perfect<br \/>\nTUI experience they want is impossible (every component fully up to date no matter the location,<br \/>\ndynamically mutated).<\/p>\n<h4 data-hk=\"000000010000000000004000010b41900\" id=\"blocks\">Blocks<\/h4>\n<p data-hk=\"000000010000000000004000010b42000\">We define the canonical transcript as a list of blocks. A block produces rows of text and moves<br \/>\nthrough a lifecycle:<\/p>\n<p data-hk=\"000000010000000000004000010b421\" class=\"math-line\">active \u2192 finalized \u2192 committed<\/p>\n<p data-hk=\"000000010000000000004000010b42200\">While alive, block <em data-hk=\"000000010000000000004000010b4220100\">i<\/em> shows a current snapshot, <em data-hk=\"000000010000000000004000010b4220200\">W<sub data-hk=\"000000010000000000004000010b4220201\">i<\/sub><\/em>, which is an array of rows. Upon<br \/>\nfinalization, it freezes to an immutable snapshot, <em data-hk=\"000000010000000000004000010b4220300\">F<sub data-hk=\"000000010000000000004000010b4220301\">i<\/sub><\/em>.<\/p>\n<p data-hk=\"000000010000000000004000010b42300\">Blocks come in two modes:<\/p>\n<ul data-hk=\"000000010000000000004000010b42400\">\n<li data-hk=\"000000010000000000004000010b4240100\">Mutable: each new snapshot may replace the previous one wholesale (spinners, progress).<br \/>\nSnapshots are speculative and never become history; only <em data-hk=\"000000010000000000004000010b424010100\">F<sub data-hk=\"000000010000000000004000010b424010101\">i<\/sub><\/em> does.<\/li>\n<li data-hk=\"000000010000000000004000010b4240200\">Append-only: snapshots only grow: every snapshot is a prefix of the next, and the last<br \/>\nsnapshot is a prefix of <em data-hk=\"000000010000000000004000010b424020100\">F<sub data-hk=\"000000010000000000004000010b424020101\">i<\/sub><\/em> (streaming text).<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b42500\">The distinction matters when a block outgrows its viewport allocation. A mutable snapshot cannot<br \/>\nenter history early because a later update might replace it; we would have to yank already-scrolled<br \/>\nrows. An append-only block such as assistant thinking only extends a stable prefix, so that prefix<br \/>\ncan begin committing immediately.<\/p>\n<h4 data-hk=\"000000010000000000004000010b42600\" id=\"terminal\">Terminal<\/h4>\n<p data-hk=\"000000010000000000004000010b42700\">A terminal at width <em data-hk=\"000000010000000000004000010b4270100\">W<\/em> and height <em data-hk=\"000000010000000000004000010b4270200\">H<\/em> has two buffers:<\/p>\n<ul data-hk=\"000000010000000000004000010b42800\">\n<li data-hk=\"000000010000000000004000010b4280100\"><em data-hk=\"000000010000000000004000010b428010100\">V<\/em>: the viewport, of <em data-hk=\"000000010000000000004000010b428010200\">H<\/em> visible rows<\/li>\n<li data-hk=\"000000010000000000004000010b4280200\"><em data-hk=\"000000010000000000004000010b428020100\">S<\/em>: native scrollback, unbounded, append-only<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b42900\">Technically, we could clear and write over the scrollback, but this leads to behavior users often<br \/>\ncomplain about; so it is now an invariant.<\/p>\n<p data-hk=\"000000010000000000004000010b43000\">Wrapping, <em data-hk=\"000000010000000000004000010b4300100\">wrap<sub data-hk=\"000000010000000000004000010b4300101\">W<\/sub><\/em>, turns logical rows into physical rows and depends on the current<br \/>\nwidth. There is no addressable area below the viewport. Writing past its bottom scrolls the terminal<br \/>\nand pushes the top rows into <em data-hk=\"000000010000000000004000010b4300200\">S<\/em> irreversibly.<\/p>\n<p data-hk=\"000000010000000000004000010b43100\">The logical history <em data-hk=\"000000010000000000004000010b4310100\">L<\/em> is kept in unwrapped rows, so it is width-independent: committed finals, in<br \/>\nblock order, each exactly once plus however much of the currently streaming block has already been<br \/>\nlet through. With <em data-hk=\"000000010000000000004000010b4310200\">c<\/em> the last committed block and <em data-hk=\"000000010000000000004000010b4310300\">j = c+1<\/em>:<\/p>\n<p data-hk=\"000000010000000000004000010b432\" class=\"math-line\">L = F<sub>1<\/sub> \u00b7 F<sub>2<\/sub> \u22ef F<sub>c<\/sub> \u00b7 W<sub>j<\/sub>[1..e<sub>j<\/sub>]<\/p>\n<p data-hk=\"000000010000000000004000010b43300\">where <em data-hk=\"000000010000000000004000010b4330100\">e<sub data-hk=\"000000010000000000004000010b4330101\">j<\/sub><\/em> counts the rows the streaming head has already emitted into history<br \/>\n(<em data-hk=\"000000010000000000004000010b4330200\">e<sub data-hk=\"000000010000000000004000010b4330201\">j<\/sub> = 0<\/em> unless block <em data-hk=\"000000010000000000004000010b4330300\">j<\/em> is an append-only block mid-stream).<\/p>\n<p data-hk=\"000000010000000000004000010b43400\">Therefore:<\/p>\n<ul data-hk=\"000000010000000000004000010b43500\">\n<li data-hk=\"000000010000000000004000010b4350100\">committed finals occur exactly once, consecutively, in block order;<\/li>\n<li data-hk=\"000000010000000000004000010b4350200\">mutable speculative snapshots never enter <em data-hk=\"000000010000000000004000010b435020100\">L<\/em>;<\/li>\n<li data-hk=\"000000010000000000004000010b4350300\">an append-only head may enter <em data-hk=\"000000010000000000004000010b435030100\">L<\/em> row by row while still streaming;<\/li>\n<li data-hk=\"000000010000000000004000010b4350400\">finalization writes nothing;<\/li>\n<li data-hk=\"000000010000000000004000010b4350500\">commitment appends only the rows of <em data-hk=\"000000010000000000004000010b435050100\">F<sub data-hk=\"000000010000000000004000010b435050101\">j<\/sub><\/em> not yet emitted<\/li>\n<\/ul>\n<h4 data-hk=\"000000010000000000004000010b43600\" id=\"resize\">Resize<\/h4>\n<p data-hk=\"000000010000000000004000010b43700\">Resize changes nothing logical: every <em data-hk=\"000000010000000000004000010b4370100\">W<sub data-hk=\"000000010000000000004000010b4370101\">i<\/sub><\/em>, every <em data-hk=\"000000010000000000004000010b4370200\">F<sub data-hk=\"000000010000000000004000010b4370201\">i<\/sub><\/em>, and <em data-hk=\"000000010000000000004000010b4370300\">c<\/em> survive<br \/>\nunchanged. Only wrapping and viewport allocation are recomputed. Rows already in native scrollback<br \/>\ncannot be rewritten, so resize needs one explicit policy for them:<\/p>\n<ul data-hk=\"000000010000000000004000010b43800\">\n<li data-hk=\"000000010000000000004000010b4380100\">Preserve: keep the emulator-wrapped history as-is.<\/li>\n<li data-hk=\"000000010000000000004000010b4380200\">Append: append a re-rendered history, possibly duplicating physical rows.<\/li>\n<li data-hk=\"000000010000000000004000010b4380300\">Rebuild: start a new physical epoch and replay history into it.<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b43900\">These rules separate three things that are easy to conflate: mutable presentation in the viewport,<br \/>\nwidth-independent logical history, and irreversible native terminal rows. Once they are named,<br \/>\nresize and streaming become policy choices instead of folklore.<\/p>\n<h3 data-hk=\"000000010000000000004000010b44000\" id=\"specify-the-impossible-part\">Specify the impossible part<\/h3>\n<p data-hk=\"000000010000000000004000010b44100\">Now why did I put you through all this &#8220;math&#8221;? Because this is a very complicated algorithm to<br \/>\nverify the sanity of; in the previous iteration, we had to write a fuzzer to get to a stable point,<br \/>\nand this time I&#8217;d like to avoid that.<\/p>\n<p data-hk=\"000000010000000000004000010b44200\">Instead, we modeled the behavior in <a data-hk=\"000000010000000000004000010b4420100\" href=\"https:\/\/lamport.azurewebsites.net\/tla\/tla.html\">TLA+<\/a> as described, and asked for iterative changes to how the<br \/>\ncommit and finalization of these blocks are handled until the clearly specified invariants were all<br \/>\nmet.<\/p>\n<p data-hk=\"000000010000000000004000010b44300\">Now, if we do want to make a change, say, yolo commit partials, or not allow block truncation, we<br \/>\nhave a reference to update and an extremely easy way to know whether or not it will work, with a<br \/>\ncounterexample presented on failure.<\/p>\n<p data-hk=\"000000010000000000004000010b44400\">The paper and the full <code data-hk=\"000000010000000000004000010b4440100\">ElasticSlots.tla<\/code> source live in <a data-hk=\"000000010000000000004000010b4440200\" href=\"#appendix-b-elastic-speculative-slots\">Appendix B<\/a>.<\/p>\n<h3 data-hk=\"000000010000000000004000010b44500\" id=\"what-this-unlocks\">What this unlocks<\/h3>\n<p data-hk=\"000000010000000000004000010b44600\">Obligatory flex, and we can move on! <em data-hk=\"000000010000000000004000010b4460100\">Now if someone complains about how TUI is broken, I can give<br \/>\nthem a formal proof of why it cannot be fixed, great.<\/em><\/p>\n<figure data-hk=\"000000010000000000004000010b447\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/tui-flex.png\" width=\"923\" height=\"482\" alt=\"The omp\u00b2 TUI: a command palette overlay above a list of live worker shards, a session rail with diff stats, a status bar, and an inline image thumbnail\" loading=\"lazy\"\/><figcaption>The omp\u00b2 TUI mid-task: command palette over live parallel shards, session rail with per-file diff stats, and an inline image thumbnail \u2014 every element a component on the same streaming pipeline.<\/figcaption><\/figure>\n<p data-hk=\"000000010000000000004000010b44800\">The TUI, web client, and remote inspector can differ in layout without differing in truth. Tool<br \/>\nauthors describe semantic state; the component system owns presentation; the transcript protocol<br \/>\nowns exactly-once history.<\/p>\n<p data-hk=\"000000010000000000004000010b44900\">That is the same design move repeated again: push the hard invariant down into the layer that can<br \/>\nenforce it. The implementation stack should reinforce those invariants rather than invite every<br \/>\ncontributor\u2014and every coding agent\u2014to invent a local style.<\/p>\n<h2 data-hk=\"000000010000000000004000010b45000\" id=\"the-stack\">The stack<\/h2>\n<aside data-hk=\"000000010000000000004000010b4510\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>Choose languages whose constraints steer agents toward the codebase you want to maintain.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b45110\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b45200\">The previous chapters are architecture. Language choice decides how much friction the codebase puts<br \/>\nbetween that architecture and the next \u201chelpful\u201d local exception. This matters more when a large<br \/>\nshare of the implementation is produced by agents trained on the defaults and pathologies of each<br \/>\necosystem.<\/p>\n<h3 data-hk=\"000000010000000000004000010b45300\" id=\"language-choice-is-architecture\">Language choice is architecture<\/h3>\n<p data-hk=\"000000010000000000004000010b45400\"><strong data-hk=\"000000010000000000004000010b4540100\">TypeScript is an awful choice at the moment unless you have no choice but to interact with<br \/>\nfrontend code.<\/strong><\/p>\n<p data-hk=\"000000010000000000004000010b45500\">One of the most impactful decisions you can make when starting a project right now is: picking the<br \/>\nright tool. Now if I saw an article starting like this 3 years back, I&#8217;d have started ranting,<br \/>\nbut&#8230; If you don&#8217;t believe me, try giving Claude the exact same prompt describing a widget you want<br \/>\nto build.<\/p>\n<p data-hk=\"000000010000000000004000010b45600\">Now swap macOS (Swift) -&gt; Linux (Qt\/JS). The former will get you a glassmorphic widget that looks<br \/>\nlike it belongs with the OS, the latter will get you a rectangle with overlapping UI elements and<br \/>\nquestionable UX choices, making you feel like you just finished reading up on the XML schema<br \/>\nrequired to define a UI and this is your first time compiling it.<\/p>\n<p data-hk=\"000000010000000000004000010b45700\">Now sure, the way you prompted plays a role here, and you could indeed have gone into more detail,<br \/>\nbut after a while you will notice that no matter what you do, one will outperform the other almost<br \/>\neffortlessly. One thing macOS historically did well is forcing developers into one consistent design<br \/>\nstyle, and it goes just the same with LLMs.<\/p>\n<p data-hk=\"000000010000000000004000010b45800\">The point is not that Swift contains taste and JavaScript does not. It is that defaults, standard<br \/>\nlibraries, canonical project shapes, compiler feedback, and ecosystem conventions act as a prior<br \/>\nfor generated code. A language that permits twenty equally normal local styles asks the model to<br \/>\nmake twenty decisions before it reaches the product problem.<\/p>\n<h3 data-hk=\"000000010000000000004000010b45900\" id=\"typescript-becomes-your-language\">TypeScript becomes your language<\/h3>\n<p data-hk=\"000000010000000000004000010b46000\">The one thing I loved about TypeScript, unfortunately, was that it always ended up becoming<br \/>\n<em data-hk=\"000000010000000000004000010b4600100\">your<\/em> language:<\/p>\n<ul data-hk=\"000000010000000000004000010b46100\">\n<li data-hk=\"000000010000000000004000010b4610100\">to <code data-hk=\"000000010000000000004000010b461010100\">camelCase<\/code> or <code data-hk=\"000000010000000000004000010b461010200\">snake_case<\/code>? or perhaps just name your lib <code data-hk=\"000000010000000000004000010b461010300\">$<\/code><\/li>\n<li data-hk=\"000000010000000000004000010b4610200\">to write generics that span 200 lines, or to not even have a single one?<\/li>\n<li data-hk=\"000000010000000000004000010b4610300\">to use <code data-hk=\"000000010000000000004000010b461030100\">Buffer<\/code> or <code data-hk=\"000000010000000000004000010b461030200\">Uint8Array<\/code>?<\/li>\n<li data-hk=\"000000010000000000004000010b4610400\">to use Zod or Typebox?<\/li>\n<li data-hk=\"000000010000000000004000010b4610500\">to use <code data-hk=\"000000010000000000004000010b461050100\">Array&lt;T&gt;<\/code> or <code data-hk=\"000000010000000000004000010b461050200\">T[]<\/code>?<\/li>\n<li data-hk=\"000000010000000000004000010b4610600\">to use ESM or CJS? (wb the extension? <code data-hk=\"000000010000000000004000010b461060100\">.ejs, .cjs, .mjs, .js?<\/code>)<\/li>\n<li data-hk=\"000000010000000000004000010b4610700\">to use TypeScript or JSDoc?<\/li>\n<li data-hk=\"000000010000000000004000010b4610800\">to use Class, or to stay with objects (or hell, new function())?<\/li>\n<li data-hk=\"000000010000000000004000010b4610900\">to export as default or not?<\/li>\n<li data-hk=\"000000010000000000004000010b4610a1000\">to use star re-exports, or name each?<\/li>\n<li data-hk=\"000000010000000000004000010b4610a1100\">to use <code data-hk=\"000000010000000000004000010b4610a110100\">private foo<\/code> or <code data-hk=\"000000010000000000004000010b4610a110200\">#foo<\/code>?<\/li>\n<li data-hk=\"000000010000000000004000010b4610a1200\">to use <code data-hk=\"000000010000000000004000010b4610a120100\">module\/index.ts<\/code> or <code data-hk=\"000000010000000000004000010b4610a120200\">module.ts<\/code>?<\/li>\n<li data-hk=\"000000010000000000004000010b4610a1300\">to use <code data-hk=\"000000010000000000004000010b4610a130100\">const x = () =&gt; ..<\/code> or <code data-hk=\"000000010000000000004000010b4610a130200\">function x() {<\/code>?<\/li>\n<li data-hk=\"000000010000000000004000010b4610a1400\">to use <code data-hk=\"000000010000000000004000010b4610a140100\">function x(args)<\/code> or <code data-hk=\"000000010000000000004000010b4610a140200\">function x(...args)<\/code>?<\/li>\n<li data-hk=\"000000010000000000004000010b4610a1500\">if latter, to use <code data-hk=\"000000010000000000004000010b4610a150100\">...args: any[]<\/code> or <code data-hk=\"000000010000000000004000010b4610a150200\">...args: unknown[]<\/code>?<\/li>\n<li data-hk=\"000000010000000000004000010b4610a1600\">to use <code data-hk=\"000000010000000000004000010b4610a160100\">const X = 1<\/code>, <code data-hk=\"000000010000000000004000010b4610a160200\">enum E { X = 1 }<\/code>, or <code data-hk=\"000000010000000000004000010b4610a160300\">const enum E { X = 1 }<\/code>?<\/li>\n<\/ul>\n<p data-hk=\"000000010000000000004000010b46200\">Now see, having spent 10 years of my life with the biggest write-only language aka C++, I do find<br \/>\njoy in this. However, when forced to choose between Zod and Typebox, your junior friend will just<br \/>\nroll what we call an <code data-hk=\"000000010000000000004000010b4620100\">isRecord<\/code>. Why use generics when you can just union the types? Why make sure<br \/>\nevery branch works for both of the types mentally, when you can specialize with a little typeof? Why<br \/>\nuse classes, it&#8217;s just objects and prototypes, no?<\/p>\n<p data-hk=\"000000010000000000004000010b46300\">It could be the sheer amount of bad JS code out there, or it could be the fact that they probably<br \/>\nswallowed a pile of minified code along the way, but I am tired of it. Considering the same junior<br \/>\ncan find Linux 0-days, if I were you, I&#8217;d stop hoping for <em data-hk=\"000000010000000000004000010b4630100\">the right model<\/em> or <em data-hk=\"000000010000000000004000010b4630200\">the right<br \/>\ncode-quality tool<\/em> and stop jumping through hoops.<\/p>\n<p data-hk=\"000000010000000000004000010b46400\">Perhaps EffectJS will change that, IMO Go will be the winner here at the end of the day (esp. when GC proposal for WASM finalizes) for<br \/>\nsimilar reasons to why Swift wins at design (especially with compilation speed and the ease of<br \/>\ncross-compilation), although some cases demand a lower-level systems language, so we chose Rust here.<\/p>\n<p data-hk=\"000000010000000000004000010b46500\">They still have to be steered quite frequently, taking the shortest path to the goal; allocating copies over dealing with intricate borrows,<br \/>\npassing errors as strings instead of using <code data-hk=\"000000010000000000004000010b4650100\">thiserror<\/code>, but they have most of what&#8217;s necessary for them to work in the <code data-hk=\"000000010000000000004000010b4650200\">std<\/code> coupled with<br \/>\nthe <code data-hk=\"000000010000000000004000010b4650300\">serde<\/code> ecosystem, and the compiler provides a decent amount of safety, so that was that.<\/p>\n<h3 data-hk=\"000000010000000000004000010b46600\" id=\"python-for-extensions\">Python for extensions<\/h3>\n<p data-hk=\"000000010000000000004000010b46700\">The next decision was whether to invite TS back for extensibility. We said no, mainly because:<\/p>\n<ol data-hk=\"000000010000000000004000010b46800\">\n<li data-hk=\"000000010000000000004000010b4680100\">Agents output decent Py =&gt; Decent extensions, by extension<\/li>\n<li data-hk=\"000000010000000000004000010b4680200\">A spec-compliant JS <em data-hk=\"000000010000000000004000010b468020100\">runtime<\/em> is basically impossible in a small footprint (thank you, Locale) &amp;<br \/>\nwithout the ecosystem, we might as well run Lua<\/li>\n<li data-hk=\"000000010000000000004000010b4680300\">Extensions don&#8217;t even make up 1% of the run time, so we don&#8217;t really need JIT<\/li>\n<li data-hk=\"000000010000000000004000010b4680400\">With a full Py runtime embedded we can also guarantee the <code data-hk=\"000000010000000000004000010b468040100\">eval<\/code> tool works out of the box,<br \/>\ninstead of asking the user to install py3 and never being able to rely on it in the<br \/>\nflows we ship.<\/li>\n<li data-hk=\"000000010000000000004000010b4680500\">Python code can inspect its own AST out of the box. This is what makes the runtime chapter&#8217;s <code data-hk=\"000000010000000000004000010b468050100\">@remote<\/code> design possible.<\/li>\n<\/ol>\n<p data-hk=\"000000010000000000004000010b46900\">The runtime chapter introduced the <code data-hk=\"000000010000000000004000010b4690100\">@remote<\/code> boundary. Python&#8217;s introspection and attribute model are<br \/>\nwhat make that boundary ergonomic: the SDK can inspect a function, package the relevant source, and<br \/>\nexecute it in the sandbox runtime without asking every extension author to hand-write an RPC.<\/p>\n<p data-hk=\"000000010000000000004000010b47000\">Bringing the runtime also makes <code data-hk=\"000000010000000000004000010b4700100\">Eval<\/code> a dependable builtin rather than a feature that works only<br \/>\nwhen the user happened to install a compatible Python.<\/p>\n<h2 data-hk=\"000000010000000000004000010b47100\" id=\"closing-notes\">Closing notes<\/h2>\n<aside data-hk=\"000000010000000000004000010b4720\" class=\"lesson\"><span class=\"lesson-kicker\" aria-hidden=\"true\"\/><\/p>\n<p>An agent harness is systems software\u2014not a while loop around a fetch.<\/p>\n<p><!--$--><canvas data-hk=\"000000010000000000004000010b47210\" class=\"st-dither-area st-dither-area--field st-dither-area--field \" aria-hidden=\"true\"\/><!--\/--><\/aside>\n<p data-hk=\"000000010000000000004000010b47300\">\u201cBut why?\u201d was the opening question. The direct answer is that every chapter above is a category of<br \/>\nsoftware with decades of prior art: replication, sandboxing, configuration, scheduling, protocol<br \/>\ncompatibility, real-time rendering, and language\/runtime design.<\/p>\n<p data-hk=\"000000010000000000004000010b47400\">omp\u00b2 is still being built against this document in states ranging from shipped to still being thought<br \/>\nthrough; but we sincerely thank each and every one of you for giving it a try and sharing with us<br \/>\nall kinds of awesome ways you tried to use omp, from making it operate a software factory,<br \/>\nto asking it to build itself a camera app on the very same phone.<\/p>\n<figure data-hk=\"000000010000000000004000010b475\"\/>\n<p data-hk=\"000000010000000000004000010b47700\">You have shaped omp and we expect nothing less interesting from the future!<\/p>\n<hr data-hk=\"000000010000000000004000010b47800\"\/>\n<h2 data-hk=\"000000010000000000004000010b47900\" id=\"appendix-a-state-failures-in-the-official-examples\">Appendix A: state failures in the official examples<\/h2>\n<p data-hk=\"000000010000000000004000010b48000\">The state chapter summarizes these failures by category. This appendix keeps the original evidence:<br \/>\nsource links, minimal code excerpts, and reproduction videos.<\/p>\n<p data-hk=\"000000010000000000004000010b48100\">The claim was not theoretical. We looked at 78 official extension examples: 60 were stateless;<br \/>\namong the 17 with state, only two were correct.<\/p>\n<h4 data-hk=\"000000010000000000004000010b48200\" id=\"1-the-checkpoint-is-cleared-before-fork-can-use-it-git-checkpointts\">1. The checkpoint is cleared before <code data-hk=\"000000010000000000004000010b4820100\">\/fork<\/code> can use it: <code data-hk=\"000000010000000000004000010b4820200\">git-checkpoint.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b48300\"><a data-hk=\"000000010000000000004000010b4830100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/git-checkpoint.ts#L11-L51\">source<\/a>:<br \/>\nmissing durable checkpoint ownership; <code data-hk=\"000000010000000000004000010b4830200\">\/fork<\/code> is invoked while idle, after <code data-hk=\"000000010000000000004000010b4830300\">agent_settled<\/code> has<br \/>\nalready emptied the only map of stash refs.<\/p>\n<pre data-hk=\"000000010000000000004000010b48400\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b4840100\"><span data-hk=\"000000010000000000004000010b484010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b48401010100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b48401010200\" style=\"color:#C9A4FF\"> checkpoints<\/span><span data-hk=\"000000010000000000004000010b48401010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b48401010400\" style=\"color:#FF54C0\">new<\/span><span data-hk=\"000000010000000000004000010b48401010500\" style=\"color:#44CFFF\"> Map<\/span><span data-hk=\"000000010000000000004000010b48401010600\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b48401010700\" style=\"color:#C9A4FF\">string<\/span><span data-hk=\"000000010000000000004000010b48401010800\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b48401010900\" style=\"color:#C9A4FF\">string<\/span><span data-hk=\"000000010000000000004000010b48401010a1000\" style=\"color:#CFD4DC\">&gt;();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b484010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b48401020100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ \u2026<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b484010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b48401030100\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b48401030200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b48401030300\" style=\"color:#44CFFF\">on<\/span><span data-hk=\"000000010000000000004000010b48401030400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b48401030500\" style=\"color:#B99AFF\">\"agent_settled\"<\/span><span data-hk=\"000000010000000000004000010b48401030600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b48401030700\" style=\"color:#FF54C0\">async<\/span><span data-hk=\"000000010000000000004000010b48401030800\" style=\"color:#CFD4DC\"> () <\/span><span data-hk=\"000000010000000000004000010b48401030900\" style=\"color:#FF54C0\">=&gt;<\/span><span data-hk=\"000000010000000000004000010b48401030a1000\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b484010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b48401040100\" style=\"color:#9BE8FF\">  checkpoints<\/span><span data-hk=\"000000010000000000004000010b48401040200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b48401040300\" style=\"color:#44CFFF\">clear<\/span><span data-hk=\"000000010000000000004000010b48401040400\" style=\"color:#CFD4DC\">();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b484010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b48401050100\" style=\"color:#CFD4DC\">});<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b485\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/git-checkpoint.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b48600\" id=\"2-tree-navigation-does-not-restore-state-plan-modeindexts\">2. Tree navigation does not restore state: <code data-hk=\"000000010000000000004000010b4860100\">plan-mode\/index.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b48700\"><a data-hk=\"000000010000000000004000010b4870100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/plan-mode\/index.ts#L340-L352\">source<\/a>:<br \/>\nmissing <code data-hk=\"000000010000000000004000010b4870200\">session_tree<\/code> and <code data-hk=\"000000010000000000004000010b4870300\">getBranch()<\/code>; rewinding leaves plan mode and its tool restrictions<br \/>\nactive, while resume can resurrect a dead branch&#8217;s snapshot.<\/p>\n<pre data-hk=\"000000010000000000004000010b48800\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b4880100\"><span data-hk=\"000000010000000000004000010b488010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b48801010100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b48801010200\" style=\"color:#C9A4FF\"> entries<\/span><span data-hk=\"000000010000000000004000010b48801010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b48801010400\" style=\"color:#9BE8FF\">ctx<\/span><span data-hk=\"000000010000000000004000010b48801010500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b48801010600\" style=\"color:#9BE8FF\">sessionManager<\/span><span data-hk=\"000000010000000000004000010b48801010700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b48801010800\" style=\"color:#44CFFF\">getEntries<\/span><span data-hk=\"000000010000000000004000010b48801010900\" style=\"color:#CFD4DC\">();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b488010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b48801020100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b48801020200\" style=\"color:#C9A4FF\"> planModeEntry<\/span><span data-hk=\"000000010000000000004000010b48801020300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b48801020400\" style=\"color:#9BE8FF\">entries<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b488010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b48801030100\" style=\"color:#CFD4DC\">  .<\/span><span data-hk=\"000000010000000000004000010b48801030200\" style=\"color:#44CFFF\">filter<\/span><span data-hk=\"000000010000000000004000010b48801030300\" style=\"color:#CFD4DC\">((<\/span><span data-hk=\"000000010000000000004000010b48801030400\" style=\"color:#9BE8FF;fontStyle:italic\">e<\/span><span data-hk=\"000000010000000000004000010b48801030500\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b48801030600\" style=\"color:#FF54C0\">=&gt;<\/span><span data-hk=\"000000010000000000004000010b48801030700\" style=\"color:#9BE8FF\"> e<\/span><span data-hk=\"000000010000000000004000010b48801030800\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b48801030900\" style=\"color:#9BE8FF\">type<\/span><span data-hk=\"000000010000000000004000010b48801030a1000\" style=\"color:#CFD4DC\"> === <\/span><span data-hk=\"000000010000000000004000010b48801030a1100\" style=\"color:#B99AFF\">\"custom\"<\/span><span data-hk=\"000000010000000000004000010b48801030a1200\" style=\"color:#CFD4DC\"> &amp;&amp; <\/span><span data-hk=\"000000010000000000004000010b48801030a1300\" style=\"color:#9BE8FF\">e<\/span><span data-hk=\"000000010000000000004000010b48801030a1400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b48801030a1500\" style=\"color:#9BE8FF\">customType<\/span><span data-hk=\"000000010000000000004000010b48801030a1600\" style=\"color:#CFD4DC\"> === <\/span><span data-hk=\"000000010000000000004000010b48801030a1700\" style=\"color:#B99AFF\">\"plan-mode\"<\/span><span data-hk=\"000000010000000000004000010b48801030a1800\" style=\"color:#CFD4DC\">)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b488010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b48801040100\" style=\"color:#CFD4DC\">  .<\/span><span data-hk=\"000000010000000000004000010b48801040200\" style=\"color:#44CFFF\">pop<\/span><span data-hk=\"000000010000000000004000010b48801040300\" style=\"color:#CFD4DC\">();<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b489\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/plan-mode.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b49000\" id=\"3-the-counter-cannot-count-history-status-linets\">3. The counter cannot count history: <code data-hk=\"000000010000000000004000010b4900100\">status-line.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b49100\"><a data-hk=\"000000010000000000004000010b4910100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/status-line.ts#L10-L23\">source<\/a>:<br \/>\nmissing branch derivation; rewind from turn 3 to turn 1 and the next turn says 4, while resume<br \/>\nstarts again at zero.<\/p>\n<pre data-hk=\"000000010000000000004000010b49200\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b4920100\"><span data-hk=\"000000010000000000004000010b492010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b49201010100\" style=\"color:#FF54C0\">let<\/span><span data-hk=\"000000010000000000004000010b49201010200\" style=\"color:#9BE8FF\"> turnCount<\/span><span data-hk=\"000000010000000000004000010b49201010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b49201010400\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b49201010500\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b492010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b49201020100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ \u2026<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b492010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b49201030100\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b49201030200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b49201030300\" style=\"color:#44CFFF\">on<\/span><span data-hk=\"000000010000000000004000010b49201030400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b49201030500\" style=\"color:#B99AFF\">\"turn_start\"<\/span><span data-hk=\"000000010000000000004000010b49201030600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b49201030700\" style=\"color:#FF54C0\">async<\/span><span data-hk=\"000000010000000000004000010b49201030800\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b49201030900\" style=\"color:#9BE8FF;fontStyle:italic\">_event<\/span><span data-hk=\"000000010000000000004000010b49201030a1000\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b49201030a1100\" style=\"color:#9BE8FF;fontStyle:italic\">ctx<\/span><span data-hk=\"000000010000000000004000010b49201030a1200\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b49201030a1300\" style=\"color:#FF54C0\">=&gt;<\/span><span data-hk=\"000000010000000000004000010b49201030a1400\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b492010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b49201040100\" style=\"color:#9BE8FF\">  turnCount<\/span><span data-hk=\"000000010000000000004000010b49201040200\" style=\"color:#CFD4DC\">++;<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b493\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/status-line.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b49400\" id=\"4-a-dynamically-added-tool-survives-rewind-then-disappears-after-resume-dynamic-toolsts\">4. A dynamically added tool survives rewind, then disappears after resume: <code data-hk=\"000000010000000000004000010b4940100\">dynamic-tools.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b49500\"><a data-hk=\"000000010000000000004000010b4950100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/dynamic-tools.ts#L25-L33\">source<\/a>:<br \/>\n<code data-hk=\"000000010000000000004000010b4950200\">\/add-echo-tool echo_branch<\/code> writes only to the live extension registry; <code data-hk=\"000000010000000000004000010b4950300\">\/tree<\/code> does not restart<br \/>\nthat registry, so rewind keeps the tool, but <code data-hk=\"000000010000000000004000010b4950400\">--continue<\/code> starts a new registry and the tool<br \/>\ndisappears.<\/p>\n<pre data-hk=\"000000010000000000004000010b49600\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b4960100\"><span data-hk=\"000000010000000000004000010b496010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b49601010100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b49601010200\" style=\"color:#C9A4FF\"> registeredToolNames<\/span><span data-hk=\"000000010000000000004000010b49601010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b49601010400\" style=\"color:#FF54C0\">new<\/span><span data-hk=\"000000010000000000004000010b49601010500\" style=\"color:#44CFFF\"> Set<\/span><span data-hk=\"000000010000000000004000010b49601010600\" style=\"color:#CFD4DC\">&lt;<\/span><span data-hk=\"000000010000000000004000010b49601010700\" style=\"color:#C9A4FF\">string<\/span><span data-hk=\"000000010000000000004000010b49601010800\" style=\"color:#CFD4DC\">&gt;();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b496010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b49601020100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ \u2026<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b496010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b49601030100\" style=\"color:#9BE8FF\">registeredToolNames<\/span><span data-hk=\"000000010000000000004000010b49601030200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b49601030300\" style=\"color:#44CFFF\">add<\/span><span data-hk=\"000000010000000000004000010b49601030400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b49601030500\" style=\"color:#9BE8FF\">name<\/span><span data-hk=\"000000010000000000004000010b49601030600\" style=\"color:#CFD4DC\">);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b496010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b49601040100\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b49601040200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b49601040300\" style=\"color:#44CFFF\">registerTool<\/span><span data-hk=\"000000010000000000004000010b49601040400\" style=\"color:#CFD4DC\">({<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b497\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/dynamic-tools.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b49800\" id=\"5-a-save-returns-from-an-abandoned-branch-snakets\">5. A save returns from an abandoned branch: <code data-hk=\"000000010000000000004000010b4980100\">snake.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b49900\"><a data-hk=\"000000010000000000004000010b4990100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/snake.ts#L320-L328\">source<\/a>:<br \/>\nrestore scans the whole session file; save on branch A, rewind before it, open <code data-hk=\"000000010000000000004000010b4990200\">\/snake<\/code>, and the<br \/>\ndead save returns.<\/p>\n<pre data-hk=\"000000010000000000004000010b50000\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b5000100\"><span data-hk=\"000000010000000000004000010b500010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b50001010100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b50001010200\" style=\"color:#C9A4FF\"> entries<\/span><span data-hk=\"000000010000000000004000010b50001010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50001010400\" style=\"color:#9BE8FF\">ctx<\/span><span data-hk=\"000000010000000000004000010b50001010500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50001010600\" style=\"color:#9BE8FF\">sessionManager<\/span><span data-hk=\"000000010000000000004000010b50001010700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50001010800\" style=\"color:#44CFFF\">getEntries<\/span><span data-hk=\"000000010000000000004000010b50001010900\" style=\"color:#CFD4DC\">();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b500010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b50001020100\" style=\"color:#FF54C0\">for<\/span><span data-hk=\"000000010000000000004000010b50001020200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b50001020300\" style=\"color:#FF54C0\">let<\/span><span data-hk=\"000000010000000000004000010b50001020400\" style=\"color:#9BE8FF\"> i<\/span><span data-hk=\"000000010000000000004000010b50001020500\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50001020600\" style=\"color:#9BE8FF\">entries<\/span><span data-hk=\"000000010000000000004000010b50001020700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50001020800\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b50001020900\" style=\"color:#CFD4DC\"> - <\/span><span data-hk=\"000000010000000000004000010b50001020a1000\" style=\"color:#B99AFF\">1<\/span><span data-hk=\"000000010000000000004000010b50001020a1100\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b50001020a1200\" style=\"color:#9BE8FF\">i<\/span><span data-hk=\"000000010000000000004000010b50001020a1300\" style=\"color:#CFD4DC\"> &gt;= <\/span><span data-hk=\"000000010000000000004000010b50001020a1400\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b50001020a1500\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b50001020a1600\" style=\"color:#9BE8FF\">i<\/span><span data-hk=\"000000010000000000004000010b50001020a1700\" style=\"color:#CFD4DC\">--) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b500010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b50001030100\" style=\"color:#FF54C0\">  const<\/span><span data-hk=\"000000010000000000004000010b50001030200\" style=\"color:#C9A4FF\"> entry<\/span><span data-hk=\"000000010000000000004000010b50001030300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50001030400\" style=\"color:#9BE8FF\">entries<\/span><span data-hk=\"000000010000000000004000010b50001030500\" style=\"color:#CFD4DC\">[<\/span><span data-hk=\"000000010000000000004000010b50001030600\" style=\"color:#9BE8FF\">i<\/span><span data-hk=\"000000010000000000004000010b50001030700\" style=\"color:#CFD4DC\">];<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b500010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b50001040100\" style=\"color:#FF54C0\">  if<\/span><span data-hk=\"000000010000000000004000010b50001040200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b50001040300\" style=\"color:#9BE8FF\">entry<\/span><span data-hk=\"000000010000000000004000010b50001040400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50001040500\" style=\"color:#9BE8FF\">type<\/span><span data-hk=\"000000010000000000004000010b50001040600\" style=\"color:#CFD4DC\"> === <\/span><span data-hk=\"000000010000000000004000010b50001040700\" style=\"color:#B99AFF\">\"custom\"<\/span><span data-hk=\"000000010000000000004000010b50001040800\" style=\"color:#CFD4DC\"> &amp;&amp; <\/span><span data-hk=\"000000010000000000004000010b50001040900\" style=\"color:#9BE8FF\">entry<\/span><span data-hk=\"000000010000000000004000010b50001040a1000\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50001040a1100\" style=\"color:#9BE8FF\">customType<\/span><span data-hk=\"000000010000000000004000010b50001040a1200\" style=\"color:#CFD4DC\"> === <\/span><span data-hk=\"000000010000000000004000010b50001040a1300\" style=\"color:#C9A4FF\">SNAKE_SAVE_TYPE<\/span><span data-hk=\"000000010000000000004000010b50001040a1400\" style=\"color:#CFD4DC\">) {<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b501\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/snake.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b50200\" id=\"6-last-message-means-last-in-the-file-bookmarkts\">6. &#8220;Last message&#8221; means last in the file: <code data-hk=\"000000010000000000004000010b5020100\">bookmark.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b50300\"><a data-hk=\"000000010000000000004000010b5030100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/bookmark.ts#L19-L25\">source<\/a>:<br \/>\nmissing <code data-hk=\"000000010000000000004000010b5030200\">getBranch()<\/code>; after rewind, <code data-hk=\"000000010000000000004000010b5030300\">\/bookmark<\/code> can label an assistant message on an abandoned<br \/>\nbranch the user cannot see.<\/p>\n<pre data-hk=\"000000010000000000004000010b50400\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b5040100\"><span data-hk=\"000000010000000000004000010b504010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b50401010100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b50401010200\" style=\"color:#C9A4FF\"> entries<\/span><span data-hk=\"000000010000000000004000010b50401010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50401010400\" style=\"color:#9BE8FF\">ctx<\/span><span data-hk=\"000000010000000000004000010b50401010500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50401010600\" style=\"color:#9BE8FF\">sessionManager<\/span><span data-hk=\"000000010000000000004000010b50401010700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50401010800\" style=\"color:#44CFFF\">getEntries<\/span><span data-hk=\"000000010000000000004000010b50401010900\" style=\"color:#CFD4DC\">();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b504010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b50401020100\" style=\"color:#FF54C0\">for<\/span><span data-hk=\"000000010000000000004000010b50401020200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b50401020300\" style=\"color:#FF54C0\">let<\/span><span data-hk=\"000000010000000000004000010b50401020400\" style=\"color:#9BE8FF\"> i<\/span><span data-hk=\"000000010000000000004000010b50401020500\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50401020600\" style=\"color:#9BE8FF\">entries<\/span><span data-hk=\"000000010000000000004000010b50401020700\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50401020800\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b50401020900\" style=\"color:#CFD4DC\"> - <\/span><span data-hk=\"000000010000000000004000010b50401020a1000\" style=\"color:#B99AFF\">1<\/span><span data-hk=\"000000010000000000004000010b50401020a1100\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b50401020a1200\" style=\"color:#9BE8FF\">i<\/span><span data-hk=\"000000010000000000004000010b50401020a1300\" style=\"color:#CFD4DC\"> &gt;= <\/span><span data-hk=\"000000010000000000004000010b50401020a1400\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b50401020a1500\" style=\"color:#CFD4DC\">; <\/span><span data-hk=\"000000010000000000004000010b50401020a1600\" style=\"color:#9BE8FF\">i<\/span><span data-hk=\"000000010000000000004000010b50401020a1700\" style=\"color:#CFD4DC\">--) {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b504010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b50401030100\" style=\"color:#FF54C0\">  const<\/span><span data-hk=\"000000010000000000004000010b50401030200\" style=\"color:#C9A4FF\"> entry<\/span><span data-hk=\"000000010000000000004000010b50401030300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50401030400\" style=\"color:#9BE8FF\">entries<\/span><span data-hk=\"000000010000000000004000010b50401030500\" style=\"color:#CFD4DC\">[<\/span><span data-hk=\"000000010000000000004000010b50401030600\" style=\"color:#9BE8FF\">i<\/span><span data-hk=\"000000010000000000004000010b50401030700\" style=\"color:#CFD4DC\">];<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b504010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b50401040100\" style=\"color:#FF54C0\">  if<\/span><span data-hk=\"000000010000000000004000010b50401040200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b50401040300\" style=\"color:#9BE8FF\">entry<\/span><span data-hk=\"000000010000000000004000010b50401040400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50401040500\" style=\"color:#9BE8FF\">type<\/span><span data-hk=\"000000010000000000004000010b50401040600\" style=\"color:#CFD4DC\"> === <\/span><span data-hk=\"000000010000000000004000010b50401040700\" style=\"color:#B99AFF\">\"message\"<\/span><span data-hk=\"000000010000000000004000010b50401040800\" style=\"color:#CFD4DC\"> &amp;&amp; <\/span><span data-hk=\"000000010000000000004000010b50401040900\" style=\"color:#9BE8FF\">entry<\/span><span data-hk=\"000000010000000000004000010b50401040a1000\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50401040a1100\" style=\"color:#9BE8FF\">message<\/span><span data-hk=\"000000010000000000004000010b50401040a1200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50401040a1300\" style=\"color:#9BE8FF\">role<\/span><span data-hk=\"000000010000000000004000010b50401040a1400\" style=\"color:#CFD4DC\"> === <\/span><span data-hk=\"000000010000000000004000010b50401040a1500\" style=\"color:#B99AFF\">\"assistant\"<\/span><span data-hk=\"000000010000000000004000010b50401040a1600\" style=\"color:#CFD4DC\">) {<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b505\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/bookmark.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b50600\" id=\"7-calculator-stays-active-after-rewinding-before-discovery-kimi-deferred-toolsts\">7. <code data-hk=\"000000010000000000004000010b5060100\">Calculator<\/code> stays active after rewinding before discovery: <code data-hk=\"000000010000000000004000010b5060200\">kimi-deferred-tools.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b50700\"><a data-hk=\"000000010000000000004000010b5070100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/kimi-deferred-tools.ts#L47-L60\">source<\/a>:<br \/>\n<code data-hk=\"000000010000000000004000010b5070200\">tool_search<\/code> activates <code data-hk=\"000000010000000000004000010b5070300\">Calculator<\/code>, but no <code data-hk=\"000000010000000000004000010b5070400\">session_tree<\/code> handler derives the active roster again;<br \/>\nafter navigating to a point before discovery, <code data-hk=\"000000010000000000004000010b5070500\">Calculator<\/code> is still active.<\/p>\n<pre data-hk=\"000000010000000000004000010b50800\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b5080100\"><span data-hk=\"000000010000000000004000010b508010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b50801010100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b50801010200\" style=\"color:#C9A4FF\"> active<\/span><span data-hk=\"000000010000000000004000010b50801010300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50801010400\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b50801010500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50801010600\" style=\"color:#44CFFF\">getActiveTools<\/span><span data-hk=\"000000010000000000004000010b50801010700\" style=\"color:#CFD4DC\">();<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b508010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b50801020100\" style=\"color:#FF54C0\">const<\/span><span data-hk=\"000000010000000000004000010b50801020200\" style=\"color:#C9A4FF\"> added<\/span><span data-hk=\"000000010000000000004000010b50801020300\" style=\"color:#CFD4DC\"> = <\/span><span data-hk=\"000000010000000000004000010b50801020400\" style=\"color:#9BE8FF\">active<\/span><span data-hk=\"000000010000000000004000010b50801020500\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50801020600\" style=\"color:#44CFFF\">includes<\/span><span data-hk=\"000000010000000000004000010b50801020700\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b50801020800\" style=\"color:#B99AFF\">\"Calculator\"<\/span><span data-hk=\"000000010000000000004000010b50801020900\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b50801020a1000\" style=\"color:#FF54C0\">?<\/span><span data-hk=\"000000010000000000004000010b50801020a1100\" style=\"color:#CFD4DC\"> [] <\/span><span data-hk=\"000000010000000000004000010b50801020a1200\" style=\"color:#FF54C0\">:<\/span><span data-hk=\"000000010000000000004000010b50801020a1300\" style=\"color:#CFD4DC\"> [<\/span><span data-hk=\"000000010000000000004000010b50801020a1400\" style=\"color:#B99AFF\">\"Calculator\"<\/span><span data-hk=\"000000010000000000004000010b50801020a1500\" style=\"color:#CFD4DC\">];<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b508010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b50801030100\" style=\"color:#FF54C0\">if<\/span><span data-hk=\"000000010000000000004000010b50801030200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b50801030300\" style=\"color:#9BE8FF\">added<\/span><span data-hk=\"000000010000000000004000010b50801030400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50801030500\" style=\"color:#9BE8FF\">length<\/span><span data-hk=\"000000010000000000004000010b50801030600\" style=\"color:#CFD4DC\"> &gt; <\/span><span data-hk=\"000000010000000000004000010b50801030700\" style=\"color:#B99AFF\">0<\/span><span data-hk=\"000000010000000000004000010b50801030800\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b50801030900\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b50801030a1000\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b50801030a1100\" style=\"color:#44CFFF\">setActiveTools<\/span><span data-hk=\"000000010000000000004000010b50801030a1200\" style=\"color:#CFD4DC\">([...<\/span><span data-hk=\"000000010000000000004000010b50801030a1300\" style=\"color:#9BE8FF\">active<\/span><span data-hk=\"000000010000000000004000010b50801030a1400\" style=\"color:#CFD4DC\">, ...<\/span><span data-hk=\"000000010000000000004000010b50801030a1500\" style=\"color:#9BE8FF\">added<\/span><span data-hk=\"000000010000000000004000010b50801030a1600\" style=\"color:#CFD4DC\">]);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b508010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b50801040100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ Missing: session_tree \u2192 derive active tools from selected branch.<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b509\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/kimi-deferred-tools.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b51000\" id=\"8-switching-sessions-commits-the-worktree-auto-commit-on-exitts\">8. Switching sessions commits the worktree: <code data-hk=\"000000010000000000004000010b5100100\">auto-commit-on-exit.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b51100\"><a data-hk=\"000000010000000000004000010b5110100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/auto-commit-on-exit.ts#L11-L42\">source<\/a>:<br \/>\nmissing an exit-only boundary; <code data-hk=\"000000010000000000004000010b5110200\">\/new<\/code>, <code data-hk=\"000000010000000000004000010b5110300\">\/resume<\/code>, and <code data-hk=\"000000010000000000004000010b5110400\">\/fork<\/code> fire <code data-hk=\"000000010000000000004000010b5110500\">session_shutdown<\/code>, which stages<br \/>\nand commits the dirty worktree.<\/p>\n<pre data-hk=\"000000010000000000004000010b51200\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b5120100\"><span data-hk=\"000000010000000000004000010b512010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b51201010100\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b51201010200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b51201010300\" style=\"color:#44CFFF\">on<\/span><span data-hk=\"000000010000000000004000010b51201010400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b51201010500\" style=\"color:#B99AFF\">\"session_shutdown\"<\/span><span data-hk=\"000000010000000000004000010b51201010600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b51201010700\" style=\"color:#FF54C0\">async<\/span><span data-hk=\"000000010000000000004000010b51201010800\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b51201010900\" style=\"color:#9BE8FF;fontStyle:italic\">_event<\/span><span data-hk=\"000000010000000000004000010b51201010a1000\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b51201010a1100\" style=\"color:#9BE8FF;fontStyle:italic\">ctx<\/span><span data-hk=\"000000010000000000004000010b51201010a1200\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b51201010a1300\" style=\"color:#FF54C0\">=&gt;<\/span><span data-hk=\"000000010000000000004000010b51201010a1400\" style=\"color:#CFD4DC\"> {<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b512010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b51201020100\" style=\"color:#CFD4DC8F;fontStyle:italic\">  \/\/ \u2026<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b512010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b51201030100\" style=\"color:#FF54C0\">  await<\/span><span data-hk=\"000000010000000000004000010b51201030200\" style=\"color:#9BE8FF\"> pi<\/span><span data-hk=\"000000010000000000004000010b51201030300\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b51201030400\" style=\"color:#44CFFF\">exec<\/span><span data-hk=\"000000010000000000004000010b51201030500\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b51201030600\" style=\"color:#B99AFF\">\"git\"<\/span><span data-hk=\"000000010000000000004000010b51201030700\" style=\"color:#CFD4DC\">, [<\/span><span data-hk=\"000000010000000000004000010b51201030800\" style=\"color:#B99AFF\">\"add\"<\/span><span data-hk=\"000000010000000000004000010b51201030900\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b51201030a1000\" style=\"color:#B99AFF\">\"-A\"<\/span><span data-hk=\"000000010000000000004000010b51201030a1100\" style=\"color:#CFD4DC\">]);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b512010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b51201040100\" style=\"color:#FF54C0\">  await<\/span><span data-hk=\"000000010000000000004000010b51201040200\" style=\"color:#9BE8FF\"> pi<\/span><span data-hk=\"000000010000000000004000010b51201040300\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b51201040400\" style=\"color:#44CFFF\">exec<\/span><span data-hk=\"000000010000000000004000010b51201040500\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b51201040600\" style=\"color:#B99AFF\">\"git\"<\/span><span data-hk=\"000000010000000000004000010b51201040700\" style=\"color:#CFD4DC\">, [<\/span><span data-hk=\"000000010000000000004000010b51201040800\" style=\"color:#B99AFF\">\"commit\"<\/span><span data-hk=\"000000010000000000004000010b51201040900\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b51201040a1000\" style=\"color:#B99AFF\">\"-m\"<\/span><span data-hk=\"000000010000000000004000010b51201040a1100\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b51201040a1200\" style=\"color:#9BE8FF\">commitMessage<\/span><span data-hk=\"000000010000000000004000010b51201040a1300\" style=\"color:#CFD4DC\">]);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b512010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b51201050100\" style=\"color:#CFD4DC\">});<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b513\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/auto-commit-on-exit.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h4 data-hk=\"000000010000000000004000010b51400\" id=\"9-live-and-restored-state-disagree-tic-tac-toets\">9. Live and restored state disagree: <code data-hk=\"000000010000000000004000010b5140100\">tic-tac-toe.ts<\/code><\/h4>\n<p data-hk=\"000000010000000000004000010b51500\"><a data-hk=\"000000010000000000004000010b5150100\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/tic-tac-toe.ts#L631-L645\">restore<\/a>;<br \/>\n<a data-hk=\"000000010000000000004000010b5150200\" href=\"https:\/\/github.com\/earendil-works\/pi\/blob\/853a80d26c90a14c1886f0ebb8ffaae133ca2185\/packages\/coding-agent\/examples\/extensions\/tic-tac-toe.ts#L802-L810\">user<br \/>\nmove<\/a>:<br \/>\nreconstruction accepts only tool results, but user moves are custom entries; crash after X and<br \/>\nbefore O, and X disappears.<\/p>\n<pre data-hk=\"000000010000000000004000010b51600\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b5160100\"><span data-hk=\"000000010000000000004000010b516010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b51601010100\" style=\"color:#FF54C0\">if<\/span><span data-hk=\"000000010000000000004000010b51601010200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b51601010300\" style=\"color:#9BE8FF\">entry<\/span><span data-hk=\"000000010000000000004000010b51601010400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b51601010500\" style=\"color:#9BE8FF\">type<\/span><span data-hk=\"000000010000000000004000010b51601010600\" style=\"color:#CFD4DC\"> !== <\/span><span data-hk=\"000000010000000000004000010b51601010700\" style=\"color:#B99AFF\">\"message\"<\/span><span data-hk=\"000000010000000000004000010b51601010800\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b51601010900\" style=\"color:#FF54C0\">continue<\/span><span data-hk=\"000000010000000000004000010b51601010a1000\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b516010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b51601020100\" style=\"color:#FF54C0\">if<\/span><span data-hk=\"000000010000000000004000010b51601020200\" style=\"color:#CFD4DC\"> (<\/span><span data-hk=\"000000010000000000004000010b51601020300\" style=\"color:#9BE8FF\">msg<\/span><span data-hk=\"000000010000000000004000010b51601020400\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b51601020500\" style=\"color:#9BE8FF\">role<\/span><span data-hk=\"000000010000000000004000010b51601020600\" style=\"color:#CFD4DC\"> !== <\/span><span data-hk=\"000000010000000000004000010b51601020700\" style=\"color:#B99AFF\">\"toolResult\"<\/span><span data-hk=\"000000010000000000004000010b51601020800\" style=\"color:#CFD4DC\">) <\/span><span data-hk=\"000000010000000000004000010b51601020900\" style=\"color:#FF54C0\">continue<\/span><span data-hk=\"000000010000000000004000010b51601020a1000\" style=\"color:#CFD4DC\">;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b516010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b51601030100\" style=\"color:#CFD4DC8F;fontStyle:italic\">\/\/ User moves take a different path:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b516010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b51601040100\" style=\"color:#9BE8FF\">pi<\/span><span data-hk=\"000000010000000000004000010b51601040200\" style=\"color:#CFD4DC\">.<\/span><span data-hk=\"000000010000000000004000010b51601040300\" style=\"color:#44CFFF\">appendEntry<\/span><span data-hk=\"000000010000000000004000010b51601040400\" style=\"color:#CFD4DC\">(<\/span><span data-hk=\"000000010000000000004000010b51601040500\" style=\"color:#C9A4FF\">SAVE_TYPE<\/span><span data-hk=\"000000010000000000004000010b51601040600\" style=\"color:#CFD4DC\">, <\/span><span data-hk=\"000000010000000000004000010b51601040700\" style=\"color:#44CFFF\">getBoardDetails<\/span><span data-hk=\"000000010000000000004000010b51601040800\" style=\"color:#CFD4DC\">());<\/span><\/span><\/code><\/pre>\n<figure data-hk=\"000000010000000000004000010b517\"><video src=\"https:\/\/stencil.so\/blog\/harness-playbook\/bugs\/tic-tac-toe.mp4\" width=\"1000\" height=\"684\" autoplay=\"\" loop=\"\" muted=\"\" playsinline=\"\"\/><\/figure>\n<h2 data-hk=\"000000010000000000004000010b51800\" id=\"appendix-b-elastic-speculative-slots\">Appendix B: Elastic Speculative Slots<\/h2>\n<p data-hk=\"000000010000000000004000010b51900\">The interface chapter keeps the protocol and conclusions in the main reading path. This appendix<br \/>\ncontains the paper and the complete <a data-hk=\"000000010000000000004000010b5190100\" href=\"https:\/\/lamport.azurewebsites.net\/tla\/tla.html\">TLA+<\/a> model used to check the transcript invariants.<\/p>\n<figure data-hk=\"000000010000000000004000010b520\"><a href=\"https:\/\/stencil.so\/blog\/harness-playbook\/elastic-slots.pdf\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/stencil.so\/blog\/harness-playbook\/elastic-slots-p1.png\" width=\"1082\" height=\"1400\" alt=\"First page of the Elastic Speculative Slots paper: a formally verified rendering protocol for streaming concurrent output blocks through a bounded terminal viewport into append-only scrollback\" loading=\"lazy\"\/><\/a><figcaption>&#8220;Elastic Speculative Slots&#8221; \u2014 the paper: the three-layer contract, the safety theorem, and the conditional progress results, one-to-one with the full spec below. \u00b7 Click through for the full PDF.<\/figcaption><\/figure>\n<details data-hk=\"000000010000000000004000010b521\">\n<summary>ElasticSlots.tla \u2014 the full spec<\/summary>\n<p><!--$--><\/p>\n<pre data-hk=\"000000010000000000004000010b52200\" class=\"shiki plasma \" style=\"backgroundColor:#050508;color:#CFD4DC\" tabindex=\"0\"><code data-hk=\"000000010000000000004000010b5220100\"><span data-hk=\"000000010000000000004000010b522010100\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201010100\">---- MODULE ElasticSlots ----<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010200\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201020100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010300\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201030100\">\\* Elastic Speculative Slots: a formally verified rendering protocol for<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010400\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201040100\">\\* streaming concurrent output blocks through a bounded terminal viewport<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010500\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201050100\">\\* into append-only scrollback.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010600\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201060100\">\\*<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010700\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201070100\">\\* Three decoupled layers, related by invariants (see ELASTIC_SLOTS2.tex):<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010800\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201080100\">\\*   1. semantic block state   (phase\/mode\/want\/final\/emitted per block)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010900\" class=\"line \"><span data-hk=\"000000010000000000004000010b52201090100\">\\*   2. logical history ledger (`history`: width-independent, exactly-once)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a100100\">\\*   3. physical native rows   (`native`: width-rendered, source-tagged)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a110100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a120100\">EXTENDS Naturals, Sequences, FiniteSets, TLC<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a130100\">\\* Naturals: arithmetic; Sequences: &lt;&lt;&gt;&gt;\/Len\/SubSeq\/\\o; FiniteSets:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a140100\">\\* Cardinality\/IsFiniteSet; TLC: model-checking utilities.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a150100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a160100\">CONSTANTS N, H, MaxResizes, MaxLive, RowValues, SnapshotValues,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a170100\">          NoFinal, Placeholder, Blank, OverflowMarker<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a180100\">\\* N            : number of block identities (blocks are 1..N, in commit order)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a1900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a190100\">\\* H            : maximum viewport (live transcript) height, in rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a200100\">\\* MaxResizes   : bound on resize events (keeps the state space finite)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a210100\">\\* MaxLive      : uncommitted-block count that constitutes \"pressure\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a220100\">\\* RowValues    : finite row alphabet (what a semantic line of output \"is\")<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a230100\">\\* SnapshotValues: finite universe of block contents (sequences of rows)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a240100\">\\* NoFinal      : sentinel \"this block has no final snapshot yet\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a250100\">\\* Placeholder  : synthetic viewport row shown for an empty slot<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a260100\">\\* Blank        : synthetic viewport row for unused screen space<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a270100\">\\* OverflowMarker: synthetic viewport row summarizing hidden older blocks<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a280100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010a2900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a290100\">ASSUME<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a300100\">    \u2227 N \u2208 \u2115 \\ {0}                                  \\* at least one block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a310100\">    \u2227 H \u2208 \u2115 \\ {0}                                  \\* viewport can be nonempty<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a320100\">    \u2227 MaxResizes \u2208 \u2115                               \\* zero resizes is allowed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a330100\">    \u2227 MaxLive \u2208 \u2115 \\ {0}                            \\* pressure threshold &gt;= 1<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a340100\">    \u2227 IsFiniteSet(RowValues)                           \\* finite row alphabet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a350100\">    \u2227 RowValues \u2260 {}                                   \\* ... and nonempty<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a360100\">    \u2227 IsFiniteSet(SnapshotValues)                      \\* finite snapshot universe<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a370100\">    \u2227 SnapshotValues \u2286 Seq(RowValues)          \\* snapshots are row sequences<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a380100\">    \u2227 \u27e8\u27e9 \u2208 SnapshotValues                          \\* the empty snapshot exists<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a3900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a390100\">    \u2227 (\u2203 snapshot \u2208 SnapshotValues : Len(snapshot) = 1)  \\* a length-1 snapshot exists<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a400100\">    \u2227 (\u2203 snapshot \u2208 SnapshotValues : Len(snapshot) &gt; 1)  \\* a longer one exists too<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a410100\">    \u2227 NoFinal \u2209 SnapshotValues                    \\* sentinel distinct from real data<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a420100\">    \u2227 Placeholder \u2209 RowValues                     \\* synthetic rows are not<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a430100\">    \u2227 Blank \u2209 RowValues                           \\* ... confusable with<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a440100\">    \u2227 OverflowMarker \u2209 RowValues                  \\* ... semantic rows,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a450100\">    \u2227 Placeholder \u2260 Blank                              \\* and are pairwise<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a460100\">    \u2227 Placeholder \u2260 OverflowMarker                     \\* distinct from<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a470100\">    \u2227 Blank \u2260 OverflowMarker                           \\* each other.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a480100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010a4900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a490100\">Blocks \u225c 1\u2025N                                          \\* the block identities<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a500100\">ModelRows \u225c {\"row-a\", \"row-b\"}                         \\* tiny concrete row alphabet for TLC<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a510100\">ModelSnapshots \u225c                                       \\* a richer snapshot universe (unused by the shipped cfg)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a520100\">    {\u27e8\u27e9,                                              \\* empty block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a530100\">     \u27e8\"row-a\"\u27e9,                                       \\* one-liner<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a540100\">     \u27e8\"row-b\"\u27e9,                                       \\* one-liner, other row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a550100\">     \u27e8\"row-a\", \"row-b\"\u27e9,                              \\* two distinct rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a560100\">     \u27e8\"row-b\", \"row-a\"\u27e9,                              \\* order matters<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a570100\">     \u27e8\"row-a\", \"row-b\", \"row-a\"\u27e9}                     \\* length three, with repeat<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a580100\">SmallModelSnapshots \u225c {\u27e8\u27e9, \u27e8\"row-a\"\u27e9, \u27e8\"row-a\", \"row-b\"\u27e9}  \\* the cfg's universe: lengths 0, 1, 2<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a5900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a590100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a600100\">WidthValues \u225c {\"Wide\", \"Narrow\"}                       \\* two-point abstraction of terminal width<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a610100\">ResizeModes \u225c {\"Preserve\", \"Append\", \"Rebuild\"}        \\* policy chosen at a width-changing resize<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a620100\">ReplayModes \u225c {\"None\", \"Append\", \"Rebuild\"}            \\* pending replay (None = no replay in flight)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a630100\">BlockModes \u225c {\"Undeclared\", \"Mutable\", \"AppendOnly\"}   \\* presentation contract, fixed at Create<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a640100\">Phases \u225c {\"Absent\", \"Queued\", \"Active\", \"Finalized\", \"Committed\"}  \\* block lifecycle, monotone left-to-right<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a650100\">StopReasons \u225c {\"Running\", \"Graceful\", \"Detach\", \"WriteFailure\"}    \\* why the host stopped (Running = it hasn't)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a660100\">NativeSources \u225c {\"Append\", \"Retire\", \"Replay\", \"Resize\", \"FailedWrite\", \"Exit\"}  \\* provenance tag on every native row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a670100\">CellRows \u225c RowValues \u222a {Placeholder, Blank, OverflowMarker}     \\* what a viewport cell may display<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a680100\">Cells \u225c [owner : 0\u2025N, row : CellRows]                 \\* a viewport cell: owning block (0 = chrome) + row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a6900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a690100\">TaggedRows \u225c [owner : Blocks, row : RowValues]         \\* a ledger row: semantic, width-independent<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a700100\">NativeRows \u225c [source : NativeSources, owner : 0\u2025N, row : CellRows, width : WidthValues]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a710100\">\\* a native row: provenance source, owner, rendered row, and the width it was rendered at<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a720100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a730100\">SnapshotLengths \u225c {Len(snapshot) : snapshot \u2208 SnapshotValues}  \\* set of occurring snapshot lengths<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a740100\">MaxSnapshotLength \u225c                                    \\* L_max: the longest snapshot length<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a750100\">    CHOOSE maximum \u2208 SnapshotLengths :                \\* (CHOOSE is fine here: the maximum<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a760100\">        \u2200 length \u2208 SnapshotLengths : length \u2264 maximum  \\*  of a finite set is unique)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a770100\">MaxFailureRows \u225c 2 * N * MaxSnapshotLength             \\* K_max: upper bound on one physical write batch<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a780100\">                                                        \\* (factor 2 = worst-case Narrow doubling)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a7900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a790100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a800100\">BlankCell \u225c [owner \u21a6 0, row \u21a6 Blank]               \\* the unused-screen-space cell<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a810100\">OverflowCell \u225c [owner \u21a6 0, row \u21a6 OverflowMarker]   \\* the \"N older blocks hidden\" summary cell<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a820100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a830100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a840100\">\\* State variables (one tuple entry per column of Table 1 in the paper).<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a850100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a860100\">VARIABLES c, phase, mode, want, final, emitted, alloc, target,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a870100\">          history, native, width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a880100\">          replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a8900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a890100\">          replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a900100\">          flush, shutdown, running, stopReason<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a910100\">\\* c              : commit frontier -- blocks 1..c are committed (retired)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a920100\">\\* phase          : lifecycle phase per block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a930100\">\\* mode           : Mutable \/ AppendOnly contract per block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a940100\">\\* want           : current speculative snapshot per block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a950100\">\\* final          : frozen final snapshot per block (NoFinal until finalized)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a960100\">\\* emitted        : rows of the head block already streamed into history<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a970100\">\\* alloc          : painted slot height per block (rows on screen now)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a980100\">\\* target         : requested slot height per block (animation target)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010a9900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010a990100\">\\* history        : the logical ledger (layer 2)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1000100\">\\* native         : the physical scrollback of the current epoch (layer 3)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1010100\">\\* width, height  : current terminal geometry<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1020100\">\\* resizes        : how many resizes happened (bounded by MaxResizes)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1030100\">\\* epoch          : display epoch; Rebuild resets native and bumps this<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1040100\">\\* replayMode     : pending replay policy (None \/ Append \/ Rebuild)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1050100\">\\* replayCursor   : first committed block to replay (invariantly 1 while replaying)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1060100\">\\* replayEnd      : last committed block to replay (= c at replay start)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1070100\">\\* replayPartial  : how many stable head rows to replay<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1080100\">\\* replayPrepared : replay frame computed and cut fixed (gates the scheduler)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b10900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1090100\">\\* replayCut      : rows of the replay frame that must scroll into native<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1100100\">\\* flush          : explicit \"retire everything\" request (never reset)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1110100\">\\* shutdown       : graceful shutdown initiated<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1120100\">\\* running        : host still alive; every action requires it<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1130100\">\\* stopReason     : why we stopped (Running while alive)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1140100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1150100\">vars \u225c \u27e8c, phase, mode, want, final, emitted, alloc, target,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1160100\">          history, native, width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1170100\">          replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1180100\">          replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b11900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1190100\">          flush, shutdown, running, stopReason\u27e9<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1200100\">\\* the full variable tuple, used for stuttering ([Next]_vars) and UNCHANGED<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1210100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1220100\">Maximum(left, right) \u225c IF left \u2265 right THEN left ELSE right  \\* max of two naturals<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1230100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1240100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1250100\">\\* Width rendering: the two-point abstraction of soft-wrap reflow.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1260100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1270100\">RECURSIVE DoubleRows(_)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1280100\">DoubleRows(snapshot) \u225c                                 \\* Narrow rendering:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b12900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1290100\">    IF Len(snapshot) = 0 THEN \u27e8\u27e9                      \\* empty stays empty;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1300100\">    ELSE \u27e8Head(snapshot), Head(snapshot)\u27e9 \u2218 DoubleRows(Tail(snapshot))<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1310100\">    \\* every semantic row occupies TWO physical rows (models a wrapped line)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1320100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1330100\">Render(snapshot, wx) \u225c IF wx = \"Wide\" THEN snapshot ELSE DoubleRows(snapshot)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1340100\">\\* rho_omega: Wide = identity, Narrow = row doubling; prefix-monotone by construction<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1350100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1360100\">Tag(i, snapshot) \u225c                                     \\* tg_i: stamp each row with its owner<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1370100\">    [j \u2208 1\u2025Len(snapshot) \u21a6 [owner \u21a6 i, row \u21a6 snapshot[j]]]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1380100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b13900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1390100\">SnapshotSlice(snapshot, lo, hi) \u225c                      \\* s[lo..hi], empty when lo &gt; hi<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1400100\">    IF lo &gt; hi THEN \u27e8\u27e9 ELSE SubSeq(snapshot, lo, hi)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1410100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1420100\">TagSlice(i, snapshot, lo, hi) \u225c Tag(i, SnapshotSlice(snapshot, lo, hi))  \\* owner-tagged slice<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1430100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1440100\">NativeTag(source, i, snapshot, wx) \u225c                   \\* ntg: render at width wx, then tag<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1450100\">    [j \u2208 1\u2025Len(Render(snapshot, wx)) \u21a6             \\* one native row per RENDERED row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1460100\">        [source \u21a6 source, owner \u21a6 i,                \\* provenance + owner<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1470100\">         row \u21a6 Render(snapshot, wx)[j], width \u21a6 wx]]  \\* rendered row + width it used<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1480100\">NativeTagSlice(source, i, snapshot, lo, hi, wx) \u225c      \\* native-tag a semantic slice<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b14900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1490100\">    NativeTag(source, i, SnapshotSlice(snapshot, lo, hi), wx)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1500100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1510100\">NativeCells(source, cells, wx) \u225c                       \\* lift screen cells to native rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1520100\">    [j \u2208 1\u2025Len(cells) \u21a6                            \\* (used when the emulator itself<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1530100\">        [source \u21a6 source, owner \u21a6 cells[j].owner,   \\*  pushes viewport rows into<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1540100\">         row \u21a6 cells[j].row, width \u21a6 wx]]           \\*  scrollback, e.g. on resize\/exit)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1550100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1560100\">PrefixOf(sequence, count) \u225c [j \u2208 1\u2025count \u21a6 sequence[j]]  \\* first `count` elements<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1570100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1580100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b15900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1590100\">\\* The logical ledger as a FUNCTION of state (invariant ECH says<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1600100\">\\* `history` always equals CommittedRows(c, final) \\o PartialHeadRows).<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1610100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1620100\">RECURSIVE CommittedRows(_, _)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1630100\">CommittedRows(k, finals) \u225c                             \\* C(k): finals of blocks 1..k,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1640100\">    IF k = 0 THEN \u27e8\u27e9                                  \\* tagged, concatenated in<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1650100\">    ELSE CommittedRows(k - 1, finals) \u2218 Tag(k, finals[k])  \\* block (= commit) order<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1660100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1670100\">RECURSIVE TaggedRange(_, _, _)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1680100\">TaggedRange(lo, hi, finals) \u225c                          \\* tagged finals of blocks lo..hi<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b16900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1690100\">    IF lo &gt; hi THEN \u27e8\u27e9                                \\* (empty range allowed)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1700100\">    ELSE Tag(lo, finals[lo]) \u2218 TaggedRange(lo + 1, hi, finals)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1710100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1720100\">RECURSIVE NativeRange(_, _, _, _, _)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1730100\">NativeRange(source, lo, hi, finals, wx) \u225c              \\* same, but width-rendered and<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1740100\">    IF lo &gt; hi THEN \u27e8\u27e9                                \\* source-tagged for `native`<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1750100\">    ELSE NativeTag(source, lo, finals[lo], wx)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1760100\">         \u2218 NativeRange(source, lo + 1, hi, finals, wx)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1770100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1780100\">RetirementRows(lo, hi, finals, firstEmitted) \u225c         \\* logical retirement batch:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b17900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1790100\">    IF lo &gt; hi THEN \u27e8\u27e9                                \\* head block lo contributes only<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1800100\">    ELSE TagSlice(lo, finals[lo], firstEmitted + 1, Len(finals[lo]))  \\* its UNstreamed suffix,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1810100\">         \u2218 TaggedRange(lo + 1, hi, finals)             \\* later blocks contribute in full<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1820100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1830100\">NativeRetirementRows(source, lo, hi, finals, firstEmitted, wx) \u225c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1840100\">    IF lo &gt; hi THEN \u27e8\u27e9                                \\* physical twin of RetirementRows:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1850100\">    ELSE NativeTagSlice(                                \\* the same rows,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1860100\">             source,                                    \\* provenance-tagged<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1870100\">             lo,                                        \\* (Retire on success,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1880100\">             finals[lo],                                \\*  FailedWrite on failure),<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b18900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1890100\">             firstEmitted + 1,                          \\* starting after the already-<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1900100\">             Len(finals[lo]),                           \\* streamed head prefix,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1910100\">             wx                                         \\* rendered at the current width<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1920100\">         )<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1930100\">         \u2218 NativeRange(source, lo + 1, hi, finals, wx) \\* then full later finals<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1940100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1950100\">FinalizedRange(lo, hi) \u225c                               \\* \"blocks lo..hi are all Finalized\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1960100\">    \u2200 i \u2208 lo\u2025hi : phase[i] = \"Finalized\"            \\* (a retirement batch precondition)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1970100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1980100\">Unemitted(snapshot, i, emission) \u225c                     \\* U_i(s): the part of s not yet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b19900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b1990100\">    IF mode[i] = \"AppendOnly\"                           \\* streamed into history --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2000100\">    THEN SnapshotSlice(snapshot, emission[i] + 1, Len(snapshot))  \\* suffix for append-only,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2010100\">    ELSE snapshot                                       \\* everything for mutable blocks<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2020100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2030100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2040100\">\\* Live-viewport geometry: who is presented, who is visible, how much<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2050100\">\\* space is reserved. All operators take the ambient tuple explicitly so<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2060100\">\\* that action guards can evaluate them at SUCCESSOR values.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2070100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2080100\">Presented(ph, finals, emission, i, wx) \u225c               \\* block i occupies viewport iff<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b20900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2090100\">    \u2228 ph[i] = \"Active\"                                 \\* it is actively producing, or<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2100100\">    \u2228 \u2227 ph[i] = \"Finalized\"                           \\* it is finalized AND still has<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2110100\">     \u2227 Len(Render(Unemitted(finals[i], i, emission), wx)) &gt; 0  \\* unstreamed content to show<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2120100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2130100\">PresentedSet(ph, finals, emission, wx) \u225c               \\* the set of presented blocks<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2140100\">    {i \u2208 Blocks : Presented(ph, finals, emission, i, wx)}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2150100\">PresentedCount(ph, finals, emission, wx) \u225c             \\* pi: how many are presented<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2160100\">    Cardinality(PresentedSet(ph, finals, emission, wx))<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2170100\">Overflow(ph, finals, emission, wx, hx) \u225c               \\* ovf: more presented blocks<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2180100\">    PresentedCount(ph, finals, emission, wx) &gt; hx       \\* than viewport rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b21900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2190100\">SummaryRows(ph, finals, emission, wx, hx) \u225c            \\* sigma: one summary row is<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2200100\">    IF hx &gt; 0 \u2227 Overflow(ph, finals, emission, wx, hx) THEN 1 ELSE 0  \\* shown iff overflowing (and h&gt;0)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2210100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2220100\">NewerPresented(ph, finals, emission, wx, i) \u225c          \\* how many presented blocks are<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2230100\">    Cardinality({                                       \\* NEWER (higher index) than i --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2240100\">        j \u2208 Blocks :                                  \\* used to privilege recency<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2250100\">            j &gt; i \u2227 Presented(ph, finals, emission, j, wx)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2260100\">    })<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2270100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2280100\">VisiblePresented(ph, finals, emission, wx, hx, i) \u225c    \\* vis(i): presented AND, under<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b22900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2290100\">    \u2227 Presented(ph, finals, emission, i, wx)           \\* overflow, among the hx-1<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2300100\">    \u2227 IF Overflow(ph, finals, emission, wx, hx)        \\* newest presented blocks<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2310100\">       THEN \u2227 hx &gt; 0                                   \\* (one row is sacrificed to<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2320100\">            \u2227 NewerPresented(ph, finals, emission, wx, i) &lt; hx - 1  \\* the summary marker)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2330100\">       ELSE TRUE                                        \\* no overflow: presented = visible<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2340100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2350100\">RECURSIVE AllocationTotal(_, _)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2360100\">AllocationTotal(al, i) \u225c                               \\* sum of painted heights,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2370100\">    IF i &gt; N THEN 0 ELSE al[i] + AllocationTotal(al, i + 1)  \\* blocks i..N<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2380100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b23900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2390100\">RECURSIVE ReservationTotal(_, _, _)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2400100\">ReservationTotal(al, requested, i) \u225c                   \\* Res: each block is charged<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2410100\">    IF i &gt; N THEN 0                                     \\* max(painted, requested) --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2420100\">    ELSE Maximum(al[i], requested[i]) + ReservationTotal(al, requested, i + 1)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2430100\">    \\* growth pays up front, shrink keeps its old charge until painted<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2440100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2450100\">AllocationStateOK(al, requested, ph, finals, emission, wx, hx) \u225c  \\* A_OK: allocation admissibility<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2460100\">    \u2227 al \u2208 [Blocks \u2192 0\u2025H]                          \\* painted heights in range<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2470100\">    \u2227 requested \u2208 [Blocks \u2192 0\u2025H]                   \\* requested heights in range<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2480100\">    \u2227 \u2200 i \u2208 Blocks :<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b24900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2490100\">           IF VisiblePresented(ph, finals, emission, wx, hx, i)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2500100\">           THEN IF ph[i] = \"Active\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2510100\">                THEN \u2227 al[i] \u2208 1\u2025H                  \\* visible active: painted &gt;= 1,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2520100\">                     \u2227 requested[i] \u2208 1\u2025H           \\* target &gt;= 1 (may differ: animating)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2530100\">                ELSE \u2227 al[i] \u2208 1\u2025H                  \\* visible finalized: painted &gt;= 1,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2540100\">                     \u2227 requested[i] = al[i]            \\* and frozen (no more animation)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2550100\">           ELSE \u2227 al[i] = 0                            \\* invisible blocks hold<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2560100\">                \u2227 requested[i] = 0                     \\* no space at all<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2570100\">    \u2227 ReservationTotal(al, requested, 1)               \\* reservation invariant:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2580100\">       + SummaryRows(ph, finals, emission, wx, hx) \u2264 hx  \\* reservations + summary fit in h<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b25900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2590100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2600100\">CanonicalAllocation(ph, finals, emission, wx, hx) \u225c    \\* kappa: the safe default --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2610100\">    [i \u2208 Blocks \u21a6                                   \\* one row per visible block,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2620100\">        IF VisiblePresented(ph, finals, emission, wx, hx, i) THEN 1 ELSE 0]  \\* zero otherwise<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2630100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2640100\">SnapshotHeight(ph, wants, finals, i, wx) \u225c             \\* dm(i): row demand of block i<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2650100\">    CASE ph[i] = \"Active\" \u2192<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2660100\">             Maximum(1, Len(Render(Unemitted(wants[i], i, emitted), wx)))  \\* live: &gt;= 1 row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2670100\">      \u25a1 ph[i] = \"Queued\" \u2192<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2680100\">             Maximum(1, Len(Render(Unemitted(wants[i], i, emitted), wx)))  \\* queued demands space too<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b26900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2690100\">      \u25a1 ph[i] = \"Finalized\" \u2192<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2700100\">             Len(Render(Unemitted(finals[i], i, emitted), wx))  \\* finalized: exactly its unstreamed rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2710100\">      \u25a1 OTHER \u2192 0                                     \\* absent\/committed demand nothing<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2720100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2730100\">RECURSIVE FullRows(_, _, _, _, _)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2740100\">FullRows(ph, wants, finals, wx, i) \u225c                   \\* D: total row demand of<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2750100\">    IF i &gt; N THEN 0                                     \\* blocks i..N<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2760100\">    ELSE SnapshotHeight(ph, wants, finals, i, wx)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2770100\">         + FullRows(ph, wants, finals, wx, i + 1)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2780100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b27900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2790100\">CreatedCount \u225c Cardinality({i \u2208 Blocks : phase[i] \u2260 \"Absent\"})  \\* gamma: how many blocks exist<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2800100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2810100\">PartialHeadExists \u225c                                    \\* PH: the head block (c+1) has<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2820100\">    \u2227 c &lt; CreatedCount                                 \\* been created,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2830100\">    \u2227 mode[c + 1] = \"AppendOnly\"                       \\* is append-only,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2840100\">    \u2227 phase[c + 1] \u2208 {\"Active\", \"Finalized\"}         \\* is live,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2850100\">    \u2227 emitted[c + 1] &gt; 0                               \\* and has streamed some rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2860100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2870100\">PartialHeadRows \u225c                                      \\* A(c): the head's streamed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2880100\">    IF PartialHeadExists                                \\* prefix as tagged ledger rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b28900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2890100\">    THEN TagSlice(c + 1, want[c + 1], 1, emitted[c + 1])  \\* (prefix of `want`, stable by<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2900100\">    ELSE \u27e8\u27e9                                           \\*  the append-only contract)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2910100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2920100\">RowPressure \u225c FullRows(phase, want, final, width, 1) &gt; height  \\* demand exceeds viewport<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2930100\">Pressure \u225c                                             \\* pressure = row pressure OR<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2940100\">    \u2228 RowPressure                                      \\* too many uncommitted<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2950100\">    \u2228 CreatedCount - c \u2265 MaxLive                      \\* blocks piling up<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2960100\">RetirementRequested \u225c flush \u2228 Pressure                \\* Req: when retirement may fire<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2970100\">Replaying \u225c replayMode \u2260 \"None\"                        \\* a replay is in flight<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2980100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b29900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b2990100\">PreviewSource(i) \u225c                                     \\* what a slot displays:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3000100\">    IF phase[i] = \"Active\"                              \\* live blocks show their<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3010100\">    THEN Unemitted(want[i], i, emitted)                 \\* unstreamed speculation,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3020100\">    ELSE Unemitted(final[i], i, emitted)                \\* others their unstreamed final<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3030100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3040100\">PreviewCell(i, snapshot) \u225c                             \\* the representative cell of a slot:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3050100\">    LET rendered \u225c Render(snapshot, width) IN          \\* render at current width;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3060100\">    [owner \u21a6 i,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3070100\">     row \u21a6 IF Len(rendered) = 0                       \\* empty content shows the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3080100\">             THEN Placeholder                           \\* placeholder row, otherwise<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b30900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3090100\">             ELSE rendered[Len(rendered)]]              \\* the LAST rendered row (tail view)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3100100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3110100\">Repeat(value, count) \u225c [j \u2208 1\u2025count \u21a6 value]      \\* value^count as a sequence<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3120100\">Slot(i, snapshot, allocation) \u225c Repeat(PreviewCell(i, snapshot), allocation)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3130100\">\\* a slot = its preview cell repeated alloc[i] times (abstracting the real tail window)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3140100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3150100\">RECURSIVE PresentedCells(_)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3160100\">PresentedCells(i) \u225c                                    \\* all slots, ascending block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3170100\">    IF i &gt; N THEN \u27e8\u27e9                                  \\* order (newest at the bottom,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3180100\">    ELSE (IF alloc[i] = 0 THEN \u27e8\u27e9 ELSE Slot(i, PreviewSource(i), alloc[i]))  \\* next to the cursor);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b31900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3190100\">         \u2218 PresentedCells(i + 1)                       \\* zero-alloc blocks contribute nothing<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3200100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3210100\">Screen \u225c                                               \\* Q: the whole viewport, top to bottom:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3220100\">    Repeat(<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3230100\">        BlankCell,                                      \\* blank filler first,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3240100\">        height - AllocationTotal(alloc, 1) - SummaryRows(phase, final, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3250100\">    )                                                   \\* (exactly the unclaimed rows)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3260100\">    \u2218 (IF SummaryRows(phase, final, emitted, width, height) = 1<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3270100\">        THEN \u27e8OverflowCell\u27e9                           \\* then the overflow summary if any,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3280100\">        ELSE \u27e8\u27e9)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b32900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3290100\">    \u2218 PresentedCells(1)                                \\* then the block slots<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3300100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3310100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3320100\">\\* Replay geometry: what a width-changing resize must re-render.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3330100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3340100\">ReplayRows \u225c                                           \\* R: the full replay frame --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3350100\">    IF \u00acReplaying<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3360100\">    THEN \u27e8\u27e9                                           \\* nothing when no replay pending<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3370100\">    ELSE NativeRange(\"Replay\", replayCursor, replayEnd, final, width)  \\* committed finals 1..c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3380100\">         \u2218 (IF replayPartial = 0                       \\* re-rendered at the NEW width,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b33900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3390100\">             THEN \u27e8\u27e9                                  \\* plus the head's already-<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3400100\">             ELSE NativeTagSlice(                       \\* streamed stable prefix<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3410100\">                     \"Replay\",                          \\* (if it had streamed rows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3420100\">                     replayEnd + 1,                     \\*  at resize time) --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3430100\">                     want[replayEnd + 1],               \\* prefix of want, immutable<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3440100\">                     1,                                 \\* under the append-only<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3450100\">                     replayPartial,                     \\* contract, so stable while<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3460100\">                     width                              \\* the replay is in flight<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3470100\">                  ))<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3480100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b34900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3490100\">ReplayRoom \u225c                                           \\* how many blank rows the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3500100\">    Cardinality({j \u2208 1\u2025height : Screen[j] = BlankCell})  \\* viewport can absorb scroll-free<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3510100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3520100\">RequiredReplayCut \u225c                                    \\* cut*: replay rows that do NOT<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3530100\">    IF Len(ReplayRows) &gt; ReplayRoom THEN Len(ReplayRows) - ReplayRoom ELSE 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3540100\">    \\* fit in the blank region and must scroll into native scrollback<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3550100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3560100\">PreparedReplayTail \u225c                                   \\* the part painted bottom-first<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3570100\">    IF replayPrepared                                   \\* into blank rows (no scroll);<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3580100\">    THEN SnapshotSlice(ReplayRows, replayCut + 1, Len(ReplayRows))  \\* only meaningful once<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b35900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3590100\">    ELSE \u27e8\u27e9                                           \\* the frame is prepared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3600100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3610100\">Prefix(left, right) \u225c                                  \\* left is a prefix of right<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3620100\">    \u2227 Len(left) \u2264 Len(right)                          \\* (the partial order behind the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3630100\">    \u2227 \u2200 j \u2208 1\u2025Len(left) : left[j] = right[j]       \\*  append-only contract)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3640100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3650100\">NoEarlierQueued(i) \u225c \u2200 j \u2208 1\u2025(i - 1) : phase[j] \u2260 \"Queued\"  \\* FIFO admission guard<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3660100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3670100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3680100\">\\* Initial state: nothing created, full-height wide viewport, empty<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b36900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3690100\">\\* histories, no replay, host running.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3700100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3710100\">Init \u225c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3720100\">    \u2227 c = 0                                            \\* nothing committed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3730100\">    \u2227 phase = [i \u2208 Blocks \u21a6 \"Absent\"]              \\* no block exists<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3740100\">    \u2227 mode = [i \u2208 Blocks \u21a6 \"Undeclared\"]           \\* no contract chosen<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3750100\">    \u2227 want = [i \u2208 Blocks \u21a6 \u27e8\u27e9]                   \\* empty speculation<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3760100\">    \u2227 final = [i \u2208 Blocks \u21a6 NoFinal]               \\* nothing finalized<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3770100\">    \u2227 emitted = [i \u2208 Blocks \u21a6 0]                   \\* nothing streamed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3780100\">    \u2227 alloc = [i \u2208 Blocks \u21a6 0]                     \\* no slot painted<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b37900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3790100\">    \u2227 target = [i \u2208 Blocks \u21a6 0]                    \\* no slot requested<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3800100\">    \u2227 history = \u27e8\u27e9                                   \\* empty ledger (= CommittedRows(0,...))<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3810100\">    \u2227 native = \u27e8\u27e9                                    \\* empty scrollback<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3820100\">    \u2227 width = \"Wide\"                                   \\* initial geometry:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3830100\">    \u2227 height = H                                       \\* wide, full height<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3840100\">    \u2227 resizes = 0                                      \\* no resizes yet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3850100\">    \u2227 epoch = 0                                        \\* first display epoch<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3860100\">    \u2227 replayMode = \"None\"                              \\* no replay pending<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3870100\">    \u2227 replayCursor = 0                                 \\* replay window empty<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3880100\">    \u2227 replayEnd = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b38900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3890100\">    \u2227 replayPartial = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3900100\">    \u2227 replayPrepared = FALSE                           \\* no frame prepared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3910100\">    \u2227 replayCut = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3920100\">    \u2227 flush = FALSE                                    \\* no flush requested<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3930100\">    \u2227 shutdown = FALSE                                 \\* not shutting down<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3940100\">    \u2227 running = TRUE                                   \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3950100\">    \u2227 stopReason = \"Running\"                           \\* ... and not stopped<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3960100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3970100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3980100\">\\* Actions. Every guard conjoins `running`; most also require ~shutdown.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b39900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b3990100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4000100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4010100\">Create(declaration) \u225c                                  \\* a new block is declared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4020100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4030100\">    \u2227 \u00acshutdown                                        \\* no new work during shutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4040100\">    \u2227 CreatedCount &lt; N                                 \\* an identity is still free<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4050100\">    \u2227 phase[CreatedCount + 1] = \"Absent\"               \\* blocks are created contiguously<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4060100\">    \u2227 declaration \u2208 {\"Mutable\", \"AppendOnly\"}        \\* contract chosen now, forever<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4070100\">    \u2227 phase' = [phase EXCEPT ![CreatedCount + 1] = \"Queued\"]  \\* enters the queue<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4080100\">    \u2227 mode' = [mode EXCEPT ![CreatedCount + 1] = declaration] \\* contract recorded<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b40900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4090100\">    \u2227 UNCHANGED \u27e8c, want, final, emitted, alloc, target, history, native,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4100100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4110100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4120100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4130100\">                   flush, shutdown, running, stopReason\u27e9  \\* pure bookkeeping: no paint, no history<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4140100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4150100\">Admit(i) \u225c                                             \\* a queued block gets a live slot<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4160100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4170100\">    \u2227 \u00acshutdown                                        \\* not during shutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4180100\">    \u2227 phase[i] = \"Queued\"                              \\* must be waiting<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b41900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4190100\">    \u2227 NoEarlierQueued(i)                               \\* FIFO: no older block still queued<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4200100\">    \u2227 LET newPhase \u225c [phase EXCEPT ![i] = \"Active\"]   \\* candidate successor phase,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4210100\">           newAlloc \u225c [alloc EXCEPT ![i] = 1]          \\* with a fresh 1-row slot<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4220100\">           newTarget \u225c [target EXCEPT ![i] = 1]        \\* painted and requested<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4230100\">       IN \u2227 \u00acOverflow(newPhase, final, emitted, width, height)  \\* admission may NOT overflow --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4240100\">          \u2227 AllocationStateOK(newAlloc, newTarget, newPhase, final, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4250100\">          \\* ... and the new slot must fit the reservation invariant; otherwise the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4260100\">          \\* block simply stays queued (denied, not summarized)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4270100\">          \u2227 phase' = newPhase                          \\* commit the candidate state<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4280100\">          \u2227 alloc' = newAlloc<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b42900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4290100\">          \u2227 target' = newTarget<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4300100\">    \u2227 UNCHANGED \u27e8c, mode, want, final, emitted, history, native, width, height,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4310100\">                   resizes, epoch, replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4320100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4330100\">                   flush, shutdown, running, stopReason\u27e9  \\* repaint only: histories untouched<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4340100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4350100\">Update(i, snapshot) \u225c                                  \\* speculation evolves<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4360100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4370100\">    \u2227 \u00acshutdown                                        \\* not during shutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4380100\">    \u2227 phase[i] \u2208 {\"Queued\", \"Active\"}                \\* only unfinalized blocks change<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b43900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4390100\">    \u2227 (mode[i] = \"Mutable\" \u2228 Prefix(want[i], snapshot))  \\* THE append-only contract:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4400100\">    \\* mutable blocks may replace their content arbitrarily; append-only<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4410100\">    \\* blocks may only extend it (old rows are immutable)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4420100\">    \u2227 snapshot \u2260 want[i]                               \\* no stuttering updates<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4430100\">    \u2227 want' = [want EXCEPT ![i] = snapshot]            \\* the only writer of speculation<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4440100\">    \u2227 UNCHANGED \u27e8c, phase, mode, final, emitted, alloc, target, history, native,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4450100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4460100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4470100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4480100\">                   flush, shutdown, running, stopReason\u27e9  \\* repaint only<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b44900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4490100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4500100\">RequestAllocation(newTarget) \u225c                         \\* the app asks for new slot heights<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4510100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4520100\">    \u2227 \u00acshutdown                                        \\* not during shutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4530100\">    \u2227 AllocationStateOK(alloc, newTarget, phase, final, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4540100\">    \\* admissible against the CURRENT paint: max(painted, newly-requested)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4550100\">    \\* must fit, so every later animation frame is pre-paid (dominance)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4560100\">    \u2227 newTarget \u2260 target                               \\* no stuttering requests<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4570100\">    \u2227 target' = newTarget                              \\* targets change; paint doesn't yet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4580100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, history, native,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b45900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4590100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4600100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4610100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4620100\">                   flush, shutdown, running, stopReason\u27e9  \\* nothing visible happens yet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4630100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4640100\">BridgeHeight(sampled, requested) \u225c                     \\* B(a,t): next painted height<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4650100\">    IF sampled &lt; requested THEN requested               \\* growth jumps straight to target;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4660100\">    ELSE IF sampled &gt; 2 \u2227 requested = 1 THEN 2         \\* a deep shrink (&gt;2 -&gt; 1) pauses at 2<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4670100\">    ELSE requested                                      \\* all other shrinks are direct<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4680100\">    \\* the 2-row bridge frame makes deep collapses read as contractions, not snaps<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b46900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4690100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4700100\">ApplyAllocation(i) \u225c                                   \\* one animation frame is painted<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4710100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4720100\">    \u2227 \u00acshutdown                                        \\* not during shutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4730100\">    \u2227 phase[i] = \"Active\"                              \\* only active slots animate<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4740100\">    \u2227 alloc[i] \u2260 target[i]                             \\* something to do<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4750100\">    \u2227 LET nextHeight \u225c BridgeHeight(alloc[i], target[i])  \\* bridged next height<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4760100\">           newAlloc \u225c [alloc EXCEPT ![i] = nextHeight]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4770100\">       IN \u2227 AllocationStateOK(newAlloc, target, phase, final, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4780100\">          \\* always satisfiable along a bridge: B never raises max(alloc, target)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b47900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4790100\">          \u2227 alloc' = newAlloc                          \\* paint the frame<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4800100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, target, history, native,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4810100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4820100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4830100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4840100\">                   flush, shutdown, running, stopReason\u27e9  \\* repaint only<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4850100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4860100\">FinalizeActive(i, snapshot) \u225c                          \\* a live block completes<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4870100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4880100\">    \u2227 \u00acshutdown                                        \\* not during shutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b48900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4890100\">    \u2227 phase[i] = \"Active\"                              \\* it was producing<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4900100\">    \u2227 (mode[i] = \"Mutable\" \u2228 Prefix(want[i], snapshot))  \\* final must honor the contract<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4910100\">    \u2227 LET newPhase \u225c [phase EXCEPT ![i] = \"Finalized\"]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4920100\">           newFinal \u225c [final EXCEPT ![i] = snapshot]   \\* the final value, frozen forever<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4930100\">           newAlloc \u225c CanonicalAllocation(newPhase, newFinal, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4940100\">       IN \u2227 phase' = newPhase                          \\* lifecycle advances<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4950100\">          \u2227 want' = [want EXCEPT ![i] = snapshot]      \\* want converges to final<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4960100\">          \u2227 final' = newFinal                          \\* (invariant: final = want)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4970100\">          \u2227 alloc' = newAlloc                          \\* ALL slots collapse to canonical<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4980100\">          \u2227 target' = newAlloc                         \\* 1-row previews: finished content<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b49900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b4990100\">    \u2227 UNCHANGED \u27e8c, mode, emitted, history, native, width, height,  \\* no longer animates<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5000100\">                   resizes, epoch, replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5010100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5020100\">                   flush, shutdown, running, stopReason\u27e9  \\* repaint only: nothing retires yet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5030100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5040100\">FinalizeQueued(i, snapshot) \u225c                          \\* a block completes WITHOUT ever<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5050100\">    \u2227 running                                          \\* having held a slot (finished<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5060100\">    \u2227 \u00acshutdown                                        \\* before space freed up)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5070100\">    \u2227 phase[i] = \"Queued\"                              \\* straight from the queue<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5080100\">    \u2227 (mode[i] = \"Mutable\" \u2228 Prefix(want[i], snapshot))  \\* same contract check<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b50900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5090100\">    \u2227 LET newPhase \u225c [phase EXCEPT ![i] = \"Finalized\"]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5100100\">           newWant \u225c [want EXCEPT ![i] = snapshot]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5110100\">           newFinal \u225c [final EXCEPT ![i] = snapshot]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5120100\">           newAlloc \u225c CanonicalAllocation(newPhase, newFinal, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5130100\">       IN \u2227 phase' = newPhase                          \\* note: THIS transition may cause<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5140100\">          \u2227 want' = newWant                            \\* overflow (a hidden block becomes<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5150100\">          \u2227 final' = newFinal                          \\* presented) -- summarization, not<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5160100\">          \u2227 alloc' = newAlloc                          \\* denial, handles it here<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5170100\">          \u2227 target' = newAlloc<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5180100\">    \u2227 UNCHANGED \u27e8c, mode, emitted, history, native, width, height,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b51900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5190100\">                   resizes, epoch, replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5200100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5210100\">                   flush, shutdown, running, stopReason\u27e9  \\* repaint only<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5220100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5230100\">AppendStable \u225c                                         \\* natural streaming: ONE stable row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5240100\">    \u2227 running                                          \\* of the append-only HEAD block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5250100\">    \u2227 \u00acshutdown                                        \\* scrolls into both histories<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5260100\">    \u2227 \u00acReplaying                                       \\* never interleaves with replay<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5270100\">    \u2227 c &lt; CreatedCount                                 \\* a head block exists<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5280100\">    \u2227 mode[c + 1] = \"AppendOnly\"                       \\* only append-only blocks stream<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b52900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5290100\">    \u2227 phase[c + 1] \u2208 {\"Active\", \"Finalized\"}         \\* and only while live<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5300100\">    \u2227 RowPressure                                      \\* only under ROW pressure: with<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5310100\">    \\* room to spare, stable rows stay in the viewport (still repositionable)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5320100\">    \u2227 emitted[c + 1] &lt; Len(want[c + 1])                \\* a stable row remains to stream<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5330100\">    \u2227 LET next \u225c emitted[c + 1] + 1                   \\* index of the row to emit<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5340100\">           newEmitted \u225c [emitted EXCEPT ![c + 1] = next]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5350100\">           newAlloc \u225c CanonicalAllocation(phase, final, newEmitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5360100\">       IN \u2227 history' = history \u2218 TagSlice(c + 1, want[c + 1], next, next)  \\* ledger += 1 semantic row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5370100\">          \u2227 native' =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5380100\">                 native<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b53900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5390100\">                 \u2218 NativeTagSlice(\"Append\", c + 1, want[c + 1], next, next, width)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5400100\">          \\* native += the same row, rendered (1 or 2 physical rows), tagged Append<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5410100\">          \u2227 emitted' = newEmitted                      \\* the stable frontier advances<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5420100\">          \u2227 alloc' = newAlloc                          \\* layout recanonicalizes (the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5430100\">          \u2227 target' = newAlloc                         \\* streamed row left the viewport)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5440100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5450100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5460100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5470100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5480100\">                   flush, shutdown, running, stopReason\u27e9  \\* frontier c itself does not move<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b54900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5490100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5500100\">CompleteAppendOnly \u225c                                   \\* the fully-streamed head commits<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5510100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5520100\">    \\* (deliberately NO ~shutdown: draining the head stays possible while<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5530100\">    \\*  shutting down)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5540100\">    \u2227 \u00acReplaying                                       \\* never during replay<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5550100\">    \u2227 c &lt; CreatedCount                                 \\* head exists<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5560100\">    \u2227 mode[c + 1] = \"AppendOnly\"                       \\* head is append-only<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5570100\">    \u2227 phase[c + 1] = \"Finalized\"                       \\* head is done<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5580100\">    \u2227 emitted[c + 1] = Len(final[c + 1])               \\* every row already streamed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b55900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5590100\">    \u2227 LET newPhase \u225c [phase EXCEPT ![c + 1] = \"Committed\"]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5600100\">           newEmitted \u225c [emitted EXCEPT ![c + 1] = 0]  \\* emitted counter retires with it<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5610100\">           newAlloc \u225c CanonicalAllocation(newPhase, final, newEmitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5620100\">       IN \u2227 c' = c + 1                                 \\* frontier advances: PURE<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5630100\">          \u2227 phase' = newPhase                          \\* bookkeeping -- every row is<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5640100\">          \u2227 emitted' = newEmitted                      \\* already in both histories,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5650100\">          \u2227 alloc' = newAlloc                          \\* so nothing is written<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5660100\">          \u2227 target' = newAlloc<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5670100\">    \u2227 UNCHANGED \u27e8mode, want, final, history, native, width, height,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5680100\">                   resizes, epoch, replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b56900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5690100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5700100\">                   flush, shutdown, running, stopReason\u27e9  \\* note: history unchanged!<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5710100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5720100\">BeginFlush \u225c                                           \\* someone asks for full retirement<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5730100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5740100\">    \u2227 \u00acflush                                           \\* idempotent: set once,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5750100\">    \u2227 flush' = TRUE                                    \\* never reset<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5760100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, target,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5770100\">                   history, native, width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5780100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b57900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5790100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5800100\">                   shutdown, running, stopReason\u27e9      \\* a pure request: no effect yet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5810100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5820100\">RetireSuccess(batchEnd) \u225c                              \\* in-order retirement of a batch<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5830100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5840100\">    \u2227 \u00acReplaying                                       \\* never during replay<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5850100\">    \u2227 batchEnd \u2208 (c + 1)\u2025N                          \\* batch = blocks c+1 .. batchEnd<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5860100\">    \u2227 FinalizedRange(c + 1, batchEnd)                  \\* ... ALL of them finalized<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5870100\">    \u2227 RetirementRequested                              \\* only under flush or pressure<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5880100\">    \u2227 history' =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b58900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5890100\">           history \u2218 RetirementRows(c + 1, batchEnd, final, emitted[c + 1])<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5900100\">    \\* ledger += head's unstreamed suffix, then later finals in full<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5910100\">    \\* (emitted[c+1] is the only possibly-nonzero emitted counter)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5920100\">    \u2227 native' =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5930100\">           native<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5940100\">           \u2218 NativeRetirementRows(                     \\* native += the same rows,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5950100\">                  \"Retire\",                             \\* tagged Retire, rendered at<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5960100\">                  c + 1,                                \\* the current width; realized<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5970100\">                  batchEnd,                             \\* on a real terminal as ONE<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5980100\">                  final,                                \\* streamed write (paper,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b59900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b5990100\">                  emitted[c + 1],                       \\* Lemma \"streaming<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6000100\">                  width                                 \\* realization\")<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6010100\">              )<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6020100\">    \u2227 LET newPhase \u225c [i \u2208 Blocks \u21a6<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6030100\">                            IF i \u2264 batchEnd THEN \"Committed\" ELSE phase[i]]  \\* batch commits<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6040100\">           newEmitted \u225c [i \u2208 Blocks \u21a6<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6050100\">                              IF i \u2264 batchEnd THEN 0 ELSE emitted[i]]  \\* counters reset<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6060100\">           newAlloc \u225c CanonicalAllocation(newPhase, final, newEmitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6070100\">       IN \u2227 c' = batchEnd                              \\* frontier jumps to batch end<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6080100\">          \u2227 phase' = newPhase<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b60900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6090100\">          \u2227 emitted' = newEmitted<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6100100\">          \u2227 alloc' = newAlloc                          \\* retired slots disappear;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6110100\">          \u2227 target' = newAlloc                         \\* survivors recanonicalize<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6120100\">    \u2227 UNCHANGED \u27e8mode, want, final, width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6130100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6140100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6150100\">                   flush, shutdown, running, stopReason\u27e9  \\* finals themselves are untouched<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6160100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6170100\">RetireFailure(batchEnd, count) \u225c                       \\* the SAME write, torn partway:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6180100\">    \u2227 running                                          \\* same enabling conditions<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b61900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6190100\">    \u2227 \u00acReplaying                                       \\* as RetireSuccess ...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6200100\">    \u2227 batchEnd \u2208 (c + 1)\u2025N<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6210100\">    \u2227 FinalizedRange(c + 1, batchEnd)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6220100\">    \u2227 RetirementRequested<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6230100\">    \u2227 LET rows \u225c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6240100\">              NativeRetirementRows(                     \\* the batch that WOULD have<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6250100\">                  \"FailedWrite\",                        \\* been written, tagged<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6260100\">                  c + 1,                                \\* FailedWrite for forensics<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6270100\">                  batchEnd,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6280100\">                  final,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b62900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6290100\">                  emitted[c + 1],<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6300100\">                  width<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6310100\">              )<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6320100\">       IN \u2227 count \u2208 0\u2025Len(rows)                     \\* the terminal accepted `count`<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6330100\">          \u2227 native' = native \u2218 PrefixOf(rows, count)  \\* rows: an arbitrary PREFIX --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6340100\">          \\* never reordered, never a row from outside the batch<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6350100\">    \u2227 running' = FALSE                                 \\* fail-stop: the host halts;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6360100\">    \u2227 stopReason' = \"WriteFailure\"                     \\* no retry path exists, so<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6370100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, target, history,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6380100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b63900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6390100\">                   replayMode, replayCursor, replayEnd, replayPartial, replayPrepared, replayCut, flush, shutdown\u27e9<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6400100\">    \\* CRITICAL: c and history do NOT advance -- the ledger never lies about<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6410100\">    \\* what committed, so duplication\/reordering after failure is impossible<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6420100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6430100\">Resize(newWidth, newHeight, resizePolicy, pushed) \u225c    \\* terminal geometry changes<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6440100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6450100\">    \u2227 \u00acshutdown                                        \\* not during shutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6460100\">    \u2227 resizes &lt; MaxResizes                             \\* bounded (finite model)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6470100\">    \u2227 newWidth \u2208 WidthValues                         \\* new geometry and the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6480100\">    \u2227 newHeight \u2208 0\u2025H                               \\* policy for native history<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b64900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6490100\">    \u2227 resizePolicy \u2208 ResizeModes<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6500100\">    \u2227 newWidth \u2260 width \u2228 newHeight \u2260 height           \\* an actual change<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6510100\">    \u2227 pushed \u2208 0\u2025Len(Screen)                        \\* emulator may scroll 0..h top<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6520100\">    \\* viewport rows into scrollback during the resize (e.g. height shrink)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6530100\">    \u2227 LET widthChanged \u225c newWidth \u2260 width<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6540100\">           effectiveMode \u225c IF widthChanged THEN resizePolicy ELSE \"Preserve\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6550100\">           \\* height-only resizes never replay: rendered rows are still valid<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6560100\">           pushedRows \u225c NativeCells(\"Resize\", PrefixOf(Screen, pushed), width)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6570100\">           \\* rows pushed by the emulator, tagged Resize, at the OLD width<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6580100\">           beginReplay \u225c effectiveMode \u2260 \"Preserve\" \u2227 (c &gt; 0 \u2228 PartialHeadExists)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b65900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6590100\">           \\* replay only if there is committed\/streamed content to re-render<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6600100\">           newPhase \u225c phase                            \\* lifecycle is untouched<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6610100\">           newAlloc \u225c CanonicalAllocation(newPhase, final, emitted, newWidth, newHeight)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6620100\">       IN \u2227 width' = newWidth                          \\* adopt the new geometry<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6630100\">          \u2227 height' = newHeight<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6640100\">          \u2227 resizes' = resizes + 1                     \\* burn one resize budget<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6650100\">          \u2227 alloc' = newAlloc                          \\* layout recanonicalizes at<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6660100\">          \u2227 target' = newAlloc                         \\* the new geometry<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6670100\">          \u2227 native' = IF effectiveMode = \"Rebuild\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6680100\">                        THEN \u27e8\u27e9                       \\* Rebuild: native display is wiped ...<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b66900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6690100\">                        ELSE native \u2218 pushedRows       \\* else: record what the emulator pushed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6700100\">          \u2227 epoch' = IF effectiveMode = \"Rebuild\" THEN epoch + 1 ELSE epoch<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6710100\">          \\* ... and the display epoch increments (native monotonicity is epoch-scoped)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6720100\">          \u2227 replayMode' =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6730100\">                 IF beginReplay THEN effectiveMode      \\* start a replay,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6740100\">                 ELSE IF Replaying THEN replayMode ELSE \"None\"  \\* or keep\/clear the old one<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6750100\">          \u2227 replayCursor' =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6760100\">                 IF beginReplay THEN 1                  \\* replay window = committed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6770100\">                 ELSE IF Replaying THEN replayCursor ELSE 0     \\* blocks 1..c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6780100\">          \u2227 replayEnd' =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b67900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6790100\">                 IF beginReplay THEN c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6800100\">                 ELSE IF Replaying THEN replayEnd ELSE 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6810100\">          \u2227 replayPartial' =<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6820100\">                 IF beginReplay<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6830100\">                 THEN IF PartialHeadExists THEN emitted[c + 1] ELSE 0  \\* plus the streamed head prefix<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6840100\">                 ELSE IF Replaying THEN replayPartial ELSE 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6850100\">          \u2227 replayPrepared' = FALSE                    \\* ANY resize invalidates a<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6860100\">          \u2227 replayCut' = 0                             \\* previously prepared frame<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6870100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, history,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6880100\">                   flush, shutdown, running, stopReason\u27e9<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b68900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6890100\">    \\* resize logical-neutrality: ledger, frontier, and semantics never move<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6900100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6910100\">PrepareReplay \u225c                                        \\* compute the replay frame<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6920100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6930100\">    \u2227 Replaying                                        \\* a replay is pending<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6940100\">    \u2227 \u00acreplayPrepared                                  \\* and not yet prepared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6950100\">    \u2227 replayPrepared' = TRUE                           \\* freeze the frame NOW:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6960100\">    \u2227 replayCut' = RequiredReplayCut                   \\* cut = rows that must scroll<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6970100\">    \\* from here the scheduler gate (see Next) admits ONLY the two replay<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6980100\">    \\* writes, so the sampled cut cannot be invalidated by interleaving<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b69900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b6990100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, target,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7000100\">                   history, native, width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7010100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7020100\">                   flush, shutdown, running, stopReason\u27e9  \\* pure computation: no write yet<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7030100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7040100\">ReplaySynchronousSuccess \u225c                             \\* the single buffered write lands<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7050100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7060100\">    \u2227 Replaying                                        \\* replay pending<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7070100\">    \u2227 replayPrepared                                   \\* frame prepared (gate open)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7080100\">    \u2227 native' = native \u2218 PrefixOf(ReplayRows, replayCut)  \\* exactly `cut` rows scroll into<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b70900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7090100\">    \\* native; the tail was painted into blank rows (no scroll, no history)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7100100\">    \u2227 replayMode' = \"None\"                             \\* replay fully drains:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7110100\">    \u2227 replayCursor' = 0                                \\* all replay state returns<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7120100\">    \u2227 replayEnd' = 0                                   \\* to its idle shape<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7130100\">    \u2227 replayPartial' = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7140100\">    \u2227 replayPrepared' = FALSE<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7150100\">    \u2227 replayCut' = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7160100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, target,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7170100\">                   history, width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7180100\">                   flush, shutdown, running, stopReason\u27e9  \\* logically neutral: ledger untouched<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b71900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7190100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7200100\">ReplaySynchronousFailure(count) \u225c                      \\* the same write, torn partway<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7210100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7220100\">    \u2227 Replaying                                        \\* replay pending<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7230100\">    \u2227 replayPrepared                                   \\* frame prepared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7240100\">    \u2227 count \u2208 0\u2025replayCut                           \\* an arbitrary prefix of the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7250100\">    \u2227 native' = native \u2218 PrefixOf(ReplayRows, count)  \\* scrolled portion landed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7260100\">    \u2227 running' = FALSE                                 \\* fail-stop, as with<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7270100\">    \u2227 stopReason' = \"WriteFailure\"                     \\* RetireFailure: halt, no retry<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7280100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, target, history,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b72900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7290100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7300100\">                   replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7310100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7320100\">                   flush, shutdown\u27e9                    \\* ledger and frontier still truthful<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7330100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7340100\">BeginGracefulShutdown \u225c                                \\* wind-down begins<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7350100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7360100\">    \u2227 \u00acshutdown                                        \\* only once<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7370100\">    \u2227 LET newPhase \u225c [i \u2208 Blocks \u21a6<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7380100\">                            IF phase[i] = \"Absent\" THEN \"Absent\"     \\* never-created stay absent;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b73900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7390100\">                            ELSE IF i \u2264 c THEN \"Committed\" ELSE \"Finalized\"]  \\* all live work freezes<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7400100\">           newFinal \u225c [i \u2208 Blocks \u21a6<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7410100\">                            IF phase[i] = \"Absent\" THEN NoFinal      \\* absent: still no final;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7420100\">                            ELSE IF i \u2264 c \u2228 phase[i] = \"Finalized\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7430100\">                            THEN final[i]               \\* already-frozen finals kept;<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7440100\">                            ELSE want[i]]               \\* queued\/active freeze AT their<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7450100\">           newAlloc \u225c CanonicalAllocation(newPhase, newFinal, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7460100\">       IN \u2227 phase' = newPhase                          \\* current speculation (f := w)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7470100\">          \u2227 final' = newFinal<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7480100\">          \u2227 alloc' = newAlloc                          \\* layout collapses to canonical<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b74900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7490100\">          \u2227 target' = newAlloc<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7500100\">    \u2227 flush' = TRUE                                    \\* permanent flush: everything<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7510100\">    \u2227 shutdown' = TRUE                                 \\* must drain, then exit<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7520100\">    \u2227 UNCHANGED \u27e8c, mode, want, emitted, history, native, width, height,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7530100\">                   resizes, epoch, replayMode, replayCursor, replayEnd, replayPartial,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7540100\">                   replayPrepared, replayCut,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7550100\">                   running, stopReason\u27e9                \\* nothing retires in this step itself<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7560100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7570100\">GracefulExit(push) \u225c                                   \\* clean exit after full drain<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7580100\">    \u2227 running                                          \\* host alive<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b75900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7590100\">    \u2227 shutdown                                         \\* shutdown was initiated,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7600100\">    \u2227 \u00acReplaying                                       \\* replay has drained,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7610100\">    \u2227 c = CreatedCount                                 \\* and EVERY block committed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7620100\">    \u2227 push \u2208 0\u20251                                    \\* optionally scroll one last row<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7630100\">    \u2227 push = 0 \u2228 height &gt; 0                           \\* (only if a viewport row exists)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7640100\">    \u2227 running' = FALSE                                 \\* host stops<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7650100\">    \u2227 stopReason' = \"Graceful\"                         \\* ... cleanly<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7660100\">    \u2227 native' = IF push = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7670100\">                 THEN native                            \\* either no final scroll, or the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7680100\">                 ELSE native \u2218 NativeCells(\"Exit\", \u27e8Screen[1]\u27e9, width)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b76900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7690100\">                 \\* top viewport row scrolls out (restoring the shell prompt),<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7700100\">                 \\* tagged Exit<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7710100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, target, history,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7720100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7730100\">                   replayMode, replayCursor, replayEnd, replayPartial, replayPrepared, replayCut, flush, shutdown\u27e9<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7740100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7750100\">DetachExit(push) \u225c                                     \\* abandon ship: exit NOW,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7760100\">    \u2227 running                                          \\* uncommitted work is dropped<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7770100\">    \u2227 \u00acshutdown                                        \\* (a detach, not a shutdown)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7780100\">    \u2227 push \u2208 0\u20251                                    \\* same optional final scroll<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b77900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7790100\">    \u2227 push = 0 \u2228 height &gt; 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7800100\">    \u2227 running' = FALSE                                 \\* host stops<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7810100\">    \u2227 stopReason' = \"Detach\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7820100\">    \u2227 native' = IF push = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7830100\">                 THEN native<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7840100\">                 ELSE native \u2218 NativeCells(\"Exit\", \u27e8Screen[1]\u27e9, width)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7850100\">    \u2227 UNCHANGED \u27e8c, phase, mode, want, final, emitted, alloc, target, history,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7860100\">                   width, height, resizes, epoch,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7870100\">                   replayMode, replayCursor, replayEnd, replayPartial, replayPrepared, replayCut, flush, shutdown\u27e9<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7880100\">    \\* ECH guarantees `history` holds exactly the committed content at detach<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b78900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7890100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7900100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7910100\">\\* Existentially closed action wrappers (for fairness and Next).<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7920100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7930100\">RetireSuccessAction \u225c \u2203 batchEnd \u2208 Blocks : RetireSuccess(batchEnd)  \\* some batch retires<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7940100\">RetireFailureAction \u225c                                  \\* some batch write fails at<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7950100\">    \u2203 batchEnd \u2208 Blocks :                            \\* some prefix length<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7960100\">        \u2203 count \u2208 0\u2025MaxFailureRows : RetireFailure(batchEnd, count)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7970100\">ReplaySynchronousFailureAction \u225c                       \\* replay write fails at some<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7980100\">    \u2203 count \u2208 0\u2025MaxFailureRows : ReplaySynchronousFailure(count)  \\* prefix length<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b79900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b7990100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8000100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8010100\">\\* The scheduler gate: once a replay frame is prepared, the ONLY possible<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8020100\">\\* steps are the replay write landing or failing. This is what the word<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8030100\">\\* \"synchronous\" means, and it is what keeps replayCut = RequiredReplayCut<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8040100\">\\* stable (nothing may repaint in between).<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8050100\">\\* -------------------------------------------------------------------------<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8060100\">Next \u225c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8070100\">    IF replayPrepared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8080100\">    THEN ReplaySynchronousSuccess \u2228 ReplaySynchronousFailureAction  \\* gate closed: write or die<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b80900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8090100\">    ELSE \u2228 \u2203 declaration \u2208 {\"Mutable\", \"AppendOnly\"} : Create(declaration)  \\* gate open:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8100100\">         \u2228 \u2203 i \u2208 Blocks : Admit(i)                                          \\* any protocol<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8110100\">         \u2228 \u2203 i \u2208 Blocks, snapshot \u2208 SnapshotValues : Update(i, snapshot)  \\* step may fire<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8120100\">         \u2228 \u2203 newTarget \u2208 [Blocks \u2192 0\u2025H] : RequestAllocation(newTarget)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8130100\">         \u2228 \u2203 i \u2208 Blocks : ApplyAllocation(i)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8140100\">         \u2228 \u2203 i \u2208 Blocks, snapshot \u2208 SnapshotValues : FinalizeActive(i, snapshot)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8150100\">         \u2228 \u2203 i \u2208 Blocks, snapshot \u2208 SnapshotValues : FinalizeQueued(i, snapshot)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8160100\">         \u2228 AppendStable<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8170100\">         \u2228 CompleteAppendOnly<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8180100\">         \u2228 BeginFlush<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b81900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8190100\">         \u2228 RetireSuccessAction<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8200100\">         \u2228 RetireFailureAction<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8210100\">         \u2228 \u2203 newWidth \u2208 WidthValues, newHeight \u2208 0\u2025H,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8220100\">               resizePolicy \u2208 ResizeModes, pushed \u2208 0\u2025H :<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8230100\">                Resize(newWidth, newHeight, resizePolicy, pushed)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8240100\">         \u2228 PrepareReplay<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8250100\">         \u2228 BeginGracefulShutdown<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8260100\">         \u2228 \u2203 push \u2208 0\u20251 : GracefulExit(push)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8270100\">         \u2228 \u2203 push \u2208 0\u20251 : DetachExit(push)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8280100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b82900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8290100\">Spec \u225c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8300100\">    \u2227 Init                                             \\* start in the initial state,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8310100\">    \u2227 \u25a1[Next]_vars                                    \\* take Next steps (or stutter),<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8320100\">    \u2227 WF_vars(RetireSuccessAction)                     \\* and don't ignore forever:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8330100\">    \u2227 WF_vars(PrepareReplay)                           \\* retirement, replay preparation,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8340100\">    \u2227 WF_vars(ReplaySynchronousSuccess)                \\* the replay write,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8350100\">    \u2227 WF_vars(AppendStable)                            \\* head streaming,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8360100\">    \u2227 WF_vars(CompleteAppendOnly)                      \\* and head commitment.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8370100\">    \\* Weak fairness: an action enabled forever is eventually taken. Failures<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8380100\">    \\* and exits are NOT fair -- they may happen, but are never forced.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b83900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8390100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8400100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8410100\">\\* Invariants (checked by TLC in every reachable state).<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8420100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8430100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8440100\">TypeOK \u225c                                               \\* T: every variable in range<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8450100\">    \u2227 c \u2208 0\u2025N                                       \\* frontier within block ids<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8460100\">    \u2227 phase \u2208 [Blocks \u2192 Phases]                     \\* valid phase per block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8470100\">    \u2227 mode \u2208 [Blocks \u2192 BlockModes]                  \\* valid mode per block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8480100\">    \u2227 want \u2208 [Blocks \u2192 SnapshotValues]              \\* speculation from the universe<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b84900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8490100\">    \u2227 final \u2208 [Blocks \u2192 SnapshotValues \u222a {NoFinal}]  \\* final or the sentinel<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8500100\">    \u2227 emitted \u2208 [Blocks \u2192 0\u2025MaxSnapshotLength]     \\* emitted counter bounded<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8510100\">    \u2227 alloc \u2208 [Blocks \u2192 0\u2025H]                       \\* painted heights bounded<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8520100\">    \u2227 target \u2208 [Blocks \u2192 0\u2025H]                      \\* requested heights bounded<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8530100\">    \u2227 history \u2208 Seq(TaggedRows)                      \\* ledger rows well-formed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8540100\">    \u2227 native \u2208 Seq(NativeRows)                       \\* native rows well-formed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8550100\">    \u2227 width \u2208 WidthValues                            \\* geometry in range<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8560100\">    \u2227 height \u2208 0\u2025H<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8570100\">    \u2227 resizes \u2208 0\u2025MaxResizes                        \\* resize budget respected<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8580100\">    \u2227 epoch \u2208 0\u2025MaxResizes                          \\* epochs only at resizes<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b85900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8590100\">    \u2227 replayMode \u2208 ReplayModes                       \\* replay state in range<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8600100\">    \u2227 replayCursor \u2208 0\u2025(N + 1)                      \\* (loose bound; really 0 or 1)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8610100\">    \u2227 replayEnd \u2208 0\u2025N<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8620100\">    \u2227 replayPartial \u2208 0\u2025MaxSnapshotLength<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8630100\">    \u2227 replayPrepared \u2208 BOOLEAN<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8640100\">    \u2227 replayCut \u2208 0\u2025MaxFailureRows                  \\* cut bounded by max batch size<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8650100\">    \u2227 flush \u2208 BOOLEAN<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8660100\">    \u2227 shutdown \u2208 BOOLEAN<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8670100\">    \u2227 running \u2208 BOOLEAN<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8680100\">    \u2227 stopReason \u2208 StopReasons<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b86900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8690100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8700100\">LifecycleShape \u225c                                       \\* LS: blocks form three bands --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8710100\">    \u2227 c \u2264 CreatedCount                                \\* can't commit the uncreated<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8720100\">    \u2227 \u2200 i \u2208 1\u2025c :                                  \\* band 1: 1..c<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8730100\">           \u2227 phase[i] = \"Committed\"                    \\* all committed,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8740100\">           \u2227 mode[i] \u2208 {\"Mutable\", \"AppendOnly\"}     \\* with a declared mode<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8750100\">    \u2227 \u2200 i \u2208 (c + 1)\u2025CreatedCount :                 \\* band 2: live blocks<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8760100\">           \u2227 phase[i] \u2208 {\"Queued\", \"Active\", \"Finalized\"}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8770100\">           \u2227 mode[i] \u2208 {\"Mutable\", \"AppendOnly\"}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8780100\">    \u2227 \u2200 i \u2208 (CreatedCount + 1)\u2025N :                 \\* band 3: not yet created<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b87900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8790100\">           \u2227 phase[i] = \"Absent\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8800100\">           \u2227 mode[i] = \"Undeclared\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8810100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8820100\">SnapshotDiscipline \u225c                                   \\* SD: finals exist exactly for<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8830100\">    \u2200 i \u2208 Blocks :                                   \\* finalized\/committed blocks,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8840100\">        IF phase[i] \u2208 {\"Finalized\", \"Committed\"}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8850100\">        THEN \u2227 final[i] \u2208 SnapshotValues             \\* are real snapshots,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8860100\">             \u2227 final[i] = want[i]                      \\* and equal the last speculation<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8870100\">        ELSE final[i] = NoFinal                         \\* everyone else: the sentinel<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8880100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b88900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8890100\">EmissionDiscipline \u225c                                   \\* ED: streaming is head-only --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8900100\">    \u2227 \u2200 i \u2208 Blocks :<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8910100\">           \u2227 emitted[i] \u2264 Len(want[i])                \\* never emitted more than exists<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8920100\">           \u2227 (mode[i] \u2260 \"AppendOnly\" \u21d2 emitted[i] = 0)  \\* mutable blocks never stream<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8930100\">           \u2227 (emitted[i] &gt; 0 \u21d2<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8940100\">                  \u2227 i = c + 1                          \\* only the HEAD may have<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8950100\">                  \u2227 phase[i] \u2208 {\"Active\", \"Finalized\"})  \\* streamed rows, and only live<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8960100\">    \u2227 (PartialHeadExists \u21d2 emitted[c + 1] \u2264 Len(want[c + 1]))  \\* (redundant safety belt)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8970100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8980100\">Capacity \u225c AllocationStateOK(alloc, target, phase, final, emitted, width, height)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b89900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b8990100\">\\* CAP: the reservation invariant holds of the ACTUAL alloc\/target at all times<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9000100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9010100\">ExactCommittedHistory \u225c history = CommittedRows(c, final) \u2218 PartialHeadRows<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9020100\">\\* ECH, the central equation: the ledger IS the committed finals in block<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9030100\">\\* order, plus the head's streamed prefix -- no dupes, no gaps, no reorders<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9040100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9050100\">NoPrematureHistory \u225c                                   \\* every ledger row is owned by<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9060100\">    \u2200 j \u2208 1\u2025Len(history) :<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9070100\">        LET owner \u225c history[j].owner IN<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9080100\">        \u2228 \u2227 owner \u2208 1\u2025c                            \\* a committed block, or<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b90900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9090100\">         \u2227 phase[owner] = \"Committed\"<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9100100\">        \u2228 \u2227 PartialHeadExists                         \\* the streaming head --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9110100\">         \u2227 owner = c + 1                              \\* speculation NEVER leaks<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9120100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9130100\">ScreenCapacity \u225c                                       \\* the screen is exactly right:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9140100\">    \u2227 Screen \u2208 Seq(Cells)                            \\* well-formed cells,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9150100\">    \u2227 Len(Screen) = height                             \\* exactly `height` of them,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9160100\">    \u2227 \u2200 i \u2208 Blocks :<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9170100\">           Cardinality({j \u2208 1\u2025height : Screen[j].owner = i}) = alloc[i]  \\* each block owns alloc[i] rows,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9180100\">    \u2227 Cardinality({j \u2208 1\u2025height : Screen[j] = OverflowCell})<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b91900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9190100\">       = SummaryRows(phase, final, emitted, width, height)  \\* the summary row appears iff overflowing,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9200100\">    \u2227 Cardinality({j \u2208 1\u2025height : Screen[j] = BlankCell})<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9210100\">       = height - AllocationTotal(alloc, 1)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9220100\">         - SummaryRows(phase, final, emitted, width, height)  \\* the rest is blank -- accounts balance<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9230100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9240100\">ReplayShape \u225c                                          \\* RS: replay bookkeeping is sane<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9250100\">    \u2227 (replayMode = \"None\" \u21d2                          \\* idle: all replay state zeroed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9260100\">           \u2227 replayCursor = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9270100\">           \u2227 replayEnd = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9280100\">                     \u2227 replayPartial = 0<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b92900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9290100\">          \u2227 \u00acreplayPrepared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9300100\">          \u2227 replayCut = 0)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9310100\">    \u2227 (replayMode \u2260 \"None\" \u21d2                          \\* in flight: window is 1..replayEnd<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9320100\">                     \u2227 replayCursor = 1<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9330100\">           \u2227 replayEnd \u2208 0\u2025c                        \\* over COMMITTED blocks only,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9340100\">                     \u2227 replayPartial \u2264 MaxSnapshotLength<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9350100\">          \u2227 IF replayPrepared<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9360100\">             THEN \u2227 replayCut = RequiredReplayCut      \\* prepared: the sampled cut is<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9370100\">                  \u2227 Len(PreparedReplayTail) \u2264 ReplayRoom  \\* still exact (the gate!) and<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9380100\">             ELSE replayCut = 0)                        \\* the tail fits the blank region<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b93900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9390100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9400100\">NativeSourceSafety \u225c                                   \\* NSS: provenance never lies --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9410100\">    \u2200 j \u2208 1\u2025Len(native) :<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9420100\">        LET owner \u225c native[j].owner IN<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9430100\">        \u2227 (native[j].source = \"Retire\" \u21d2              \\* Retire rows: from blocks that<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9440100\">               \u2227 owner \u2208 1\u2025c                        \\* really are committed<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9450100\">               \u2227 phase[owner] = \"Committed\")<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9460100\">        \u2227 (native[j].source \u2208 {\"Append\", \"Replay\"} \u21d2  \\* streamed\/replayed rows: from<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9470100\">               \u2227 owner \u2208 Blocks                        \\* committed blocks or the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9480100\">               \u2227 (\u2228 owner \u2208 1\u2025c                      \\* append-only head -- never<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b94900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9490100\">                  \u2228 \u2227 owner = c + 1                    \\* from mutable speculation<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9500100\">                    \u2227 mode[owner] = \"AppendOnly\"))<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9510100\">        \u2227 (native[j].source = \"FailedWrite\" \u21d2 stopReason = \"WriteFailure\")  \\* failure rows only after failing<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9520100\">        \u2227 (native[j].source = \"Exit\" \u21d2 \u00acrunning)      \\* exit rows only after exiting<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9530100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9540100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9550100\">\\* Temporal (action and liveness) properties.<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9560100\">\\* =========================================================================<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9570100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9580100\">HistoryExtension \u225c Prefix(history, history')           \\* one step never rewrites the ledger<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b95900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9590100\">HistoryMonotonicity \u225c \u25a1[HistoryExtension]_vars        \\* ... in ANY step: append-only forever<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9600100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9610100\">NativeEpochStep \u225c                                      \\* per step, native either<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9620100\">    IF epoch' = epoch<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9630100\">    THEN Prefix(native, native')                        \\* grows at the end (same epoch)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9640100\">    ELSE \u2227 epoch' = epoch + 1                          \\* or is wiped exactly when the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9650100\">         \u2227 native' = \u27e8\u27e9                              \\* epoch increments (Rebuild)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9660100\">NativeEpochDiscipline \u225c \u25a1[NativeEpochStep]_vars       \\* holds of every step<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9670100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9680100\">FinalsStayFixed \u225c                                      \\* finals are immutable:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b96900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9690100\">    \u2200 i \u2208 Blocks :<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9700100\">        phase[i] \u2208 {\"Finalized\", \"Committed\"} \u21d2 final'[i] = final[i]<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9710100\">FinalImmutability \u225c \u25a1[FinalsStayFixed]_vars           \\* once frozen, frozen forever<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9720100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9730100\">AppendOnlyPrefixStep \u225c                                 \\* the append-only contract as<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9740100\">    \u2200 i \u2208 Blocks :                                   \\* an action property:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9750100\">        (mode[i] = \"AppendOnly\" \u2227 phase[i] \u2208 {\"Queued\", \"Active\"})<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9760100\">        \u21d2 Prefix(want[i], want'[i])                    \\* want only ever extends<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9770100\">AppendOnlyMonotonicity \u225c \u25a1[AppendOnlyPrefixStep]_vars<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9780100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b97900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9790100\">ResizeKeepsLogicalHistoryStep \u225c                        \\* resize logical-neutrality:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9800100\">    (width' \u2260 width \u2228 height' \u2260 height) \u21d2             \\* a geometry change moves<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9810100\">        \u2227 history' = history                           \\* NONE of the semantic state --<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9820100\">        \u2227 c' = c                                       \\* not the ledger, not the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9830100\">        \u2227 mode' = mode                                 \\* frontier, not modes,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9840100\">        \u2227 want' = want                                 \\* speculation,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9850100\">        \u2227 final' = final                               \\* finals,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9860100\">        \u2227 emitted' = emitted                           \\* or streamed counters<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9870100\">ResizeKeepsLogicalHistory \u225c \u25a1[ResizeKeepsLogicalHistoryStep]_vars<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9880100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b98900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9890100\">FailedWriteStops \u225c \u25a1(                                 \\* fail-stop: a write failure<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9900100\">    stopReason = \"WriteFailure\" \u21d2 \u00acrunning             \\* and a live host never coexist<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9910100\">)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9920100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9930100\">StoppedStep \u225c \u00acrunning \u21d2 UNCHANGED vars               \\* a stopped host is frozen:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9940100\">StoppedQuiescence \u225c \u25a1[StoppedStep]_vars               \\* every later step stutters<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9950100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9960100\">AllFinalized \u225c                                         \\* every created block is done<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9970100\">    \u2200 i \u2208 1\u2025CreatedCount : phase[i] \u2208 {\"Finalized\", \"Committed\"}<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9980100\">AllCommitted \u225c                                         \\* everything retired, and the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010b99900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010b9990100\">    \u2227 c = CreatedCount                                 \\* ledger is exactly the<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10000100\">    \u2227 history = CommittedRows(c, final)                \\* committed finals<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10010100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10020100\">FlushLiveness \u225c                                        \\* drain guarantee: finalized +<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10030100\">    (AllFinalized \u2227 flush \u2227 shutdown \u2227 running \u2227 \u00acReplaying)  \\* flushing + shutting down<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10040100\">    \u219d (AllCommitted \u2228 \u00acrunning)                       \\* eventually fully commits (or halts)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10050100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10060100\">ReplayLiveness \u225c (Replaying \u2227 running) \u219d (\u00acReplaying \u2228 \u00acrunning)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10070100\">\\* every replay eventually drains (or the host halts trying)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10080100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010c100900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10090100\">QueuedDemand \u225c \u2203 i \u2208 Blocks : phase[i] = \"Queued\"   \\* someone is waiting for space<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10100100\">QueuedPressureRetirement \u225c                             \\* pressure + queued demand<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10110100\">    \u2200 i \u2208 Blocks :                                   \\* eventually sweeps a finalized<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10120100\">        (\u2227 running                                     \\* head block into history:<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10130100\">         \u2227 \u00acReplaying<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101400\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10140100\">         \u2227 c = i - 1                                   \\* i is the head,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101500\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10150100\">         \u2227 phase[i] = \"Finalized\"                      \\* it is done,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101600\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10160100\">         \u2227 Pressure                                    \\* space is scarce,<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101700\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10170100\">         \u2227 QueuedDemand)                               \\* and someone needs it<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101800\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10180100\">        \u219d (c \u2265 i \u2228 \u00acrunning)                         \\* =&gt; i eventually commits (or halt)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c101900\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10190100\">    \\* NB: this needs MaxLive small enough that queued demand implies<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c102000\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10200100\">    \\* PERSISTENT count pressure; pure row pressure alone can evaporate<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c102100\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10210100\">    \\* (see the paper's sharpness remark)<\/span><\/span>\n<span data-hk=\"000000010000000000004000010b522010c102200\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10220100\"\/><\/span>\n<span data-hk=\"000000010000000000004000010b522010c102300\" class=\"line \"><span data-hk=\"000000010000000000004000010b522010c10230100\">====<\/span><\/span><\/code><\/pre>\n<p><!--\/--><\/details>\n<\/div>\n<p><a href=\"https:\/\/stencil.so\/blog\/harness-playbook?utm_source=tldrai\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before anything else: a thank you. Hundreds of thousands of you have used omp, reported what broke, suggested what was missing, and shaped what it became. This post and omp\u00b2 itself exist because of you. Upon hearing about omp\u00b2, many of you jumped to ask, &#8220;but why?&#8221; A while loop around a fetch sounds simple, [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":23703,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[143],"tags":[],"class_list":["post-23702","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/posts\/23702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/comments?post=23702"}],"version-history":[{"count":0,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/posts\/23702\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/media\/23703"}],"wp:attachment":[{"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/media?parent=23702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/categories?post=23702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scannn.com\/lv\/wp-json\/wp\/v2\/tags?post=23702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}