{
 "paper": "prefrontal-orchestration",
 "a": "3.1",
 "b": "4.0",
 "summary": "From v3.1 (7 Apr) to v4.0 (30 May): 5,410 words to 7,254 words, 6,710 words in new or rewritten paragraphs and 4,866 taken out, 369 paragraphs changed.",
 "note": {
  "title": "Rewritten: recipes as the agent's executive function",
  "kind": "major-rewrite",
  "body": "## Summary\n\nA second full rewrite. The folder's notes say the owner chose on 2026-05-30 to rewrite this paper rather than start a new one, and to write up parts that were already running in the fork but had never been described. The paper now takes the brain's prefrontal cortex as its model: a layer that holds the plan, picks the routine and watches whether it works.\n\n- New title: \"The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function\".\n- Six capabilities, one section each: fuzzy matching of a request to a recipe, recipes built from other recipes, writing a new recipe when none fits, bounded loops, effort routing that sets model and thinking budget, and a panel that shows all of it.\n- Drops the idea of a separate orchestrator call and the Claude Code leak as the main evidence; the worker runs the recipe itself.\n- Adds pseudocode for each capability and a recipe document schema in the appendices.",
  "source": "change note"
 },
 "paragraphs_changed": 369,
 "changes": [
  {
   "section": "PREFRONTAL v3.1: From Guard Rails to Recipe Engine --- How Structured Orchestration Compounds Agent Intelligence",
   "old": "# PREFRONTAL v3.1: From Guard Rails to Recipe Engine --- How Structured Orchestration Compounds Agent Intelligence",
   "new": null,
   "marked": "[-# PREFRONTAL v3.1: From Guard Rails to Recipe Engine --- How Structured Orchestration Compounds Agent Intelligence-]"
  },
  {
   "section": "PREFRONTAL v3.1: From Guard Rails to Recipe Engine --- How Structured Orchestration Compounds Agent Intelligence",
   "old": "**Oscar Serra^1^, Jarvis^1^** ^1^Independent Research *7 April 2026 --- v3.1*",
   "new": null,
   "marked": "[-**Oscar Serra^1^, Jarvis^1^** ^1^Independent Research *7 April 2026 --- v3.1*-]"
  },
  {
   "section": "PREFRONTAL v4.0: The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function",
   "old": null,
   "new": "# PREFRONTAL v4.0: The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function",
   "marked": "{+# PREFRONTAL v4.0: The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function+}"
  },
  {
   "section": "PREFRONTAL v4.0: The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function",
   "old": null,
   "new": "**Oscar Serra¹, Jarvis¹** ¹Independent Research *30 May 2026 — v4.0*",
   "marked": "{+**Oscar Serra¹, Jarvis¹** ¹Independent Research *30 May 2026 — v4.0*+}"
  },
  {
   "section": "Abstract",
   "old": "The gap between preventing bad behaviour and enabling great behaviour is the central challenge of agent architecture. Version 2.4 of this paper proposed compounded intelligence through fractal reflection --- a post-action review cycle that converts events into reusable rules. Deployment validated the compounding hypothesis (+96% CII) but exposed a structural asymmetry: guards prevent mistakes but do not guide excellence.",
   "new": null,
   "marked": "[-The gap between preventing bad behaviour and enabling great behaviour is the central challenge of agent architecture. Version 2.4 of this paper proposed compounded intelligence through fractal reflection --- a post-action review cycle that converts events into reusable rules. Deployment validated the compounding hypothesis (+96% CII) but exposed a structural asymmetry: guards prevent mistakes but do not guide excellence.-]"
  },
  {
   "section": "Abstract",
   "old": "This paper introduces Prefrontal v3.1, a major architectural revision that transforms the orchestration layer from a passive guard system into an active **recipe execution engine**. The key insight comes from convergent evolution across three independent systems: Anthropic's Claude Code achieves its effectiveness through *skills* --- structured workflow prompts injected on demand that decompose complex tasks into ordered steps; Journey Kits (Berman, 2026) demonstrates that the commercial value of AI agents lies not in the model but in the structured *recipe* wrapped around it; and our own `prefrontal-prompt.md`, a rich orchestration prompt that has sat unused in the codebase for months, already encodes the recipe format we now propose to execute.",
   "new": null,
   "marked": "[-This paper introduces Prefrontal v3.1, a major architectural revision that transforms the orchestration layer from a passive guard system into an active **recipe execution engine**. The key insight comes from convergent evolution across three independent systems: Anthropic's Claude Code achieves its effectiveness through *skills* --- structured workflow prompts injected on demand that decompose complex tasks into ordered steps; Journey Kits (Berman, 2026) demonstrates that the commercial value of AI agents lies not in the model but in the structured *recipe* wrapped around it; and our own `prefrontal-prompt.md`, a rich orchestration prompt that has sat unused in the codebase for months, already encodes the recipe format we now propose to execute.-]"
  },
  {
   "section": "Abstract",
   "old": "The architectural pivot is economical. Prefrontal becomes a **first call** rather than a post-action reflection --- receiving the user's request, selecting or composing a recipe, dispatching parallel subagents, monitoring their progress, and conducting fractal reflection only after the recipe completes. Because this orchestration call shares nearly the same context as the main agent (same SOUL.md, same memory hierarchy, same session history), Anthropic's prompt cache makes the additional LLM call approximately 5% overhead in tokens. The fractal reflection that drove v2.4's compounding becomes the orchestrator's post-completion review --- still present, now properly situated within a complete cognitive cycle that includes pre-action planning, during-action monitoring, and post-action learning.",
   "new": null,
   "marked": "[-The architectural pivot is economical. Prefrontal becomes a **first call** rather than a post-action reflection --- receiving the user's request, selecting or composing a recipe, dispatching parallel subagents, monitoring their progress, and conducting fractal reflection only after the recipe completes. Because this orchestration call shares nearly the same context as the main agent (same SOUL.md, same memory hierarchy, same session history), Anthropic's prompt cache makes the additional LLM call approximately 5% overhead in tokens. The fractal reflection that drove v2.4's compounding becomes the orchestrator's post-completion review --- still present, now properly situated within a complete cognitive cycle that includes pre-action planning, during-action monitoring, and post-action learning.-]"
  },
  {
   "section": "Abstract",
   "old": "**Keywords:** recipe execution, agent orchestration, compounded intelligence, cognitive cycle, prompt cache, subagent parallelism, structured workflows",
   "new": null,
   "marked": "[-**Keywords:** recipe execution, agent orchestration, compounded intelligence, cognitive cycle, prompt cache, subagent parallelism, structured workflows-]"
  },
  {
   "section": "Abstract",
   "old": null,
   "new": "The dorsolateral prefrontal cortex does not *do* tasks. It holds the plan, selects the right behavioural program for the moment, sequences sub-routines, suppresses the impulsive response, watches whether the program is working, and re-allocates effort when it is not. It is the brain's executive: not a worker, but the structure that makes work coherent. We argue that a deployed language agent needs the same thing, and that the right shape for it is neither a guard rail nor a manager-agent but a **recipe execution substrate** — a layer that turns each turn into an executive-function cognitive cycle of *plan → match/compose/author → execute-with-loops → observe → adapt-effort*.",
   "marked": "{+The dorsolateral prefrontal cortex does not *do* tasks. It holds the plan, selects the right behavioural program for the moment, sequences sub-routines, suppresses the impulsive response, watches whether the program is working, and re-allocates effort when it is not. It is the brain's executive: not a worker, but the structure that makes work coherent. We argue that a deployed language agent needs the same thing, and that the right shape for it is neither a guard rail nor a manager-agent but a **recipe execution substrate** — a layer that turns each turn into an executive-function cognitive cycle of *plan → match/compose/author → execute-with-loops → observe → adapt-effort*.+}"
  },
  {
   "section": "Abstract",
   "old": null,
   "new": "A recipe is a structured workflow: ordered steps, tool hints, success gates, and failure handlers, written as a portable document rather than as code. The substrate we describe does six things with recipes that together make them an execution engine rather than a static library. (1) It **matches** the user's intent to recipes with a fuzzy, stemmed, edit-distance-tolerant scorer that reports a confidence tier, and seeds a plan automatically at the start of every turn. (2) It **composes** recipes from recipes — a recipe may merge another recipe's steps into its own at plan-build time, or call a sub-recipe at runtime, both cycle- and depth-guarded, exactly as functions call functions. (3) When nothing matches, it **authors** a new recipe on the fly, validates it, persists it, and makes it matchable on the very next turn — closing the loop on its own coverage gaps. (4) It supports bounded **loops** over steps (run *N* times / until-dry / until a marker appears), which is the element that lifts recipes from straight-line checklists to a structured, Turing-complete-ish execution substrate and closes the long-standing structural gap against hand-coded agent workflows. (5) It **routes effort dynamically**, classifying each turn as trivial / standard / deep / ultra and using that classification to *drive* the turn — model tier, thinking budget, orchestration mode, and token generosity all scale to the work. (6) It makes all of this **observable** through a dedicated RECIPES panel that renders the provenance trail (searched → matched → merged → composed → authored), per-subagent vitals, and the compact-versus-expanded decision trail, while keeping orchestration mechanics strictly out of the substantive chat.",
   "marked": "{+A recipe is a structured workflow: ordered steps, tool hints, success gates, and failure handlers, written as a portable document rather than as code. The substrate we describe does six things with recipes that together make them an execution engine rather than a static library. (1) It **matches** the user's intent to recipes with a fuzzy, stemmed, edit-distance-tolerant scorer that reports a confidence tier, and seeds a plan automatically at the start of every turn. (2) It **composes** recipes from recipes — a recipe may merge another recipe's steps into its own at plan-build time, or call a sub-recipe at runtime, both cycle- and depth-guarded, exactly as functions call functions. (3) When nothing matches, it **authors** a new recipe on the fly, validates it, persists it, and makes it matchable on the very next turn — closing the loop on its own coverage gaps. (4) It supports bounded **loops** over steps (run *N* times / until-dry / until a marker appears), which is the element that lifts recipes from straight-line checklists to a structured, Turing-complete-ish execution substrate and closes the long-standing structural gap against hand-coded agent workflows. (5) It **routes effort dynamically**, classifying each turn as trivial / standard / deep / ultra and using that classification to *drive* the turn — model tier, thinking budget, orchestration mode, and token generosity all scale to the work. (6) It makes all of this **observable** through a dedicated RECIPES panel that renders the provenance trail (searched → matched → merged → composed → authored), per-subagent vitals, and the compact-versus-expanded decision trail, while keeping orchestration mechanics strictly out of the substantive chat.+}"
  },
  {
   "section": "Abstract",
   "old": null,
   "new": "The thesis is that intelligence in a deployed agent is not primarily a property of the model. It is a property of the *structure the model executes inside* — and that structure is most powerful when it is composable, self-authoring, looping, effort-adaptive, and observable. This paper specifies that substrate, grounds the brain metaphor in concrete mechanism, and gives language-agnostic pseudocode for each of the six capabilities.",
   "marked": "{+The thesis is that intelligence in a deployed agent is not primarily a property of the model. It is a property of the *structure the model executes inside* — and that structure is most powerful when it is composable, self-authoring, looping, effort-adaptive, and observable. This paper specifies that substrate, grounds the brain metaphor in concrete mechanism, and gives language-agnostic pseudocode for each of the six capabilities.+}"
  },
  {
   "section": "Abstract",
   "old": null,
   "new": "**Keywords:** recipe execution, executive function, agent orchestration, workflow composition, self-authoring workflows, bounded loops, effort routing, observability, cognitive cycle",
   "marked": "{+**Keywords:** recipe execution, executive function, agent orchestration, workflow composition, self-authoring workflows, bounded loops, effort routing, observability, cognitive cycle+}"
  },
  {
   "section": "1. Introduction --- The Recipe Gap",
   "old": "## 1. Introduction --- The Recipe Gap",
   "new": null,
   "marked": "[-## 1. Introduction --- The Recipe Gap-]"
  },
  {
   "section": "1.1 Why Claude Code Works",
   "old": "### 1.1 Why Claude Code Works",
   "new": null,
   "marked": "[-### 1.1 Why Claude Code Works-]"
  },
  {
   "section": "1.1 Why Claude Code Works",
   "old": "In March 2026, an accidental source code exposure revealed the internal architecture of Anthropic's Claude Code, the commercially leading AI coding agent. Its effectiveness derives not from a superior model, but from a `while(true)` loop wrapped in three mechanisms:",
   "new": null,
   "marked": "[-In March 2026, an accidental source code exposure revealed the internal architecture of Anthropic's Claude Code, the commercially leading AI coding agent. Its effectiveness derives not from a superior model, but from a `while(true)` loop wrapped in three mechanisms:-]"
  },
  {
   "section": "1.1 Why Claude Code Works",
   "old": "1. **Skills**: structured prompts injected on demand that encode specific workflows. A \"commit\" skill prescribes: check status, diff changes, review history, draft message, stage files, commit. A \"review-pr\" skill prescribes: fetch PR, read changes, check tests, assess impact, write review. These are not suggestions --- they are recipes that the agent executes step by step.",
   "new": null,
   "marked": "[-1. **Skills**: structured prompts injected on demand that encode specific workflows. A \"commit\" skill prescribes: check status, diff changes, review history, draft message, stage files, commit. A \"review-pr\" skill prescribes: fetch PR, read changes, check tests, assess impact, write review. These are not suggestions --- they are recipes that the agent executes step by step.-]"
  },
  {
   "section": "1.1 Why Claude Code Works",
   "old": "2. **Fork subagents**: child agents that inherit the parent's full context (exploiting prompt cache for near-zero marginal cost), run in background with isolated tool sets, and return results to the orchestrator.",
   "new": null,
   "marked": "[-2. **Fork subagents**: child agents that inherit the parent's full context (exploiting prompt cache for near-zero marginal cost), run in background with isolated tool sets, and return results to the orchestrator.-]"
  },
  {
   "section": "1.1 Why Claude Code Works",
   "old": "3. **Five-layer context compression**: aggressive management of the context window through conversation compaction, tool result summarisation, and a `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` that separates cacheable from per-turn content.",
   "new": null,
   "marked": "[-3. **Five-layer context compression**: aggressive management of the context window through conversation compaction, tool result summarisation, and a `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` that separates cacheable from per-turn content.-]"
  },
  {
   "section": "1.1 Why Claude Code Works",
   "old": "These are operational recipes distilled from failures.",
   "new": null,
   "marked": "[-These are operational recipes distilled from failures.-]"
  },
  {
   "section": "1.1 Why Claude Code Works",
   "old": "The meta-pattern is clear: Claude Code's effectiveness comes from skills that are recipes, executed in sequence, by an agent that knows which recipe to apply.",
   "new": null,
   "marked": "[-The meta-pattern is clear: Claude Code's effectiveness comes from skills that are recipes, executed in sequence, by an agent that knows which recipe to apply.-]"
  },
  {
   "section": "1.2 The Journey Kits Thesis",
   "old": "### 1.2 The Journey Kits Thesis",
   "new": null,
   "marked": "[-### 1.2 The Journey Kits Thesis-]"
  },
  {
   "section": "1.2 The Journey Kits Thesis",
   "old": "Matthew Berman's Journey Kits (journeykits.ai, 2026) makes clear an insight that was implicit in the Claude Code analysis: **the value is not the model --- it is the structured workflow wrapped around it**. Journey Kits proposes an \"npm for AI agent workflows\" --- a registry of reusable recipes that bundle skills, source code, documentation, and metadata into distributable packages.",
   "new": null,
   "marked": "[-Matthew Berman's Journey Kits (journeykits.ai, 2026) makes clear an insight that was implicit in the Claude Code analysis: **the value is not the model --- it is the structured workflow wrapped around it**. Journey Kits proposes an \"npm for AI agent workflows\" --- a registry of reusable recipes that bundle skills, source code, documentation, and metadata into distributable packages.-]"
  },
  {
   "section": "1.2 The Journey Kits Thesis",
   "old": "The thesis is direct: if you give the same model to two teams, the one with better recipes wins. The model is the commodity; the recipe is the differentiator. This inverts the conventional wisdom that model capability is the primary driver of agent quality.",
   "new": null,
   "marked": "[-The thesis is direct: if you give the same model to two teams, the one with better recipes wins. The model is the commodity; the recipe is the differentiator. This inverts the conventional wisdom that model capability is the primary driver of agent quality.-]"
  },
  {
   "section": "1.2 The Journey Kits Thesis",
   "old": "Journey Kits identifies the recipe as the atomic unit of agent value. A recipe is not a prompt --- it is a structured workflow with preconditions, ordered steps, success criteria, and failure handlers. The distinction matters: a prompt says \"fix this bug\"; a recipe says \"reproduce the bug, locate the root cause, write a failing test, implement the fix, verify the test passes, check for regressions, commit with a descriptive message.\"",
   "new": null,
   "marked": "[-Journey Kits identifies the recipe as the atomic unit of agent value. A recipe is not a prompt --- it is a structured workflow with preconditions, ordered steps, success criteria, and failure handlers. The distinction matters: a prompt says \"fix this bug\"; a recipe says \"reproduce the bug, locate the root cause, write a failing test, implement the fix, verify the test passes, check for regressions, commit with a descriptive message.\"-]"
  },
  {
   "section": "1.3 The v2.4 Gap",
   "old": "### 1.3 The v2.4 Gap",
   "new": null,
   "marked": "[-### 1.3 The v2.4 Gap-]"
  },
  {
   "section": "1.3 The v2.4 Gap",
   "old": "Version 2.4 of this paper promised compounded intelligence through fractal reflection --- \"the compounding engine\" that converts events into reusable rules at multiple abstraction levels. The implementation delivered guards, observability, and monitoring, but lacked a navigation system for agents.",
   "new": null,
   "marked": "[-Version 2.4 of this paper promised compounded intelligence through fractal reflection --- \"the compounding engine\" that converts events into reusable rules at multiple abstraction levels. The implementation delivered guards, observability, and monitoring, but lacked a navigation system for agents.-]"
  },
  {
   "section": "1.3 The v2.4 Gap",
   "old": "v2.4 omitted the compounding engine itself. Fractal reflection, described in Section 3.1 of v2.4 as the primary mechanism of intelligence compounding, exists only as a prompt template (`prefrontal-prompt.md`) that was never wired into the execution pipeline. The four-question reflection protocol (MEMORY, PATTERN, RIPPLE, IMPROVE) runs only when the agent voluntarily follows the system prompt's instructions, which it does inconsistently.",
   "new": null,
   "marked": "[-v2.4 omitted the compounding engine itself. Fractal reflection, described in Section 3.1 of v2.4 as the primary mechanism of intelligence compounding, exists only as a prompt template (`prefrontal-prompt.md`) that was never wired into the execution pipeline. The four-question reflection protocol (MEMORY, PATTERN, RIPPLE, IMPROVE) runs only when the agent voluntarily follows the system prompt's instructions, which it does inconsistently.-]"
  },
  {
   "section": "1.4 The Cache-Shared First Call",
   "old": "### 1.4 The Cache-Shared First Call",
   "new": null,
   "marked": "[-### 1.4 The Cache-Shared First Call-]"
  },
  {
   "section": "1.4 The Cache-Shared First Call",
   "old": "The architectural insight that enables v3.1 is economic. Anthropic's prompt cache means that a second LLM call with *nearly the same context* as the first is dramatically cheaper than two independent calls. If the system prompt, SOUL.md, memory hierarchy, and session history are identical between calls, only the differing portion (the orchestration instruction vs. the task instruction) incurs full token cost.",
   "new": null,
   "marked": "[-The architectural insight that enables v3.1 is economic. Anthropic's prompt cache means that a second LLM call with *nearly the same context* as the first is dramatically cheaper than two independent calls. If the system prompt, SOUL.md, memory hierarchy, and session history are identical between calls, only the differing portion (the orchestration instruction vs. the task instruction) incurs full token cost.-]"
  },
  {
   "section": "1.4 The Cache-Shared First Call",
   "old": "Prefrontal becomes a **first call**, planning execution at ~5% overhead. Orchestration is nearly free.",
   "new": null,
   "marked": "[-Prefrontal becomes a **first call**, planning execution at ~5% overhead. Orchestration is nearly free.-]"
  },
  {
   "section": "1.4 The Cache-Shared First Call",
   "old": "The same cache property enables the fractal reflection to remain a *second call* after task completion, also at minimal marginal cost. The complete cognitive cycle --- plan, execute, reflect --- costs approximately 10% more than unorchestrated execution but produces structured, repeatable, self-improving behaviour.",
   "new": null,
   "marked": "[-The same cache property enables the fractal reflection to remain a *second call* after task completion, also at minimal marginal cost. The complete cognitive cycle --- plan, execute, reflect --- costs approximately 10% more than unorchestrated execution but produces structured, repeatable, self-improving behaviour.-]"
  },
  {
   "section": "1. Introduction — From Library to Substrate",
   "old": null,
   "new": "## 1. Introduction — From Library to Substrate",
   "marked": "{+## 1. Introduction — From Library to Substrate+}"
  },
  {
   "section": "1.1 The prefrontal analogy, taken seriously",
   "old": null,
   "new": "### 1.1 The prefrontal analogy, taken seriously",
   "marked": "{+### 1.1 The prefrontal analogy, taken seriously+}"
  },
  {
   "section": "1.1 The prefrontal analogy, taken seriously",
   "old": null,
   "new": "When a person sits down to debug a stubborn problem, very little of the work is the \"debugging.\" Most of it is executive: deciding *that* this is a debugging task and not a redesign task, recalling the program (\"reproduce, then isolate, then fix, then verify\"), holding that program in working memory while the hands and eyes do the reading and editing, suppressing the urge to patch the first symptom, noticing when the current step has stopped producing new information, and spending more attention when the problem is hard and less when it is trivial. The prefrontal cortex is the organ of that executive layer: working memory, task-set selection, sequencing, response inhibition, and effort regulation.",
   "marked": "{+When a person sits down to debug a stubborn problem, very little of the work is the \"debugging.\" Most of it is executive: deciding *that* this is a debugging task and not a redesign task, recalling the program (\"reproduce, then isolate, then fix, then verify\"), holding that program in working memory while the hands and eyes do the reading and editing, suppressing the urge to patch the first symptom, noticing when the current step has stopped producing new information, and spending more attention when the problem is hard and less when it is trivial. The prefrontal cortex is the organ of that executive layer: working memory, task-set selection, sequencing, response inhibition, and effort regulation.+}"
  },
  {
   "section": "1.1 The prefrontal analogy, taken seriously",
   "old": null,
   "new": "A language model is an extraordinary worker and a poor executive. Turn to turn it can read, reason, write, and call tools at a level that dwarfs human working memory for a single step — and yet, left to itself, it repeats the same structural mistakes: it edits before it reproduces, it codes before it designs, it searches before it scopes, it declares victory before it verifies. The deficit is not capability. It is the absence of an executive layer that holds and sequences the *program*.",
   "marked": "{+A language model is an extraordinary worker and a poor executive. Turn to turn it can read, reason, write, and call tools at a level that dwarfs human working memory for a single step — and yet, left to itself, it repeats the same structural mistakes: it edits before it reproduces, it codes before it designs, it searches before it scopes, it declares victory before it verifies. The deficit is not capability. It is the absence of an executive layer that holds and sequences the *program*.+}"
  },
  {
   "section": "1.1 The prefrontal analogy, taken seriously",
   "old": null,
   "new": "This paper describes that layer. We call it PREFRONTAL, and we argue its correct form is a **recipe execution substrate**: a thin layer wrapped around the agent that, on every turn, recognises the task, selects or assembles the appropriate behavioural program, runs it with the agent as the worker, watches the execution, and regulates how much effort the turn deserves. The brain metaphor is not decoration; each capability below maps onto a specific executive function, and we name the mapping explicitly as we go.",
   "marked": "{+This paper describes that layer. We call it PREFRONTAL, and we argue its correct form is a **recipe execution substrate**: a thin layer wrapped around the agent that, on every turn, recognises the task, selects or assembles the appropriate behavioural program, runs it with the agent as the worker, watches the execution, and regulates how much effort the turn deserves. The brain metaphor is not decoration; each capability below maps onto a specific executive function, and we name the mapping explicitly as we go.+}"
  },
  {
   "section": "1.2 What a recipe is, and why it is the right unit",
   "old": null,
   "new": "### 1.2 What a recipe is, and why it is the right unit",
   "marked": "{+### 1.2 What a recipe is, and why it is the right unit+}"
  },
  {
   "section": "1.2 What a recipe is, and why it is the right unit",
   "old": null,
   "new": "A **recipe** is a structured workflow expressed as a portable document. It carries metadata (what intents it serves, what it is for), a set of triggers, an ordered list of steps — each with a short instruction, optional tool hints, and a *done-when* success criterion — and, where relevant, constraints, safety notes, and a record of the failure modes it was designed to prevent. Crucially, a recipe is *not* a prompt and *not* a script.",
   "marked": "{+A **recipe** is a structured workflow expressed as a portable document. It carries metadata (what intents it serves, what it is for), a set of triggers, an ordered list of steps — each with a short instruction, optional tool hints, and a *done-when* success criterion — and, where relevant, constraints, safety notes, and a record of the failure modes it was designed to prevent. Crucially, a recipe is *not* a prompt and *not* a script.+}"
  },
  {
   "section": "1.2 What a recipe is, and why it is the right unit",
   "old": null,
   "new": "- A **prompt** says \"fix this bug.\" It is a wish. - A **script** says, in code, \"run command X, parse output, branch on line 12.\" It executes mechanically and shatters on the first input it did not anticipate. - A **recipe** says \"reproduce the failure with evidence; *then* trace the root cause to a file and line; *then* apply the smallest fix; *then* verify the original error is gone.\" It is structure that an intelligent worker can follow, adapt, or — with justification — override.",
   "marked": "{+- A **prompt** says \"fix this bug.\" It is a wish. - A **script** says, in code, \"run command X, parse output, branch on line 12.\" It executes mechanically and shatters on the first input it did not anticipate. - A **recipe** says \"reproduce the failure with evidence; *then* trace the root cause to a file and line; *then* apply the smallest fix; *then* verify the original error is gone.\" It is structure that an intelligent worker can follow, adapt, or — with justification — override.+}"
  },
  {
   "section": "1.2 What a recipe is, and why it is the right unit",
   "old": null,
   "new": "The recipe is the right granularity because it is the unit at which operational knowledge actually accumulates. A team that has debugged a thousand issues does not encode that experience as a better model; it encodes it as the discipline of *reproduce before you fix*. A recipe is where that discipline lives in a form that is human-readable, versionable, composable, and — as we will show — machine-authorable.",
   "marked": "{+The recipe is the right granularity because it is the unit at which operational knowledge actually accumulates. A team that has debugged a thousand issues does not encode that experience as a better model; it encodes it as the discipline of *reproduce before you fix*. A recipe is where that discipline lives in a form that is human-readable, versionable, composable, and — as we will show — machine-authorable.+}"
  },
  {
   "section": "1.3 The gap this paper closes",
   "old": null,
   "new": "### 1.3 The gap this paper closes",
   "marked": "{+### 1.3 The gap this paper closes+}"
  },
  {
   "section": "1.3 The gap this paper closes",
   "old": null,
   "new": "A recipe *library* is useful but inert: a shelf of playbooks the agent consults when it remembers to. The contribution of this work is to make the library a **substrate** — an active engine with six properties that, taken together, are what separate a checklist from a programming language for behaviour:",
   "marked": "{+A recipe *library* is useful but inert: a shelf of playbooks the agent consults when it remembers to. The contribution of this work is to make the library a **substrate** — an active engine with six properties that, taken together, are what separate a checklist from a programming language for behaviour:+}"
  },
  {
   "section": "1.3 The gap this paper closes",
   "old": null,
   "new": "1. **Matching** turns \"the agent should pick the right playbook\" into \"the right plan is already seeded before the agent's first token,\" via a fuzzy scorer with confidence tiers. (Task-set selection.) 2. **Composition** lets recipes be built from recipes, both statically (step-merge) and dynamically (runtime sub-recipe calls), so workflows reuse workflows instead of duplicating them. (Hierarchical program structure.) 3. **On-the-fly authoring** lets the substrate write a new recipe when none fits, validate it, and add it to the library mid-conversation — so coverage gaps heal themselves. (Skill acquisition.) 4. **Loops** let a step repeat under a bounded condition, which is the single feature that elevates recipes from straight-line sequences to a substrate expressive enough to encode iterative work. (Sustained, monitored repetition.) 5. **Effort routing** classifies the turn and *drives* it — choosing model tier, thinking budget, orchestration mode, and token generosity to fit. (Effort regulation.) 6. **Observability** surfaces the whole life-cycle in a dedicated panel, so a human can see what program is running, where it is, and how each worker is doing, without that machinery polluting the substantive answer. (Metacognitive monitoring.)",
   "marked": "{+1. **Matching** turns \"the agent should pick the right playbook\" into \"the right plan is already seeded before the agent's first token,\" via a fuzzy scorer with confidence tiers. (Task-set selection.) 2. **Composition** lets recipes be built from recipes, both statically (step-merge) and dynamically (runtime sub-recipe calls), so workflows reuse workflows instead of duplicating them. (Hierarchical program structure.) 3. **On-the-fly authoring** lets the substrate write a new recipe when none fits, validate it, and add it to the library mid-conversation — so coverage gaps heal themselves. (Skill acquisition.) 4. **Loops** let a step repeat under a bounded condition, which is the single feature that elevates recipes from straight-line sequences to a substrate expressive enough to encode iterative work. (Sustained, monitored repetition.) 5. **Effort routing** classifies the turn and *drives* it — choosing model tier, thinking budget, orchestration mode, and token generosity to fit. (Effort regulation.) 6. **Observability** surfaces the whole life-cycle in a dedicated panel, so a human can see what program is running, where it is, and how each worker is doing, without that machinery polluting the substantive answer. (Metacognitive monitoring.)+}"
  },
  {
   "section": "1.3 The gap this paper closes",
   "old": null,
   "new": "The rest of the paper specifies each in turn (Sections 3–8), after establishing the architecture and the economics that make it affordable (Section 2). Section 9 integrates the substrate with the surrounding cognitive systems; Section 10 gives evaluation design; Section 11 lists suggested diagrams; Section 12 concludes.",
   "marked": "{+The rest of the paper specifies each in turn (Sections 3–8), after establishing the architecture and the economics that make it affordable (Section 2). Section 9 integrates the substrate with the surrounding cognitive systems; Section 10 gives evaluation design; Section 11 lists suggested diagrams; Section 12 concludes.+}"
  },
  {
   "section": "2. Architecture --- The Orchestrator Model",
   "old": "## 2. Architecture --- The Orchestrator Model",
   "new": null,
   "marked": "[-## 2. Architecture --- The Orchestrator Model-]"
  },
  {
   "section": "2.1 System Overview",
   "old": "### 2.1 System Overview",
   "new": null,
   "marked": "[-### 2.1 System Overview-]"
  },
  {
   "section": "2.1 System Overview",
   "old": "Prefrontal v3.1 introduces a three-phase cognitive cycle that wraps every agent interaction:",
   "new": null,
   "marked": "[-Prefrontal v3.1 introduces a three-phase cognitive cycle that wraps every agent interaction:-]"
  },
  {
   "section": "2.1 System Overview",
   "old": "``` User message | v [Phase 1: PLAN] -- Prefrontal LLM call (cache-shared) | - Classify intent | - Select or compose recipe | - Present plan to user (if complex) | - Allocate subagents v [Phase 2: EXECUTE] -- Subagent dispatch | - Fan-out workers with isolated contexts | - Prefrontal monitors progress via events | - Stall detection and intervention | - Periodic status updates to UI v [Phase 3: REFLECT] -- Fractal reflection (cache-shared) | - MEMORY: persist new knowledge | - PATTERN: multi-level abstraction | - RIPPLE: scan for staleness | - IMPROVE: opportunistic fixes v Response to user ```",
   "new": null,
   "marked": "[-``` User message | v [Phase 1: PLAN] -- Prefrontal LLM call (cache-shared) | - Classify intent | - Select or compose recipe | - Present plan to user (if complex) | - Allocate subagents v [Phase 2: EXECUTE] -- Subagent dispatch | - Fan-out workers with isolated contexts | - Prefrontal monitors progress via events | - Stall detection and intervention | - Periodic status updates to UI v [Phase 3: REFLECT] -- Fractal reflection (cache-shared) | - MEMORY: persist new knowledge | - PATTERN: multi-level abstraction | - RIPPLE: scan for staleness | - IMPROVE: opportunistic fixes v Response to user ```-]"
  },
  {
   "section": "2.1 System Overview",
   "old": "**Figure 1.** The three-phase cognitive cycle. Phases 1 and 3 are cache-shared LLM calls with approximately 5% token overhead each. Phase 2 is standard agent execution with Prefrontal monitoring via WebSocket events.",
   "new": null,
   "marked": "[-**Figure 1.** The three-phase cognitive cycle. Phases 1 and 3 are cache-shared LLM calls with approximately 5% token overhead each. Phase 2 is standard agent execution with Prefrontal monitoring via WebSocket events.-]"
  },
  {
   "section": "2.1 System Overview",
   "old": "For simple requests, Phase 1 bypasses recipe selection to avoid overhead.",
   "new": null,
   "marked": "[-For simple requests, Phase 1 bypasses recipe selection to avoid overhead.-]"
  },
  {
   "section": "2.2 Prefrontal as First Call",
   "old": "### 2.2 Prefrontal as First Call",
   "new": null,
   "marked": "[-### 2.2 Prefrontal as First Call-]"
  },
  {
   "section": "2.2 Prefrontal as First Call",
   "old": "The traditional agent architecture processes user messages directly: the message enters the model alongside the system prompt, and the model decides what to do. Prefrontal v3.1 interposes an orchestration layer:",
   "new": null,
   "marked": "[-The traditional agent architecture processes user messages directly: the message enters the model alongside the system prompt, and the model decides what to do. Prefrontal v3.1 interposes an orchestration layer:-]"
  },
  {
   "section": "2.2 Prefrontal as First Call",
   "old": "1. The user's message arrives at the gateway. 2. **Before** the main agent processes it, Prefrontal receives the message with the same context (SOUL.md, memory hierarchy, session history) plus an orchestration-specific instruction set. 3. Prefrontal classifies the intent, selects a recipe, and emits a structured plan. 4. The plan is injected into the main agent's context as a structured preamble. 5. The main agent executes with the recipe's steps as explicit guidance.",
   "new": null,
   "marked": "[-1. The user's message arrives at the gateway. 2. **Before** the main agent processes it, Prefrontal receives the message with the same context (SOUL.md, memory hierarchy, session history) plus an orchestration-specific instruction set. 3. Prefrontal classifies the intent, selects a recipe, and emits a structured plan. 4. The plan is injected into the main agent's context as a structured preamble. 5. The main agent executes with the recipe's steps as explicit guidance.-]"
  },
  {
   "section": "2.2 Prefrontal as First Call",
   "old": "The critical design decision is that Prefrontal does *not* replace the main agent, nor does it introduce a separate \"manager agent\". Prefrontal is a cache-shared first call using the *exact same agent*, simply prepending the recipe. The main agent retains full autonomy; the recipe provides structure, not bureaucratic constraint. This preserves the flexibility that makes LLM agents valuable while adding the predictability that makes them reliable.",
   "new": null,
   "marked": "[-The critical design decision is that Prefrontal does *not* replace the main agent, nor does it introduce a separate \"manager agent\". Prefrontal is a cache-shared first call using the *exact same agent*, simply prepending the recipe. The main agent retains full autonomy; the recipe provides structure, not bureaucratic constraint. This preserves the flexibility that makes LLM agents valuable while adding the predictability that makes them reliable.-]"
  },
  {
   "section": "2.2 Prefrontal as First Call",
   "old": "**Why first, not second?** Version 2.4's fractal reflection operated as a post-action review --- useful for learning, but unable to prevent the mistakes it learned from. By moving to a pre-action position, Prefrontal can shape the agent's approach *before* tokens are spent on a flawed strategy. The post-action reflection remains, but now reviews execution against the plan rather than against an implicit standard.",
   "new": null,
   "marked": "[-**Why first, not second?** Version 2.4's fractal reflection operated as a post-action review --- useful for learning, but unable to prevent the mistakes it learned from. By moving to a pre-action position, Prefrontal can shape the agent's approach *before* tokens are spent on a flawed strategy. The post-action reflection remains, but now reviews execution against the plan rather than against an implicit standard.-]"
  },
  {
   "section": "2.3 The Cache Trick",
   "old": "### 2.3 The Cache Trick",
   "new": null,
   "marked": "[-### 2.3 The Cache Trick-]"
  },
  {
   "section": "2.3 The Cache Trick",
   "old": "The economics of this architecture depend entirely on prompt caching. Consider a typical agent turn:",
   "new": null,
   "marked": "[-The economics of this architecture depend entirely on prompt caching. Consider a typical agent turn:-]"
  },
  {
   "section": "2.3 The Cache Trick",
   "old": "| Component | Tokens | Cached? | |-----------|--------|---------| | System prompt (SOUL.md, agents, rules) | ~8,000 | Yes (static) | | Memory hierarchy (retrieved files) | ~4,000 | Yes (session) | | Session history | ~6,000 | Yes (session) | | Orchestration instruction | ~800 | No | | User message | ~200 | No | | **Total** | **~19,000** | **~95% cached** |",
   "new": null,
   "marked": "[-| Component | Tokens | Cached? | |-----------|--------|---------| | System prompt (SOUL.md, agents, rules) | ~8,000 | Yes (static) | | Memory hierarchy (retrieved files) | ~4,000 | Yes (session) | | Session history | ~6,000 | Yes (session) | | Orchestration instruction | ~800 | No | | User message | ~200 | No | | **Total** | **~19,000** | **~95% cached** |-]"
  },
  {
   "section": "2.3 The Cache Trick",
   "old": "The Prefrontal call uses the same first 18,000 tokens as the main agent call. Only the orchestration instruction (replacing the main agent's task instruction) differs. At Anthropic's cache pricing (90% discount on cached tokens), the Prefrontal call costs approximately 5% of a full call.",
   "new": null,
   "marked": "[-The Prefrontal call uses the same first 18,000 tokens as the main agent call. Only the orchestration instruction (replacing the main agent's task instruction) differs. At Anthropic's cache pricing (90% discount on cached tokens), the Prefrontal call costs approximately 5% of a full call.-]"
  },
  {
   "section": "2.3 The Cache Trick",
   "old": "This is not an optimisation --- it is an architectural enabler. Without prompt caching, a pre-action orchestration call would double the cost of every turn. With it, orchestration is nearly free, and the question shifts from \"can we afford orchestration?\" to \"can we afford *not* to orchestrate?\"",
   "new": null,
   "marked": "[-This is not an optimisation --- it is an architectural enabler. Without prompt caching, a pre-action orchestration call would double the cost of every turn. With it, orchestration is nearly free, and the question shifts from \"can we afford orchestration?\" to \"can we afford *not* to orchestrate?\"-]"
  },
  {
   "section": "2.4 Subagent Parallelism",
   "old": "### 2.4 Subagent Parallelism",
   "new": null,
   "marked": "[-### 2.4 Subagent Parallelism-]"
  },
  {
   "section": "2.4 Subagent Parallelism",
   "old": "For decomposable tasks, Prefrontal fans out parallel subagents:",
   "new": null,
   "marked": "[-For decomposable tasks, Prefrontal fans out parallel subagents:-]"
  },
  {
   "section": "2.4 Subagent Parallelism",
   "old": "- **Fork subagents** inherit the parent's rendered prompt (cache-shared) and receive a scoped task: \"investigate the stack trace,\" \"write a failing test,\" \"check for similar patterns in the codebase.\"",
   "new": null,
   "marked": "[-- **Fork subagents** inherit the parent's rendered prompt (cache-shared) and receive a scoped task: \"investigate the stack trace,\" \"write a failing test,\" \"check for similar patterns in the codebase.\"-]"
  },
  {
   "section": "2.4 Subagent Parallelism",
   "old": "- **Prefrontal monitors** subagent progress via WebSocket events. Each subagent emits structured status updates: task accepted, tool calls in progress, intermediate findings, completion with results.",
   "new": null,
   "marked": "[-- **Prefrontal monitors** subagent progress via WebSocket events. Each subagent emits structured status updates: task accepted, tool calls in progress, intermediate findings, completion with results.-]"
  },
  {
   "section": "2.4 Subagent Parallelism",
   "old": "- **Stall detection**: if a subagent exceeds its expected duration (configurable per recipe step, default 120 seconds) or enters a tool-denial loop (3 consecutive denials), Prefrontal intervenes --- either reassigning the task, providing additional context, or escalating to the user.",
   "new": null,
   "marked": "[-- **Stall detection**: if a subagent exceeds its expected duration (configurable per recipe step, default 120 seconds) or enters a tool-denial loop (3 consecutive denials), Prefrontal intervenes --- either reassigning the task, providing additional context, or escalating to the user.-]"
  },
  {
   "section": "2.4 Subagent Parallelism",
   "old": "- **Result aggregation**: as subagents complete, Prefrontal assembles their outputs into a coherent response. For investigation tasks, this means synthesising findings. For implementation tasks, this means verifying consistency across parallel changes.",
   "new": null,
   "marked": "[-- **Result aggregation**: as subagents complete, Prefrontal assembles their outputs into a coherent response. For investigation tasks, this means synthesising findings. For implementation tasks, this means verifying consistency across parallel changes.-]"
  },
  {
   "section": "2.4 Subagent Parallelism",
   "old": "The parallelism model mirrors Claude Code's fork pattern but adds active monitoring. Claude Code's forked subagents run independently and return results; Prefrontal's subagents are *supervised* --- the orchestrator watches their progress and can intervene. This supervision is the difference between delegation and orchestration.",
   "new": null,
   "marked": "[-The parallelism model mirrors Claude Code's fork pattern but adds active monitoring. Claude Code's forked subagents run independently and return results; Prefrontal's subagents are *supervised* --- the orchestrator watches their progress and can intervene. This supervision is the difference between delegation and orchestration.-]"
  },
  {
   "section": "2.5 Periodic Progress Reports",
   "old": "### 2.5 Periodic Progress Reports",
   "new": null,
   "marked": "[-### 2.5 Periodic Progress Reports-]"
  },
  {
   "section": "2.5 Periodic Progress Reports",
   "old": "For long-running tasks (multi-file refactors, complex investigations, deployment sequences), Prefrontal emits periodic status updates to the Tinker UI via WebSocket events:",
   "new": null,
   "marked": "[-For long-running tasks (multi-file refactors, complex investigations, deployment sequences), Prefrontal emits periodic status updates to the Tinker UI via WebSocket events:-]"
  },
  {
   "section": "2.5 Periodic Progress Reports",
   "old": "```json { \"type\": \"prefrontal:progress\", \"recipe\": \"feature-implementation\", \"step\": 3, \"totalSteps\": 7, \"stepName\": \"Write failing tests\", \"subagents\": [ {\"id\": \"sa-001\", \"status\": \"complete\", \"task\": \"Investigate root cause\"}, {\"id\": \"sa-002\", \"status\": \"running\", \"task\": \"Write test cases\", \"elapsed\": \"45s\"}, {\"id\": \"sa-003\", \"status\": \"pending\", \"task\": \"Implement fix\"} ], \"elapsed\": \"2m15s\" } ```",
   "new": null,
   "marked": "[-```json { \"type\": \"prefrontal:progress\", \"recipe\": \"feature-implementation\", \"step\": 3, \"totalSteps\": 7, \"stepName\": \"Write failing tests\", \"subagents\": [ {\"id\": \"sa-001\", \"status\": \"complete\", \"task\": \"Investigate root cause\"}, {\"id\": \"sa-002\", \"status\": \"running\", \"task\": \"Write test cases\", \"elapsed\": \"45s\"}, {\"id\": \"sa-003\", \"status\": \"pending\", \"task\": \"Implement fix\"} ], \"elapsed\": \"2m15s\" } ```-]"
  },
  {
   "section": "2.5 Periodic Progress Reports",
   "old": "The Tinker UI renders these as a real-time progress panel in the right sidebar, extending the existing call tree with recipe step indicators, subagent status badges, and elapsed time per step. Users see not just *that* the agent is working, but *what* it is doing, *where* it is in the recipe, and *how long* each step is taking.",
   "new": null,
   "marked": "[-The Tinker UI renders these as a real-time progress panel in the right sidebar, extending the existing call tree with recipe step indicators, subagent status badges, and elapsed time per step. Users see not just *that* the agent is working, but *what* it is doing, *where* it is in the recipe, and *how long* each step is taking.-]"
  },
  {
   "section": "2.6 Visualisation: The Call Tree",
   "old": "### 2.6 Visualisation: The Call Tree",
   "new": null,
   "marked": "[-### 2.6 Visualisation: The Call Tree-]"
  },
  {
   "section": "2.6 Visualisation: The Call Tree",
   "old": "The existing Prefrontal call tree panel (`prefrontal-tree.ts`) displays agent topology with real-time phase indicators. Version 3.0 extends this with:",
   "new": null,
   "marked": "[-The existing Prefrontal call tree panel (`prefrontal-tree.ts`) displays agent topology with real-time phase indicators. Version 3.0 extends this with:-]"
  },
  {
   "section": "2.6 Visualisation: The Call Tree",
   "old": "- **Recipe overlay**: the current recipe's steps are displayed as a vertical timeline alongside the call tree, with the active step highlighted and completed steps checked. - **Subagent mapping**: each subagent node in the tree is linked to its recipe step, showing which part of the plan each worker is executing. - **Cost tracking**: cumulative token usage per subagent and per recipe step, enabling real-time cost visibility. - **Stall indicators**: subagents that exceed their expected duration are highlighted with a warning indicator, and Prefrontal's intervention actions are displayed inline.",
   "new": null,
   "marked": "[-- **Recipe overlay**: the current recipe's steps are displayed as a vertical timeline alongside the call tree, with the active step highlighted and completed steps checked. - **Subagent mapping**: each subagent node in the tree is linked to its recipe step, showing which part of the plan each worker is executing. - **Cost tracking**: cumulative token usage per subagent and per recipe step, enabling real-time cost visibility. - **Stall indicators**: subagents that exceed their expected duration are highlighted with a warning indicator, and Prefrontal's intervention actions are displayed inline.-]"
  },
  {
   "section": "2. Architecture — The Executive-Function Cycle",
   "old": null,
   "new": "## 2. Architecture — The Executive-Function Cycle",
   "marked": "{+## 2. Architecture — The Executive-Function Cycle+}"
  },
  {
   "section": "2.1 The cycle",
   "old": null,
   "new": "### 2.1 The cycle",
   "marked": "{+### 2.1 The cycle+}"
  },
  {
   "section": "2.1 The cycle",
   "old": null,
   "new": "PREFRONTAL wraps every interaction in a five-phase cycle that mirrors executive function:",
   "marked": "{+PREFRONTAL wraps every interaction in a five-phase cycle that mirrors executive function:+}"
  },
  {
   "section": "2.1 The cycle",
   "old": null,
   "new": "``` user message | v PLAN classify intent; gauge effort tier <- effort routing decides the gear | v MATCH / score recipes (fuzzy + confidence); <- task-set selection COMPOSE / merge or compose; on no-match, AUTHOR author a new recipe | v EXECUTE run the plan; fan out parallel groups; <- sequencing + sub-routine calls (w/loops) recurse sub-recipes; loop steps | v OBSERVE render provenance, step progress, <- metacognitive monitoring subagent vitals to RECIPES panel | v ADAPT reflect; tune effort & recipes for <- learning + regulation next turn | v response to user ```",
   "marked": "{+``` user message | v PLAN classify intent; gauge effort tier <- effort routing decides the gear | v MATCH / score recipes (fuzzy + confidence); <- task-set selection COMPOSE / merge or compose; on no-match, AUTHOR author a new recipe | v EXECUTE run the plan; fan out parallel groups; <- sequencing + sub-routine calls (w/loops) recurse sub-recipes; loop steps | v OBSERVE render provenance, step progress, <- metacognitive monitoring subagent vitals to RECIPES panel | v ADAPT reflect; tune effort & recipes for <- learning + regulation next turn | v response to user ```+}"
  },
  {
   "section": "2.1 The cycle",
   "old": null,
   "new": "**Figure 1 (described in §11).** The five-phase executive cycle, annotated with the executive function each phase implements.",
   "marked": "{+**Figure 1 (described in §11).** The five-phase executive cycle, annotated with the executive function each phase implements.+}"
  },
  {
   "section": "2.1 The cycle",
   "old": null,
   "new": "A defining design choice: the EXECUTE phase uses *the same agent* as the worker. PREFRONTAL does not introduce a separate \"manager agent\" with its own personality and its own context. It seeds structure — a plan — and lets the worker run inside it. This preserves the property that makes language agents valuable (open-ended competence) while adding the property that makes them reliable (a default path of thoroughness). The recipe is a track, not a cage: the worker can deviate from a step when it can justify the deviation, because the gates are evaluated by judgement, not by a state machine.",
   "marked": "{+A defining design choice: the EXECUTE phase uses *the same agent* as the worker. PREFRONTAL does not introduce a separate \"manager agent\" with its own personality and its own context. It seeds structure — a plan — and lets the worker run inside it. This preserves the property that makes language agents valuable (open-ended competence) while adding the property that makes them reliable (a default path of thoroughness). The recipe is a track, not a cage: the worker can deviate from a step when it can justify the deviation, because the gates are evaluated by judgement, not by a state machine.+}"
  },
  {
   "section": "2.2 Where the structure comes from, and when it is cheap",
   "old": null,
   "new": "### 2.2 Where the structure comes from, and when it is cheap",
   "marked": "{+### 2.2 Where the structure comes from, and when it is cheap+}"
  },
  {
   "section": "2.2 Where the structure comes from, and when it is cheap",
   "old": null,
   "new": "The substrate is engineered so that the executive overhead is near-free for the common case and is *only* spent where it pays. Three mechanisms make this true.",
   "marked": "{+The substrate is engineered so that the executive overhead is near-free for the common case and is *only* spent where it pays. Three mechanisms make this true.+}"
  },
  {
   "section": "2.2 Where the structure comes from, and when it is cheap",
   "old": null,
   "new": "First, **matching is local and lazy.** Task-set selection runs at the very start of every turn against an in-memory index of recipe metadata, cached and invalidated by the recipe directory's modification time. There is no network call and no model call on this hot path; the scorer is a few hundred microseconds of token arithmetic. A plan is therefore seeded *before* the worker's first token, at negligible cost.",
   "marked": "{+First, **matching is local and lazy.** Task-set selection runs at the very start of every turn against an in-memory index of recipe metadata, cached and invalidated by the recipe directory's modification time. There is no network call and no model call on this hot path; the scorer is a few hundred microseconds of token arithmetic. A plan is therefore seeded *before* the worker's first token, at negligible cost.+}"
  },
  {
   "section": "2.2 Where the structure comes from, and when it is cheap",
   "old": null,
   "new": "Second, **effort routing gates depth.** A trivial turn (\"thanks,\" \"what time is it\") is classified as trivial and the substrate stays out of the way entirely — no plan injection, no extra reasoning, minimal tokens. The machinery of the cycle is only fully engaged when the turn warrants it. This is the analogue of the cortex spending metabolic budget proportional to task difficulty rather than firing at full intensity for every stimulus.",
   "marked": "{+Second, **effort routing gates depth.** A trivial turn (\"thanks,\" \"what time is it\") is classified as trivial and the substrate stays out of the way entirely — no plan injection, no extra reasoning, minimal tokens. The machinery of the cycle is only fully engaged when the turn warrants it. This is the analogue of the cortex spending metabolic budget proportional to task difficulty rather than firing at full intensity for every stimulus.+}"
  },
  {
   "section": "2.2 Where the structure comes from, and when it is cheap",
   "old": null,
   "new": "Third, **follow-up cognition reuses context.** When a phase does require a model call (a reflection pass, or a tiebreak judge when two recipes score within a hair of each other), that call shares almost the entire context of the main turn — the same identity, the same retrieved memory, the same conversation. Under context-caching pricing, a follow-up call that differs only in its instruction costs a small fraction of a fresh call. The question therefore shifts from \"can we afford an executive layer?\" to \"can we afford to run without one?\"",
   "marked": "{+Third, **follow-up cognition reuses context.** When a phase does require a model call (a reflection pass, or a tiebreak judge when two recipes score within a hair of each other), that call shares almost the entire context of the main turn — the same identity, the same retrieved memory, the same conversation. Under context-caching pricing, a follow-up call that differs only in its instruction costs a small fraction of a fresh call. The question therefore shifts from \"can we afford an executive layer?\" to \"can we afford to run without one?\"+}"
  },
  {
   "section": "2.3 Plans as the runtime trace of recipes",
   "old": null,
   "new": "### 2.3 Plans as the runtime trace of recipes",
   "marked": "{+### 2.3 Plans as the runtime trace of recipes+}"
  },
  {
   "section": "2.3 Plans as the runtime trace of recipes",
   "old": null,
   "new": "A recipe is a template; a **plan** is the instance of one recipe (or several, merged) executing inside a specific session. The plan is a persisted, structured document: it records which recipe(s) seeded it, the ordered steps, and the live status of each step (`pending → in_progress → done | error`). A single invariant governs it: *at most one step is `in_progress` at a time per plan*, enforced by the store rather than by the caller, so the executive's working-memory \"cursor\" is always unambiguous.",
   "marked": "{+A recipe is a template; a **plan** is the instance of one recipe (or several, merged) executing inside a specific session. The plan is a persisted, structured document: it records which recipe(s) seeded it, the ordered steps, and the live status of each step (`pending → in_progress → done | error`). A single invariant governs it: *at most one step is `in_progress` at a time per plan*, enforced by the store rather than by the caller, so the executive's working-memory \"cursor\" is always unambiguous.+}"
  },
  {
   "section": "2.3 Plans as the runtime trace of recipes",
   "old": null,
   "new": "Because the plan is persisted and seeded automatically at turn start, the substrate gains crash-resilience almost for free: if the process restarts mid-task, there is an `in_progress` plan on disk describing exactly where the work was, and the executive can resume from it rather than re-deriving intent from scratch. The plan *is* the agent's working memory, externalised.",
   "marked": "{+Because the plan is persisted and seeded automatically at turn start, the substrate gains crash-resilience almost for free: if the process restarts mid-task, there is an `in_progress` plan on disk describing exactly where the work was, and the executive can resume from it rather than re-deriving intent from scratch. The plan *is* the agent's working memory, externalised.+}"
  },
  {
   "section": "3. The Recipe System",
   "old": "## 3. The Recipe System",
   "new": null,
   "marked": "[-## 3. The Recipe System-]"
  },
  {
   "section": "3.1 Recipe Format",
   "old": "### 3.1 Recipe Format",
   "new": null,
   "marked": "[-### 3.1 Recipe Format-]"
  },
  {
   "section": "3.1 Recipe Format",
   "old": "A recipe is a structured markdown document with the following schema:",
   "new": null,
   "marked": "[-A recipe is a structured markdown document with the following schema:-]"
  },
  {
   "section": "3.1 Recipe Format",
   "old": "```markdown # Recipe: debug",
   "new": null,
   "marked": "[-```markdown # Recipe: debug-]"
  },
  {
   "section": "Metadata - intent: bug-fix, error-investigation, crash-analysis - complexity: medium - estimated-duration: 5-15 minutes - models: [sonnet, opus]",
   "old": "## Metadata - intent: bug-fix, error-investigation, crash-analysis - complexity: medium - estimated-duration: 5-15 minutes - models: [sonnet, opus]",
   "new": null,
   "marked": "[-## Metadata - intent: bug-fix, error-investigation, crash-analysis - complexity: medium - estimated-duration: 5-15 minutes - models: [sonnet, opus]-]"
  },
  {
   "section": "Preconditions - [ ] Error report or symptom description available - [ ] Repository context loaded",
   "old": "## Preconditions - [ ] Error report or symptom description available - [ ] Repository context loaded",
   "new": null,
   "marked": "[-## Preconditions - [ ] Error report or symptom description available - [ ] Repository context loaded-]"
  },
  {
   "section": "Steps",
   "old": "## Steps",
   "new": null,
   "marked": "[-## Steps-]"
  },
  {
   "section": "Step 1: Reproduce Confirm the bug exists. Run the failing command, check logs, verify the symptom. - tools: [Bash, Read] - gate: Must have confirmed reproduction before proceeding.",
   "old": "### Step 1: Reproduce Confirm the bug exists. Run the failing command, check logs, verify the symptom. - tools: [Bash, Read] - gate: Must have confirmed reproduction before proceeding.",
   "new": null,
   "marked": "[-### Step 1: Reproduce Confirm the bug exists. Run the failing command, check logs, verify the symptom. - tools: [Bash, Read] - gate: Must have confirmed reproduction before proceeding.-]"
  },
  {
   "section": "Step 2: Locate Find the root cause. Search the codebase, read stack traces, trace the execution path. - tools: [Grep, Glob, Read] - gate: Must have identified a specific file and line range.",
   "old": "### Step 2: Locate Find the root cause. Search the codebase, read stack traces, trace the execution path. - tools: [Grep, Glob, Read] - gate: Must have identified a specific file and line range.",
   "new": null,
   "marked": "[-### Step 2: Locate Find the root cause. Search the codebase, read stack traces, trace the execution path. - tools: [Grep, Glob, Read] - gate: Must have identified a specific file and line range.-]"
  },
  {
   "section": "Step 3: Understand Read the surrounding code. Understand the intent, the constraints, the history. - tools: [Read, Bash(git log)] - gate: Must articulate why the current code is wrong.",
   "old": "### Step 3: Understand Read the surrounding code. Understand the intent, the constraints, the history. - tools: [Read, Bash(git log)] - gate: Must articulate why the current code is wrong.",
   "new": null,
   "marked": "[-### Step 3: Understand Read the surrounding code. Understand the intent, the constraints, the history. - tools: [Read, Bash(git log)] - gate: Must articulate why the current code is wrong.-]"
  },
  {
   "section": "Step 4: Fix Implement the minimal fix. Change only what is necessary. - tools: [Edit, Write] - gate: Fix must be consistent with the root cause from Step 2.",
   "old": "### Step 4: Fix Implement the minimal fix. Change only what is necessary. - tools: [Edit, Write] - gate: Fix must be consistent with the root cause from Step 2.",
   "new": null,
   "marked": "[-### Step 4: Fix Implement the minimal fix. Change only what is necessary. - tools: [Edit, Write] - gate: Fix must be consistent with the root cause from Step 2.-]"
  },
  {
   "section": "Step 5: Verify Run tests. Check that the fix works and nothing else broke. - tools: [Bash] - gate: All relevant tests must pass.",
   "old": "### Step 5: Verify Run tests. Check that the fix works and nothing else broke. - tools: [Bash] - gate: All relevant tests must pass.",
   "new": null,
   "marked": "[-### Step 5: Verify Run tests. Check that the fix works and nothing else broke. - tools: [Bash] - gate: All relevant tests must pass.-]"
  },
  {
   "section": "Step 6: Document Update any affected documentation, comments, or memory files. - tools: [Edit, Write] - gate: No stale documentation remains.",
   "old": "### Step 6: Document Update any affected documentation, comments, or memory files. - tools: [Edit, Write] - gate: No stale documentation remains.",
   "new": null,
   "marked": "[-### Step 6: Document Update any affected documentation, comments, or memory files. - tools: [Edit, Write] - gate: No stale documentation remains.-]"
  },
  {
   "section": "Success Criteria - Bug is fixed and verified by test - Root cause is documented - No regressions introduced",
   "old": "## Success Criteria - Bug is fixed and verified by test - Root cause is documented - No regressions introduced",
   "new": null,
   "marked": "[-## Success Criteria - Bug is fixed and verified by test - Root cause is documented - No regressions introduced-]"
  },
  {
   "section": "Failure Handlers - Step 1 fails (cannot reproduce): Gather more information from user - Step 4 fails (fix too complex): Escalate to user with analysis - Step 5 fails (tests break): Revert and re-analyse ```",
   "old": "## Failure Handlers - Step 1 fails (cannot reproduce): Gather more information from user - Step 4 fails (fix too complex): Escalate to user with analysis - Step 5 fails (tests break): Revert and re-analyse ```",
   "new": null,
   "marked": "[-## Failure Handlers - Step 1 fails (cannot reproduce): Gather more information from user - Step 4 fails (fix too complex): Escalate to user with analysis - Step 5 fails (tests break): Revert and re-analyse ```-]"
  },
  {
   "section": "Failure Handlers - Step 1 fails (cannot reproduce): Gather more information from user - Step 4 fails (fix too complex): Escalate to user with analysis - Step 5 fails (tests break): Revert and re-analyse ```",
   "old": "Recipes are human-readable markdown files, editable, storable in memory, and versionable via git, favouring transparency and composability.",
   "new": null,
   "marked": "[-Recipes are human-readable markdown files, editable, storable in memory, and versionable via git, favouring transparency and composability.-]"
  },
  {
   "section": "3.2 Built-in Recipes",
   "old": "### 3.2 Built-in Recipes",
   "new": null,
   "marked": "[-### 3.2 Built-in Recipes-]"
  },
  {
   "section": "3.2 Built-in Recipes",
   "old": "Prefrontal v3.1 ships with six built-in recipes covering the most common agent tasks:",
   "new": null,
   "marked": "[-Prefrontal v3.1 ships with six built-in recipes covering the most common agent tasks:-]"
  },
  {
   "section": "3.2 Built-in Recipes",
   "old": "| Recipe | Steps | Typical Duration | Key Insight | |--------|-------|-----------------|-------------| | **debug** | 6 (reproduce, locate, understand, fix, verify, document) | 5--15 min | Must reproduce before fixing | | **feature** | 7 (clarify, design, plan, implement, test, verify, document) | 10--30 min | Must design before implementing | | **investigate** | 5 (scope, search, analyse, synthesise, report) | 5--20 min | Must scope before searching | | **refactor** | 6 (identify, measure, plan, execute, verify, document) | 10--25 min | Must measure before changing | | **review** | 5 (overview, deep-read, test, assess, report) | 5--15 min | Must read completely before opining | | **deploy** | 7 (pre-check, build, test, stage, verify, promote, post-check) | 10--40 min | Must verify at every stage |",
   "new": null,
   "marked": "[-| Recipe | Steps | Typical Duration | Key Insight | |--------|-------|-----------------|-------------| | **debug** | 6 (reproduce, locate, understand, fix, verify, document) | 5--15 min | Must reproduce before fixing | | **feature** | 7 (clarify, design, plan, implement, test, verify, document) | 10--30 min | Must design before implementing | | **investigate** | 5 (scope, search, analyse, synthesise, report) | 5--20 min | Must scope before searching | | **refactor** | 6 (identify, measure, plan, execute, verify, document) | 10--25 min | Must measure before changing | | **review** | 5 (overview, deep-read, test, assess, report) | 5--15 min | Must read completely before opining | | **deploy** | 7 (pre-check, build, test, stage, verify, promote, post-check) | 10--40 min | Must verify at every stage |-]"
  },
  {
   "section": "3.2 Built-in Recipes",
   "old": "Each recipe encodes hard-won operational lessons. The debug recipe's \"reproduce before fixing\" step prevents the most common agent failure mode: jumping directly to a code change based on the error message without confirming the bug's actual behaviour. The feature recipe's \"design before implementing\" step prevents premature coding --- the anti-gold-plating principle elevated from a prompt injection to a structural gate.",
   "new": null,
   "marked": "[-Each recipe encodes hard-won operational lessons. The debug recipe's \"reproduce before fixing\" step prevents the most common agent failure mode: jumping directly to a code change based on the error message without confirming the bug's actual behaviour. The feature recipe's \"design before implementing\" step prevents premature coding --- the anti-gold-plating principle elevated from a prompt injection to a structural gate.-]"
  },
  {
   "section": "3.3 Custom Recipes",
   "old": "### 3.3 Custom Recipes",
   "new": null,
   "marked": "[-### 3.3 Custom Recipes-]"
  },
  {
   "section": "3.3 Custom Recipes",
   "old": "Users can author domain-specific recipes and add them to the recipe library. A data-science team might add recipes for \"explore-dataset,\" \"train-model,\" and \"evaluate-results.\" A DevOps team might add \"incident-response,\" \"capacity-planning,\" and \"runbook-execution.\"",
   "new": null,
   "marked": "[-Users can author domain-specific recipes and add them to the recipe library. A data-science team might add recipes for \"explore-dataset,\" \"train-model,\" and \"evaluate-results.\" A DevOps team might add \"incident-response,\" \"capacity-planning,\" and \"runbook-execution.\"-]"
  },
  {
   "section": "3.3 Custom Recipes",
   "old": "Custom recipes are stored in the memory hierarchy (under `memory/recipes/`) and are automatically available to Prefrontal's recipe selection. This makes the recipe library a *growing* asset --- each new recipe captures operational knowledge that compounds across future sessions, extending the compounding thesis from individual lessons (v2.4) to entire workflows (v3.1).",
   "new": null,
   "marked": "[-Custom recipes are stored in the memory hierarchy (under `memory/recipes/`) and are automatically available to Prefrontal's recipe selection. This makes the recipe library a *growing* asset --- each new recipe captures operational knowledge that compounds across future sessions, extending the compounding thesis from individual lessons (v2.4) to entire workflows (v3.1).-]"
  },
  {
   "section": "3.4 Recipe Selection",
   "old": "### 3.4 Recipe Selection",
   "new": null,
   "marked": "[-### 3.4 Recipe Selection-]"
  },
  {
   "section": "3.4 Recipe Selection",
   "old": "When a user message arrives, Prefrontal classifies the intent and selects the appropriate recipe through a three-tier strategy:",
   "new": null,
   "marked": "[-When a user message arrives, Prefrontal classifies the intent and selects the appropriate recipe through a three-tier strategy:-]"
  },
  {
   "section": "3.4 Recipe Selection",
   "old": "1. **Keyword matching**: explicit signals in the message (\"fix this bug\" -> debug, \"add a feature\" -> feature, \"what's going on with\" -> investigate). Fast, cheap, handles the common cases.",
   "new": null,
   "marked": "[-1. **Keyword matching**: explicit signals in the message (\"fix this bug\" -> debug, \"add a feature\" -> feature, \"what's going on with\" -> investigate). Fast, cheap, handles the common cases.-]"
  },
  {
   "section": "3.4 Recipe Selection",
   "old": "2. **Structure analysis**: message length, presence of error messages or stack traces, code blocks, file paths. A message with a stack trace is likely a debug task even if it does not contain the word \"bug.\"",
   "new": null,
   "marked": "[-2. **Structure analysis**: message length, presence of error messages or stack traces, code blocks, file paths. A message with a stack trace is likely a debug task even if it does not contain the word \"bug.\"-]"
  },
  {
   "section": "3.4 Recipe Selection",
   "old": "3. **LLM classification**: for ambiguous messages, Prefrontal's LLM call includes recipe metadata (intent keywords, descriptions) and selects the best match. This is the same call that performs the orchestration, so it incurs no additional cost.",
   "new": null,
   "marked": "[-3. **LLM classification**: for ambiguous messages, Prefrontal's LLM call includes recipe metadata (intent keywords, descriptions) and selects the best match. This is the same call that performs the orchestration, so it incurs no additional cost.-]"
  },
  {
   "section": "3.4 Recipe Selection",
   "old": "Unstructured messages bypass orchestration.",
   "new": null,
   "marked": "[-Unstructured messages bypass orchestration.-]"
  },
  {
   "section": "3.5 Step Enforcement",
   "old": "### 3.5 Step Enforcement",
   "new": null,
   "marked": "[-### 3.5 Step Enforcement-]"
  },
  {
   "section": "3.5 Step Enforcement",
   "old": "Each recipe step includes a **gate** --- a condition that must be satisfied before the agent proceeds to the next step. Gates are expressed in natural language and evaluated by the orchestrator:",
   "new": null,
   "marked": "[-Each recipe step includes a **gate** --- a condition that must be satisfied before the agent proceeds to the next step. Gates are expressed in natural language and evaluated by the orchestrator:-]"
  },
  {
   "section": "3.5 Step Enforcement",
   "old": "- *\"Must have confirmed reproduction before proceeding\"* --- Prefrontal checks whether the subagent's output includes evidence of reproduction (a failing test, a reproduced error message, a confirmed symptom). - *\"Must have identified a specific file and line range\"* --- Prefrontal checks for file paths and line numbers in the investigation output.",
   "new": null,
   "marked": "[-- *\"Must have confirmed reproduction before proceeding\"* --- Prefrontal checks whether the subagent's output includes evidence of reproduction (a failing test, a reproduced error message, a confirmed symptom). - *\"Must have identified a specific file and line range\"* --- Prefrontal checks for file paths and line numbers in the investigation output.-]"
  },
  {
   "section": "3.5 Step Enforcement",
   "old": "Gates are advisory, not absolute. If a subagent presents a compelling case for skipping a step (\"the bug is obvious from the error message, reproduction is unnecessary\"), Prefrontal can grant an exception. The enforcement is structural --- it creates a default path of thoroughness that requires explicit justification to deviate from, rather than a rigid pipeline that breaks on edge cases.",
   "new": null,
   "marked": "[-Gates are advisory, not absolute. If a subagent presents a compelling case for skipping a step (\"the bug is obvious from the error message, reproduction is unnecessary\"), Prefrontal can grant an exception. The enforcement is structural --- it creates a default path of thoroughness that requires explicit justification to deviate from, rather than a rigid pipeline that breaks on edge cases.-]"
  },
  {
   "section": "3.5 Step Enforcement",
   "old": "This is the critical difference between a recipe and a script. A script executes mechanically; a recipe provides structure that an intelligent agent can follow, adapt, or override with justification.",
   "new": null,
   "marked": "[-This is the critical difference between a recipe and a script. A script executes mechanically; a recipe provides structure that an intelligent agent can follow, adapt, or override with justification.-]"
  },
  {
   "section": "3. Capability 1 — Recipe Matching (Task-Set Selection)",
   "old": null,
   "new": "## 3. Capability 1 — Recipe Matching (Task-Set Selection)",
   "marked": "{+## 3. Capability 1 — Recipe Matching (Task-Set Selection)+}"
  },
  {
   "section": "3.1 The problem with literal matching",
   "old": null,
   "new": "### 3.1 The problem with literal matching",
   "marked": "{+### 3.1 The problem with literal matching+}"
  },
  {
   "section": "3.1 The problem with literal matching",
   "old": null,
   "new": "The naïve approach to recipe selection is keyword matching: if the message contains \"bug,\" select the debug recipe. It is brittle in exactly the way human task recognition is not. A person reading \"the build keeps dying after I touched the config\" instantly recognises a debugging situation; a literal matcher sees no shared token with a recipe tagged `bug, error, crash` and silently selects nothing. Worse, a silent non-selection is invisible: the agent proceeds with no program, and no one knows the executive failed to engage.",
   "marked": "{+The naïve approach to recipe selection is keyword matching: if the message contains \"bug,\" select the debug recipe. It is brittle in exactly the way human task recognition is not. A person reading \"the build keeps dying after I touched the config\" instantly recognises a debugging situation; a literal matcher sees no shared token with a recipe tagged `bug, error, crash` and silently selects nothing. Worse, a silent non-selection is invisible: the agent proceeds with no program, and no one knows the executive failed to engage.+}"
  },
  {
   "section": "3.2 Fuzzy, stemmed, edit-distance scoring",
   "old": null,
   "new": "### 3.2 Fuzzy, stemmed, edit-distance scoring",
   "marked": "{+### 3.2 Fuzzy, stemmed, edit-distance scoring+}"
  },
  {
   "section": "3.2 Fuzzy, stemmed, edit-distance scoring",
   "old": null,
   "new": "The matcher tokenises the prompt (lower-casing, dropping stop-words and very short tokens) and scores each recipe's metadata against those tokens with a graduated notion of \"match\" that tolerates the ways natural language varies:",
   "marked": "{+The matcher tokenises the prompt (lower-casing, dropping stop-words and very short tokens) and scores each recipe's metadata against those tokens with a graduated notion of \"match\" that tolerates the ways natural language varies:+}"
  },
  {
   "section": "3.2 Fuzzy, stemmed, edit-distance scoring",
   "old": null,
   "new": "- **Exact equality** (\"debug\" == \"debug\"). - **Shared stem** after stripping common English inflections, so *debugging*, *debugged*, *debugger* all reduce to the same root as *debug*. - **Prefix overlap** for tokens of reasonable length, so *configuration* matches *config*. - **Edit-distance-1** on the stemmed forms for longer tokens, absorbing typos and minor morphological drift.",
   "marked": "{+- **Exact equality** (\"debug\" == \"debug\"). - **Shared stem** after stripping common English inflections, so *debugging*, *debugged*, *debugger* all reduce to the same root as *debug*. - **Prefix overlap** for tokens of reasonable length, so *configuration* matches *config*. - **Edit-distance-1** on the stemmed forms for longer tokens, absorbing typos and minor morphological drift.+}"
  },
  {
   "section": "3.2 Fuzzy, stemmed, edit-distance scoring",
   "old": null,
   "new": "The graduation matters: tiny tokens are matched only by equality (to avoid spurious hits), while longer tokens earn the looser rules. Scoring is weighted by *where* the match lands: a hit against a recipe's hand-curated trigger tags counts most, a hit in the title less, a hit in the summary least. Multi-word tags match as phrases; single-word tags and title/summary words match fuzzily.",
   "marked": "{+The graduation matters: tiny tokens are matched only by equality (to avoid spurious hits), while longer tokens earn the looser rules. Scoring is weighted by *where* the match lands: a hit against a recipe's hand-curated trigger tags counts most, a hit in the title less, a hit in the summary least. Multi-word tags match as phrases; single-word tags and title/summary words match fuzzily.+}"
  },
  {
   "section": "3.2 Fuzzy, stemmed, edit-distance scoring",
   "old": null,
   "new": "``` function SCORE_RECIPE(prompt_tokens, recipe): score <- 0 for tag in recipe.tags: if tag is multi-word: if prompt contains tag as a phrase: score += 5 else if any prompt token equals tag: score += 3 else if any prompt token FUZZY-MATCHES tag: score += 2 for word in tokens(recipe.title): if any prompt token equals word: score += 2 else if any prompt token FUZZY-MATCHES word: score += 1 for word in tokens(recipe.summary): if any prompt token FUZZY-MATCHES word: score += 1 return score",
   "marked": "{+``` function SCORE_RECIPE(prompt_tokens, recipe): score <- 0 for tag in recipe.tags: if tag is multi-word: if prompt contains tag as a phrase: score += 5 else if any prompt token equals tag: score += 3 else if any prompt token FUZZY-MATCHES tag: score += 2 for word in tokens(recipe.title): if any prompt token equals word: score += 2 else if any prompt token FUZZY-MATCHES word: score += 1 for word in tokens(recipe.summary): if any prompt token FUZZY-MATCHES word: score += 1 return score+}"
  },
  {
   "section": "3.2 Fuzzy, stemmed, edit-distance scoring",
   "old": null,
   "new": "function FUZZY-MATCH(a, b): return a == b or (stem(a) == stem(b) and len >= 3) or (len(a),len(b) >= 4 and one is a prefix of the other) or (len(a),len(b) >= 5 and edit_distance(stem(a), stem(b)) <= 1) ```",
   "marked": "{+function FUZZY-MATCH(a, b): return a == b or (stem(a) == stem(b) and len >= 3) or (len(a),len(b) >= 4 and one is a prefix of the other) or (len(a),len(b) >= 5 and edit_distance(stem(a), stem(b)) <= 1) ```+}"
  },
  {
   "section": "3.3 Confidence tiers and what they gate",
   "old": null,
   "new": "### 3.3 Confidence tiers and what they gate",
   "marked": "{+### 3.3 Confidence tiers and what they gate+}"
  },
  {
   "section": "3.3 Confidence tiers and what they gate",
   "old": null,
   "new": "Raw scores are reduced to a **confidence tier** — `none`, `low`, or `high` — because the executive needs to behave differently depending on how sure it is, just as a person hesitates before committing to an ambiguous task framing:",
   "marked": "{+Raw scores are reduced to a **confidence tier** — `none`, `low`, or `high` — because the executive needs to behave differently depending on how sure it is, just as a person hesitates before committing to an ambiguous task framing:+}"
  },
  {
   "section": "3.3 Confidence tiers and what they gate",
   "old": null,
   "new": "``` function CLASSIFY_CONFIDENCE(matches, threshold): if matches is empty: return \"none\" top <- matches[0].score second <- matches[1].score or 0 if top >= threshold + 3 and top - second >= 2: return \"high\" # clear leader return \"low\" # barely over, or a tie ```",
   "marked": "{+``` function CLASSIFY_CONFIDENCE(matches, threshold): if matches is empty: return \"none\" top <- matches[0].score second <- matches[1].score or 0 if top >= threshold + 3 and top - second >= 2: return \"high\" # clear leader return \"low\" # barely over, or a tie ```+}"
  },
  {
   "section": "3.3 Confidence tiers and what they gate",
   "old": null,
   "new": "- **High** confidence: a clear leader well above the bar. Seed the plan silently and proceed. - **Low** confidence: barely over the bar, or a near-tie among candidates. Seed the best, but surface the alternatives; optionally break the tie with a short, context-shared judge call. - **None**: nothing clears the bar. This is not a dead end — it is the *authoring opportunity* (Section 5).",
   "marked": "{+- **High** confidence: a clear leader well above the bar. Seed the plan silently and proceed. - **Low** confidence: barely over the bar, or a near-tie among candidates. Seed the best, but surface the alternatives; optionally break the tie with a short, context-shared judge call. - **None**: nothing clears the bar. This is not a dead end — it is the *authoring opportunity* (Section 5).+}"
  },
  {
   "section": "3.4 Auto-seeding at turn start",
   "old": null,
   "new": "### 3.4 Auto-seeding at turn start",
   "marked": "{+### 3.4 Auto-seeding at turn start+}"
  },
  {
   "section": "3.4 Auto-seeding at turn start",
   "old": null,
   "new": "The matcher runs automatically as a turn-start hook, not on the agent's initiative. This is deliberate: an executive function that must be *remembered* is an executive function that fails under load. The hook scores the prompt, builds a plan from the matched recipe(s), and persists it — with one inviolable rule: **it never clobbers an existing `in_progress` plan.** An explicit plan, or one carried over from a prior turn, always wins over a fresh auto-seed. Trivial and conversational turns (and re-injected completion signals) are filtered out before scoring, so the executive engages exactly when there is a program worth running.",
   "marked": "{+The matcher runs automatically as a turn-start hook, not on the agent's initiative. This is deliberate: an executive function that must be *remembered* is an executive function that fails under load. The hook scores the prompt, builds a plan from the matched recipe(s), and persists it — with one inviolable rule: **it never clobbers an existing `in_progress` plan.** An explicit plan, or one carried over from a prior turn, always wins over a fresh auto-seed. Trivial and conversational turns (and re-injected completion signals) are filtered out before scoring, so the executive engages exactly when there is a program worth running.+}"
  },
  {
   "section": "3.4 Auto-seeding at turn start",
   "old": null,
   "new": "The accumulating record of *which prompts produce no match* is itself a signal: a class of prompts that repeatedly fails to match means the library is too thin, the work has drifted into new territory, or it is time to author. Mining that signal is how the library grows — and Section 5 makes the growth automatic.",
   "marked": "{+The accumulating record of *which prompts produce no match* is itself a signal: a class of prompts that repeatedly fails to match means the library is too thin, the work has drifted into new territory, or it is time to author. Mining that signal is how the library grows — and Section 5 makes the growth automatic.+}"
  },
  {
   "section": "4. The Cognitive Cycle (Complete)",
   "old": "## 4. The Cognitive Cycle (Complete)",
   "new": null,
   "marked": "[-## 4. The Cognitive Cycle (Complete)-]"
  },
  {
   "section": "4. The Cognitive Cycle (Complete)",
   "old": "Version 2.4 acknowledged that its architecture captured \"only the second half\" of the cognitive cycle --- post-action reflection without pre-action planning. GStack's forcing questions (Tan, 2026) demonstrated the value of pre-action reflection, and we incorporated a minimal version (five forcing questions for complex tasks). But forcing questions are not planning --- they refine intent without producing a structured execution strategy.",
   "new": null,
   "marked": "[-Version 2.4 acknowledged that its architecture captured \"only the second half\" of the cognitive cycle --- post-action reflection without pre-action planning. GStack's forcing questions (Tan, 2026) demonstrated the value of pre-action reflection, and we incorporated a minimal version (five forcing questions for complex tasks). But forcing questions are not planning --- they refine intent without producing a structured execution strategy.-]"
  },
  {
   "section": "4. The Cognitive Cycle (Complete)",
   "old": "Version 3.0 completes the cycle.",
   "new": null,
   "marked": "[-Version 3.0 completes the cycle.-]"
  },
  {
   "section": "4.1 Pre-Action: From Questions to Recipes",
   "old": "### 4.1 Pre-Action: From Questions to Recipes",
   "new": null,
   "marked": "[-### 4.1 Pre-Action: From Questions to Recipes-]"
  },
  {
   "section": "4.1 Pre-Action: From Questions to Recipes",
   "old": "The pre-action phase now encompasses:",
   "new": null,
   "marked": "[-The pre-action phase now encompasses:-]"
  },
  {
   "section": "4.1 Pre-Action: From Questions to Recipes",
   "old": "1. **Forcing questions** (retained from v2.4): What is the user *actually* asking? What would a wrong answer look like? What constraints exist? These questions refine intent.",
   "new": null,
   "marked": "[-1. **Forcing questions** (retained from v2.4): What is the user *actually* asking? What would a wrong answer look like? What constraints exist? These questions refine intent.-]"
  },
  {
   "section": "4.1 Pre-Action: From Questions to Recipes",
   "old": "2. **Recipe selection**: based on the refined intent, Prefrontal selects or composes an appropriate recipe. For standard tasks, this means choosing from the built-in library. For novel tasks, Prefrontal composes an ad hoc recipe by combining steps from multiple templates.",
   "new": null,
   "marked": "[-2. **Recipe selection**: based on the refined intent, Prefrontal selects or composes an appropriate recipe. For standard tasks, this means choosing from the built-in library. For novel tasks, Prefrontal composes an ad hoc recipe by combining steps from multiple templates.-]"
  },
  {
   "section": "4.1 Pre-Action: From Questions to Recipes",
   "old": "3. **Plan presentation**: for complex tasks (estimated duration >5 minutes or >3 steps), Prefrontal presents the plan to the user before execution. This allows user redirection and creates an execution contract.",
   "new": null,
   "marked": "[-3. **Plan presentation**: for complex tasks (estimated duration >5 minutes or >3 steps), Prefrontal presents the plan to the user before execution. This allows user redirection and creates an execution contract.-]"
  },
  {
   "section": "4.1 Pre-Action: From Questions to Recipes",
   "old": "4. **Subagent allocation**: Prefrontal assigns recipe steps to subagents, selecting appropriate models for each (Haiku for simple searches, Sonnet for implementation, Opus for complex reasoning). This operationalises the adaptive effort routing from v2.4 at the recipe level.",
   "new": null,
   "marked": "[-4. **Subagent allocation**: Prefrontal assigns recipe steps to subagents, selecting appropriate models for each (Haiku for simple searches, Sonnet for implementation, Opus for complex reasoning). This operationalises the adaptive effort routing from v2.4 at the recipe level.-]"
  },
  {
   "section": "4.2 During-Action: Supervised Execution",
   "old": "### 4.2 During-Action: Supervised Execution",
   "new": null,
   "marked": "[-### 4.2 During-Action: Supervised Execution-]"
  },
  {
   "section": "4.2 During-Action: Supervised Execution",
   "old": "The during-action phase is entirely new. Version 2.4 had no mechanism for monitoring agent execution in progress --- the agent ran, and the reflection reviewed the outcome. Version 3.0 introduces:",
   "new": null,
   "marked": "[-The during-action phase is entirely new. Version 2.4 had no mechanism for monitoring agent execution in progress --- the agent ran, and the reflection reviewed the outcome. Version 3.0 introduces:-]"
  },
  {
   "section": "4.2 During-Action: Supervised Execution",
   "old": "- **Progress & Updates**: Subagents emit structured events. Prefrontal updates the UI, showing active steps and progress. - **Stall detection**: Prefrontal detects stalls (timeouts, retry loops) and intervenes by reassigning or providing context. - **Cross-subagent coordination**: Prefrontal relays critical findings between parallel subagents to prevent wasted effort.",
   "new": null,
   "marked": "[-- **Progress & Updates**: Subagents emit structured events. Prefrontal updates the UI, showing active steps and progress. - **Stall detection**: Prefrontal detects stalls (timeouts, retry loops) and intervenes by reassigning or providing context. - **Cross-subagent coordination**: Prefrontal relays critical findings between parallel subagents to prevent wasted effort.-]"
  },
  {
   "section": "4.3 Post-Action: Fractal Reflection, Orchestrated",
   "old": "### 4.3 Post-Action: Fractal Reflection, Orchestrated",
   "new": null,
   "marked": "[-### 4.3 Post-Action: Fractal Reflection, Orchestrated-]"
  },
  {
   "section": "4.3 Post-Action: Fractal Reflection, Orchestrated",
   "old": "The post-action phase retains v2.4's fractal reflection protocol (MEMORY, PATTERN, RIPPLE, IMPROVE) but elevates it from a voluntary prompt instruction to an *orchestrated execution*:",
   "new": null,
   "marked": "[-The post-action phase retains v2.4's fractal reflection protocol (MEMORY, PATTERN, RIPPLE, IMPROVE) but elevates it from a voluntary prompt instruction to an *orchestrated execution*:-]"
  },
  {
   "section": "4.3 Post-Action: Fractal Reflection, Orchestrated",
   "old": "1. **Mandatory execution**: Reflection is a distinct, unavoidable LLM call post-completion. 2. **Recipe-aware reflection**: Reflection assesses the turn context, recipe, plan, and execution trace to identify bottlenecks. 3. **Recipe improvement**: Prefrontal updates recipes automatically when systematic issues are identified. 4. **Structured Knowledge**: Extracted lessons are written to memory, deeply tied to their specific recipe context for higher actionability.",
   "new": null,
   "marked": "[-1. **Mandatory execution**: Reflection is a distinct, unavoidable LLM call post-completion. 2. **Recipe-aware reflection**: Reflection assesses the turn context, recipe, plan, and execution trace to identify bottlenecks. 3. **Recipe improvement**: Prefrontal updates recipes automatically when systematic issues are identified. 4. **Structured Knowledge**: Extracted lessons are written to memory, deeply tied to their specific recipe context for higher actionability.-]"
  },
  {
   "section": "4.4 The FRACTAL Pattern: Cache-Shared Follow-Up Calls",
   "old": "### 4.4 The FRACTAL Pattern: Cache-Shared Follow-Up Calls",
   "new": null,
   "marked": "[-### 4.4 The FRACTAL Pattern: Cache-Shared Follow-Up Calls-]"
  },
  {
   "section": "4.4 The FRACTAL Pattern: Cache-Shared Follow-Up Calls",
   "old": "The architectural pattern underlying both the pre-action orchestration and the post-action reflection is what we call the **FRACTAL pattern**: a cache-shared follow-up call with a different role.",
   "new": null,
   "marked": "[-The architectural pattern underlying both the pre-action orchestration and the post-action reflection is what we call the **FRACTAL pattern**: a cache-shared follow-up call with a different role.-]"
  },
  {
   "section": "4.4 The FRACTAL Pattern: Cache-Shared Follow-Up Calls",
   "old": "The fork's `fractal-reflection` extension already implements this pattern for post-action reflection: it makes a second LLM call after each turn, with nearly the same context (exploiting the prompt cache), but with a different instruction (\"reflect on what just happened\" instead of \"execute the user's request\"). Version 3.0 applies the same pattern to pre-action orchestration: a first LLM call with the same context but a different instruction (\"plan how to handle this request\" instead of \"handle this request\").",
   "new": null,
   "marked": "[-The fork's `fractal-reflection` extension already implements this pattern for post-action reflection: it makes a second LLM call after each turn, with nearly the same context (exploiting the prompt cache), but with a different instruction (\"reflect on what just happened\" instead of \"execute the user's request\"). Version 3.0 applies the same pattern to pre-action orchestration: a first LLM call with the same context but a different instruction (\"plan how to handle this request\" instead of \"handle this request\").-]"
  },
  {
   "section": "4.4 The FRACTAL Pattern: Cache-Shared Follow-Up Calls",
   "old": "The FRACTAL pattern applies generally: any cognitive function (planning, reflection, review) can be implemented via cache-shared calls at ~5% marginal cost, enabling multiple perspectives per turn.",
   "new": null,
   "marked": "[-The FRACTAL pattern applies generally: any cognitive function (planning, reflection, review) can be implemented via cache-shared calls at ~5% marginal cost, enabling multiple perspectives per turn.-]"
  },
  {
   "section": "4. Capability 2 — Composition (Recipes Built from Recipes)",
   "old": null,
   "new": "## 4. Capability 2 — Composition (Recipes Built from Recipes)",
   "marked": "{+## 4. Capability 2 — Composition (Recipes Built from Recipes)+}"
  },
  {
   "section": "4. Capability 2 — Composition (Recipes Built from Recipes)",
   "old": null,
   "new": "Hierarchical structure is the hallmark of executive control: complex behaviours are not flat sequences but programs that call sub-programs. The substrate gives recipes two complementary forms of composition, mirroring the two ways code reuses code.",
   "marked": "{+Hierarchical structure is the hallmark of executive control: complex behaviours are not flat sequences but programs that call sub-programs. The substrate gives recipes two complementary forms of composition, mirroring the two ways code reuses code.+}"
  },
  {
   "section": "4.1 Static composition — step-merge (`composes:`)",
   "old": null,
   "new": "### 4.1 Static composition — step-merge (`composes:`)",
   "marked": "{+### 4.1 Static composition — step-merge (`composes:`)+}"
  },
  {
   "section": "4.1 Static composition — step-merge (`composes:`)",
   "old": null,
   "new": "A recipe may declare, in its metadata, that it *composes* other recipes. At plan-build time, the composed recipes' steps are expanded **into** the merged plan ahead of the composing recipe's own steps — so a composite reads as \"do sub-recipe A, then sub-recipe B, then my own steps.\" This is inlining: the sub-recipes' steps become first-class rows in the single resulting plan. Expansion is **cycle-guarded** (a recipe already on the expansion stack is not expanded again) and **depth-bounded**, so a composition graph can never loop forever. Step de-duplication by normalised title keeps a step that appears in two composed recipes from running twice.",
   "marked": "{+A recipe may declare, in its metadata, that it *composes* other recipes. At plan-build time, the composed recipes' steps are expanded **into** the merged plan ahead of the composing recipe's own steps — so a composite reads as \"do sub-recipe A, then sub-recipe B, then my own steps.\" This is inlining: the sub-recipes' steps become first-class rows in the single resulting plan. Expansion is **cycle-guarded** (a recipe already on the expansion stack is not expanded again) and **depth-bounded**, so a composition graph can never loop forever. Step de-duplication by normalised title keeps a step that appears in two composed recipes from running twice.+}"
  },
  {
   "section": "4.1 Static composition — step-merge (`composes:`)",
   "old": null,
   "new": "``` function BUILD_MERGED_PLAN(matches, library): steps <- []; seen <- {}; expanded <- {} function ADD_FROM(recipe, depth): if recipe in expanded or depth > MAX_COMPOSE_DEPTH: return mark recipe expanded for sub_slug in recipe.composes: # composed steps lead ADD_FROM(library[sub_slug], depth + 1) for step in parse_steps(recipe): key <- normalise(step.title) if key not in seen: add step to steps; mark key seen for m in matches: ADD_FROM(m.recipe, 0) return plan(steps) ```",
   "marked": "{+``` function BUILD_MERGED_PLAN(matches, library): steps <- []; seen <- {}; expanded <- {} function ADD_FROM(recipe, depth): if recipe in expanded or depth > MAX_COMPOSE_DEPTH: return mark recipe expanded for sub_slug in recipe.composes: # composed steps lead ADD_FROM(library[sub_slug], depth + 1) for step in parse_steps(recipe): key <- normalise(step.title) if key not in seen: add step to steps; mark key seen for m in matches: ADD_FROM(m.recipe, 0) return plan(steps) ```+}"
  },
  {
   "section": "4.1 Static composition — step-merge (`composes:`)",
   "old": null,
   "new": "This is how a heavyweight workflow (\"ship a paper end-to-end\") is assembled from lighter, independently useful recipes (\"draft,\" \"adversarially verify,\" \"compile\") without copying their steps.",
   "marked": "{+This is how a heavyweight workflow (\"ship a paper end-to-end\") is assembled from lighter, independently useful recipes (\"draft,\" \"adversarially verify,\" \"compile\") without copying their steps.+}"
  },
  {
   "section": "4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "old": null,
   "new": "### 4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "marked": "{+### 4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)+}"
  },
  {
   "section": "4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "old": null,
   "new": "Static merge fixes the program before execution; sometimes a step should *call* another recipe at runtime, the way a function call defers control to a callee. A step whose body opens with a `uses: <recipe>` directive runs that sub-recipe instead of a plain worker dispatch, on a derived child session, and folds its result back as the step's outcome. This is a true call: the sub-recipe has its own plan, its own steps, its own fan-out.",
   "marked": "{+Static merge fixes the program before execution; sometimes a step should *call* another recipe at runtime, the way a function call defers control to a callee. A step whose body opens with a `uses: <recipe>` directive runs that sub-recipe instead of a plain worker dispatch, on a derived child session, and folds its result back as the step's outcome. This is a true call: the sub-recipe has its own plan, its own steps, its own fan-out.+}"
  },
  {
   "section": "4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "old": null,
   "new": "Two safeguards keep recursion safe, exactly as a runtime keeps a call stack from overflowing:",
   "marked": "{+Two safeguards keep recursion safe, exactly as a runtime keeps a call stack from overflowing:+}"
  },
  {
   "section": "4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "old": null,
   "new": "- **Depth cap.** Sub-recipe calls may nest only to a fixed maximum; exceeding it errors the step rather than recursing further. - **Cycle guard.** The chain of recipe references on the current call stack is tracked; a recipe that would re-enter itself (directly or transitively) is refused.",
   "marked": "{+- **Depth cap.** Sub-recipe calls may nest only to a fixed maximum; exceeding it errors the step rather than recursing further. - **Cycle guard.** The chain of recipe references on the current call stack is tracked; a recipe that would re-enter itself (directly or transitively) is refused.+}"
  },
  {
   "section": "4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "old": null,
   "new": "A subtle but important parsing rule guards correctness: only the **consecutive leading directive lines** of a step body are interpreted as directives. A `uses:` mentioned in prose, or shown inside a code fence as an example, does *not* fire. This prevents a documentation example from accidentally triggering a recursive call — the difference between citing a function and calling it.",
   "marked": "{+A subtle but important parsing rule guards correctness: only the **consecutive leading directive lines** of a step body are interpreted as directives. A `uses:` mentioned in prose, or shown inside a code fence as an example, does *not* fire. This prevents a documentation example from accidentally triggering a recursive call — the difference between citing a function and calling it.+}"
  },
  {
   "section": "4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "old": null,
   "new": "``` function EXECUTE_STEP(step, ctx): directives <- leading_directive_lines(step.body) # stop at first prose/blank line sub_ref <- parse_uses(directives) if sub_ref is set: if depth(ctx) >= MAX_USES_DEPTH or sub_ref in ctx.call_chain: return error(\"recursion guard\") result <- RUN_RECIPE(sub_ref, child_session(ctx), chain = ctx.call_chain + [sub_ref]) return done(result.note) else: return dispatch_worker(step) ```",
   "marked": "{+``` function EXECUTE_STEP(step, ctx): directives <- leading_directive_lines(step.body) # stop at first prose/blank line sub_ref <- parse_uses(directives) if sub_ref is set: if depth(ctx) >= MAX_USES_DEPTH or sub_ref in ctx.call_chain: return error(\"recursion guard\") result <- RUN_RECIPE(sub_ref, child_session(ctx), chain = ctx.call_chain + [sub_ref]) return done(result.note) else: return dispatch_worker(step) ```+}"
  },
  {
   "section": "4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)",
   "old": null,
   "new": "Together, `composes:` (inline at build time) and `uses:` (call at run time) give recipes the full reuse vocabulary of a programming language — composition and invocation — with the loop-safety guarantees a substrate must provide.",
   "marked": "{+Together, `composes:` (inline at build time) and `uses:` (call at run time) give recipes the full reuse vocabulary of a programming language — composition and invocation — with the loop-safety guarantees a substrate must provide.+}"
  },
  {
   "section": "5. Integration with Existing Extensions",
   "old": "## 5. Integration with Existing Extensions",
   "new": null,
   "marked": "[-## 5. Integration with Existing Extensions-]"
  },
  {
   "section": "5. Integration with Existing Extensions",
   "old": "Prefrontal v3.1 does not replace the existing extension ecosystem --- it orchestrates it. Each extension retains its autonomous function while gaining a coordination layer.",
   "new": null,
   "marked": "[-Prefrontal v3.1 does not replace the existing extension ecosystem --- it orchestrates it. Each extension retains its autonomous function while gaining a coordination layer.-]"
  },
  {
   "section": "5.1 Total Recall (Memory Retrieval)",
   "old": "### 5.1 Total Recall (Memory Retrieval)",
   "new": null,
   "marked": "[-### 5.1 Total Recall (Memory Retrieval)-]"
  },
  {
   "section": "5.1 Total Recall (Memory Retrieval)",
   "old": "Total Recall provides the hybrid retrieval system (semantic search via local embeddings + structured search via filename patterns) that supplies context to every agent turn. In v3.1, Prefrontal uses Total Recall in two new ways:",
   "new": null,
   "marked": "[-Total Recall provides the hybrid retrieval system (semantic search via local embeddings + structured search via filename patterns) that supplies context to every agent turn. In v3.1, Prefrontal uses Total Recall in two new ways:-]"
  },
  {
   "section": "5.1 Total Recall (Memory Retrieval)",
   "old": "- **Recipe-contextual retrieval**: when selecting a recipe, Prefrontal queries Total Recall for prior executions of the same recipe type, injecting relevant lessons into the plan. \"Last time you ran the debug recipe on this module, the root cause was in the dependency injection layer.\"",
   "new": null,
   "marked": "[-- **Recipe-contextual retrieval**: when selecting a recipe, Prefrontal queries Total Recall for prior executions of the same recipe type, injecting relevant lessons into the plan. \"Last time you ran the debug recipe on this module, the root cause was in the dependency injection layer.\"-]"
  },
  {
   "section": "5.1 Total Recall (Memory Retrieval)",
   "old": "- **Reflection-driven writes**: knowledge extracted during fractal reflection is written back through Total Recall's indexing pipeline, ensuring new lessons are immediately retrievable in future sessions.",
   "new": null,
   "marked": "[-- **Reflection-driven writes**: knowledge extracted during fractal reflection is written back through Total Recall's indexing pipeline, ensuring new lessons are immediately retrievable in future sessions.-]"
  },
  {
   "section": "5.2 Identity Persistence (SOUL.md)",
   "old": "### 5.2 Identity Persistence (SOUL.md)",
   "new": null,
   "marked": "[-### 5.2 Identity Persistence (SOUL.md)-]"
  },
  {
   "section": "5.2 Identity Persistence (SOUL.md)",
   "old": "The agent's identity --- personality, values, communication style --- is encoded in SOUL.md and loaded into every LLM call. In v3.1, this identity persists across all three phases of the cognitive cycle. The Prefrontal orchestration call, the subagent execution calls, and the fractal reflection call all share the same SOUL.md, ensuring that the agent's personality is consistent whether it is planning, executing, or reflecting.",
   "new": null,
   "marked": "[-The agent's identity --- personality, values, communication style --- is encoded in SOUL.md and loaded into every LLM call. In v3.1, this identity persists across all three phases of the cognitive cycle. The Prefrontal orchestration call, the subagent execution calls, and the fractal reflection call all share the same SOUL.md, ensuring that the agent's personality is consistent whether it is planning, executing, or reflecting.-]"
  },
  {
   "section": "5.2 Identity Persistence (SOUL.md)",
   "old": "By sharing SOUL.md across all calls, Prefrontal maintains a unified voice, avoiding the personality discontinuities of separate \"planner\" agents.",
   "new": null,
   "marked": "[-By sharing SOUL.md across all calls, Prefrontal maintains a unified voice, avoiding the personality discontinuities of separate \"planner\" agents.-]"
  },
  {
   "section": "5.3 Learned Intuition (AMYGDALA)",
   "old": "### 5.3 Learned Intuition (AMYGDALA)",
   "new": null,
   "marked": "[-### 5.3 Learned Intuition (AMYGDALA)-]"
  },
  {
   "section": "5.3 Learned Intuition (AMYGDALA)",
   "old": "The AMYGDALA extension (Serra, 2026) --- a neural action gating system that learns to recognise dangerous operations through situation embeddings --- integrates with v3.1 at the subagent level. Each subagent's tool calls pass through AMYGDALA's prudence network before execution, providing learned safety gating that complements the recipe's structural gates.",
   "new": null,
   "marked": "[-The AMYGDALA extension (Serra, 2026) --- a neural action gating system that learns to recognise dangerous operations through situation embeddings --- integrates with v3.1 at the subagent level. Each subagent's tool calls pass through AMYGDALA's prudence network before execution, providing learned safety gating that complements the recipe's structural gates.-]"
  },
  {
   "section": "5.3 Learned Intuition (AMYGDALA)",
   "old": "The integration is bidirectional: AMYGDALA's training data now includes recipe context (which step, which recipe, what preconditions were met), enabling the prudence network to learn that \"a file write during debug.fix after successful debug.locate is safe\" while \"a file write without prior investigation is dangerous.\" Recipe context makes safety gating more precise.",
   "new": null,
   "marked": "[-The integration is bidirectional: AMYGDALA's training data now includes recipe context (which step, which recipe, what preconditions were met), enabling the prudence network to learn that \"a file write during debug.fix after successful debug.locate is safe\" while \"a file write without prior investigation is dangerous.\" Recipe context makes safety gating more precise.-]"
  },
  {
   "section": "5.4 Fractal Reflection (Orchestrated)",
   "old": "### 5.4 Fractal Reflection (Orchestrated)",
   "new": null,
   "marked": "[-### 5.4 Fractal Reflection (Orchestrated)-]"
  },
  {
   "section": "5.4 Fractal Reflection (Orchestrated)",
   "old": "In v2.4, the `fractal-reflection` extension operated independently --- a post-turn LLM call that ran on its own schedule. In v3.1, Prefrontal orchestrates when reflection runs and what context it receives:",
   "new": null,
   "marked": "[-In v2.4, the `fractal-reflection` extension operated independently --- a post-turn LLM call that ran on its own schedule. In v3.1, Prefrontal orchestrates when reflection runs and what context it receives:-]"
  },
  {
   "section": "5.4 Fractal Reflection (Orchestrated)",
   "old": "- **After recipe completion**: full reflection with recipe context, execution trace, and plan comparison. - **After simple tasks**: lightweight reflection (MEMORY only, skip PATTERN/RIPPLE/IMPROVE). - **After failures**: extended reflection with root cause analysis and recipe update recommendations.",
   "new": null,
   "marked": "[-- **After recipe completion**: full reflection with recipe context, execution trace, and plan comparison. - **After simple tasks**: lightweight reflection (MEMORY only, skip PATTERN/RIPPLE/IMPROVE). - **After failures**: extended reflection with root cause analysis and recipe update recommendations.-]"
  },
  {
   "section": "5.4 Fractal Reflection (Orchestrated)",
   "old": "This orchestration eliminates the \"reflection fatigue\" identified in v2.4 Section 5.6 --- the problem of mandatory reflection on every turn creating visible latency during rapid exchanges. By matching reflection depth to task complexity, v3.1 preserves compounding while reducing overhead.",
   "new": null,
   "marked": "[-This orchestration eliminates the \"reflection fatigue\" identified in v2.4 Section 5.6 --- the problem of mandatory reflection on every turn creating visible latency during rapid exchanges. By matching reflection depth to task complexity, v3.1 preserves compounding while reducing overhead.-]"
  },
  {
   "section": "5. Capability 3 — On-the-Fly Authoring (Skill Acquisition)",
   "old": null,
   "new": "## 5. Capability 3 — On-the-Fly Authoring (Skill Acquisition)",
   "marked": "{+## 5. Capability 3 — On-the-Fly Authoring (Skill Acquisition)+}"
  },
  {
   "section": "5.1 Closing the no-match loop",
   "old": null,
   "new": "### 5.1 Closing the no-match loop",
   "marked": "{+### 5.1 Closing the no-match loop+}"
  },
  {
   "section": "5.1 Closing the no-match loop",
   "old": null,
   "new": "The executive analogue here is skill acquisition: when a person meets a task for which they have no rehearsed program, they construct one — and, crucially, they *keep* it, so the next encounter is no longer novel. A recipe substrate that merely shrugs on no-match has no way to grow; its coverage is frozen at whatever a human last hand-authored. The substrate closes this loop.",
   "marked": "{+The executive analogue here is skill acquisition: when a person meets a task for which they have no rehearsed program, they construct one — and, crucially, they *keep* it, so the next encounter is no longer novel. A recipe substrate that merely shrugs on no-match has no way to grow; its coverage is frozen at whatever a human last hand-authored. The substrate closes this loop.+}"
  },
  {
   "section": "5.1 Closing the no-match loop",
   "old": null,
   "new": "When matching returns `none` for a non-trivial turn, the turn-start hook injects a `recipe-gap` directive into the agent's context, instructing it to compose a new recipe specification — a slug, title, summary, tags, and three-to-seven ordered steps with tool hints and done-when criteria — and to author it. Authoring is a single call that **validates, assembles, and persists** a real recipe document. From the next turn onward, that document is in the index and matchable like any hand-written recipe. The coverage gap heals itself, in the conversation that exposed it.",
   "marked": "{+When matching returns `none` for a non-trivial turn, the turn-start hook injects a `recipe-gap` directive into the agent's context, instructing it to compose a new recipe specification — a slug, title, summary, tags, and three-to-seven ordered steps with tool hints and done-when criteria — and to author it. Authoring is a single call that **validates, assembles, and persists** a real recipe document. From the next turn onward, that document is in the index and matchable like any hand-written recipe. The coverage gap heals itself, in the conversation that exposed it.+}"
  },
  {
   "section": "5.2 Validation — the gate against a corrupt library",
   "old": null,
   "new": "### 5.2 Validation — the gate against a corrupt library",
   "marked": "{+### 5.2 Validation — the gate against a corrupt library+}"
  },
  {
   "section": "5.2 Validation — the gate against a corrupt library",
   "old": null,
   "new": "A self-authoring system that writes unvalidated files would slowly poison its own library. Authoring therefore refuses any specification that would produce a malformed or unsafe recipe:",
   "marked": "{+A self-authoring system that writes unvalidated files would slowly poison its own library. Authoring therefore refuses any specification that would produce a malformed or unsafe recipe:+}"
  },
  {
   "section": "5.2 Validation — the gate against a corrupt library",
   "old": null,
   "new": "``` function VALIDATE(spec): errors <- [] if spec.slug does not match SAFE_SLUG_PATTERN: # lowercase, no slashes, no \"..\" errors += \"slug unsafe (also the on-disk dir name)\" if spec.title or spec.summary missing: errors += \"title/summary required\" if spec.tags is empty: errors += \"tags required (else unmatchable)\" if spec.category set and not in CANONICAL_CATEGORIES: errors += \"bad category\" if spec.steps is empty: errors += \">=1 step required\" for i, step in spec.steps: if step.title or step.body missing: errors += \"step {i} incomplete\" if step.body contains a numbered markdown heading: # \"### N. ...\" errors += \"step {i} body would re-parse as a PHANTOM step\" if spec.parallelism_groups set: require every step index covered exactly once, in range, non-overlapping return errors ```",
   "marked": "{+``` function VALIDATE(spec): errors <- [] if spec.slug does not match SAFE_SLUG_PATTERN: # lowercase, no slashes, no \"..\" errors += \"slug unsafe (also the on-disk dir name)\" if spec.title or spec.summary missing: errors += \"title/summary required\" if spec.tags is empty: errors += \"tags required (else unmatchable)\" if spec.category set and not in CANONICAL_CATEGORIES: errors += \"bad category\" if spec.steps is empty: errors += \">=1 step required\" for i, step in spec.steps: if step.title or step.body missing: errors += \"step {i} incomplete\" if step.body contains a numbered markdown heading: # \"### N. ...\" errors += \"step {i} body would re-parse as a PHANTOM step\" if spec.parallelism_groups set: require every step index covered exactly once, in range, non-overlapping return errors ```+}"
  },
  {
   "section": "5.2 Validation — the gate against a corrupt library",
   "old": null,
   "new": "Three checks are load-bearing. The **slug** is also the directory name, so it must be traversal-safe — a self-authoring system that accepted `../../etc` as a slug would be a security hole, not a feature. The **phantom-heading** check forbids a numbered markdown heading inside a step body, because the runner splits steps on exactly that pattern; an un-checked heading would silently desynchronise the step count from the parallelism map. The **parallelism coverage** check guarantees the fan-out groups reference every step once and only once.",
   "marked": "{+Three checks are load-bearing. The **slug** is also the directory name, so it must be traversal-safe — a self-authoring system that accepted `../../etc` as a slug would be a security hole, not a feature. The **phantom-heading** check forbids a numbered markdown heading inside a step body, because the runner splits steps on exactly that pattern; an un-checked heading would silently desynchronise the step count from the parallelism map. The **parallelism coverage** check guarantees the fan-out groups reference every step once and only once.+}"
  },
  {
   "section": "5.3 Provenance and the never-overwrite rule",
   "old": null,
   "new": "### 5.3 Provenance and the never-overwrite rule",
   "marked": "{+### 5.3 Provenance and the never-overwrite rule+}"
  },
  {
   "section": "5.3 Provenance and the never-overwrite rule",
   "old": null,
   "new": "Authored recipes are stamped with an *authored-by* marker that distinguishes them from the curated, hand-written library. The persistence layer will overwrite an authored recipe only with an explicit overwrite flag, and **will never overwrite a curated recipe** — the substrate cannot cannibalise its own carefully written playbooks. Trigger phrases supplied by the author are folded into the recipe's tag set, because the matcher scores against tags; an authored recipe whose triggers never reached the tags would be invisible to the very matcher that is meant to surface it next turn. (Authored recipes are never auto-published to any shared registry; publishing is an explicit, separate human action.)",
   "marked": "{+Authored recipes are stamped with an *authored-by* marker that distinguishes them from the curated, hand-written library. The persistence layer will overwrite an authored recipe only with an explicit overwrite flag, and **will never overwrite a curated recipe** — the substrate cannot cannibalise its own carefully written playbooks. Trigger phrases supplied by the author are folded into the recipe's tag set, because the matcher scores against tags; an authored recipe whose triggers never reached the tags would be invisible to the very matcher that is meant to surface it next turn. (Authored recipes are never auto-published to any shared registry; publishing is an explicit, separate human action.)+}"
  },
  {
   "section": "5.3 Provenance and the never-overwrite rule",
   "old": null,
   "new": "This is the compounding thesis applied to workflows: each authored recipe is a captured behaviour that makes the next encounter of that task class cheaper, and the library is a *growing* asset rather than a fixed one.",
   "marked": "{+This is the compounding thesis applied to workflows: each authored recipe is a captured behaviour that makes the next encounter of that task class cheaper, and the library is a *growing* asset rather than a fixed one.+}"
  },
  {
   "section": "6. Evaluation Design",
   "old": "## 6. Evaluation Design",
   "new": null,
   "marked": "[-## 6. Evaluation Design-]"
  },
  {
   "section": "6.1 FAAR Improvement Targets",
   "old": "### 6.1 FAAR Improvement Targets",
   "new": null,
   "marked": "[-### 6.1 FAAR Improvement Targets-]"
  },
  {
   "section": "6.1 FAAR Improvement Targets",
   "old": "The recipe system should produce measurable improvements in first-attempt accuracy by preventing the most common failure modes:",
   "new": null,
   "marked": "[-The recipe system should produce measurable improvements in first-attempt accuracy by preventing the most common failure modes:-]"
  },
  {
   "section": "6.1 FAAR Improvement Targets",
   "old": "| Failure Mode | v2.4 FAAR Impact | v3.1 Mechanism | Target FAAR Delta | |-------------|-------------------|----------------|-------------------| | Fixing without reproducing | -0.08 | debug recipe step gate | +0.06 | | Coding without designing | -0.06 | feature recipe step gate | +0.04 | | Searching without scoping | -0.05 | investigate recipe step gate | +0.03 | | Skipping verification | -0.04 | all recipes include verify step | +0.03 | | **Cumulative** | **-0.23** | | **+0.16** |",
   "new": null,
   "marked": "[-| Failure Mode | v2.4 FAAR Impact | v3.1 Mechanism | Target FAAR Delta | |-------------|-------------------|----------------|-------------------| | Fixing without reproducing | -0.08 | debug recipe step gate | +0.06 | | Coding without designing | -0.06 | feature recipe step gate | +0.04 | | Searching without scoping | -0.05 | investigate recipe step gate | +0.03 | | Skipping verification | -0.04 | all recipes include verify step | +0.03 | | **Cumulative** | **-0.23** | | **+0.16** |-]"
  },
  {
   "section": "6.1 FAAR Improvement Targets",
   "old": "These targets would move the weighted FAAR from 0.90 to ~0.95.",
   "new": null,
   "marked": "[-These targets would move the weighted FAAR from 0.90 to ~0.95.-]"
  },
  {
   "section": "6.2 Cost Analysis",
   "old": "### 6.2 Cost Analysis",
   "new": null,
   "marked": "[-### 6.2 Cost Analysis-]"
  },
  {
   "section": "6.2 Cost Analysis",
   "old": "The recipe engine adds two LLM calls per complex task (orchestration + reflection). The cost depends on cache hit rates:",
   "new": null,
   "marked": "[-The recipe engine adds two LLM calls per complex task (orchestration + reflection). The cost depends on cache hit rates:-]"
  },
  {
   "section": "6.2 Cost Analysis",
   "old": "| Scenario | Cache Hit Rate | Overhead per Turn | Monthly Impact (est.) | |----------|---------------|-------------------|----------------------| | Optimal (stable context) | 95% | ~5% per call, ~10% total | +$2--4 | | Typical (moderate context churn) | 85% | ~8% per call, ~16% total | +$4--8 | | Worst case (high context churn) | 70% | ~15% per call, ~30% total | +$8--15 |",
   "new": null,
   "marked": "[-| Scenario | Cache Hit Rate | Overhead per Turn | Monthly Impact (est.) | |----------|---------------|-------------------|----------------------| | Optimal (stable context) | 95% | ~5% per call, ~10% total | +$2--4 | | Typical (moderate context churn) | 85% | ~8% per call, ~16% total | +$4--8 | | Worst case (high context churn) | 70% | ~15% per call, ~30% total | +$8--15 |-]"
  },
  {
   "section": "6.2 Cost Analysis",
   "old": "Even worst-case overhead is modest compared to savings from improved first-attempt accuracy.",
   "new": null,
   "marked": "[-Even worst-case overhead is modest compared to savings from improved first-attempt accuracy.-]"
  },
  {
   "section": "6.3 Latency Analysis",
   "old": "### 6.3 Latency Analysis",
   "new": null,
   "marked": "[-### 6.3 Latency Analysis-]"
  },
  {
   "section": "6.3 Latency Analysis",
   "old": "The orchestration call adds latency before the agent begins visible work:",
   "new": null,
   "marked": "[-The orchestration call adds latency before the agent begins visible work:-]"
  },
  {
   "section": "6.3 Latency Analysis",
   "old": "| Task Complexity | Orchestration Latency | User-Perceived Impact | |----------------|----------------------|----------------------| | Simple (passthrough) | <100ms (classification only) | None | | Medium (recipe selection) | 1--3s | Minor (plan displayed immediately) | | Complex (recipe + subagent allocation) | 3--8s | Offset by progress visibility |",
   "new": null,
   "marked": "[-| Task Complexity | Orchestration Latency | User-Perceived Impact | |----------------|----------------------|----------------------| | Simple (passthrough) | <100ms (classification only) | None | | Medium (recipe selection) | 1--3s | Minor (plan displayed immediately) | | Complex (recipe + subagent allocation) | 3--8s | Offset by progress visibility |-]"
  },
  {
   "section": "6.3 Latency Analysis",
   "old": "For complex tasks, the orchestration latency is offset by faster overall completion (fewer retries, fewer wrong turns) and improved user experience (progress visibility instead of opaque waiting).",
   "new": null,
   "marked": "[-For complex tasks, the orchestration latency is offset by faster overall completion (fewer retries, fewer wrong turns) and improved user experience (progress visibility instead of opaque waiting).-]"
  },
  {
   "section": "6.4 Comparison with Claude Code's Skill System",
   "old": "### 6.4 Comparison with Claude Code's Skill System",
   "new": null,
   "marked": "[-### 6.4 Comparison with Claude Code's Skill System-]"
  },
  {
   "section": "6.4 Comparison with Claude Code's Skill System",
   "old": "| Dimension | Claude Code Skills | Prefrontal Recipes | |-----------|-------------------|-------------------| | Selection | Hard-coded triggers in system prompt | LLM-classified intent matching | | Execution | Injected as prompt text, agent follows voluntarily | Orchestrated with step gates and monitoring | | Parallelism | Fork subagents, unsupervised | Fork subagents, supervised by Prefrontal | | Learning | Skills are static (updated by developers) | Recipes evolve through fractal reflection | | Cost model | Single call (skill text in prompt) | Cache-shared calls (~10% overhead) | | Failure handling | Agent's own judgment | Structured failure handlers per step |",
   "new": null,
   "marked": "[-| Dimension | Claude Code Skills | Prefrontal Recipes | |-----------|-------------------|-------------------| | Selection | Hard-coded triggers in system prompt | LLM-classified intent matching | | Execution | Injected as prompt text, agent follows voluntarily | Orchestrated with step gates and monitoring | | Parallelism | Fork subagents, unsupervised | Fork subagents, supervised by Prefrontal | | Learning | Skills are static (updated by developers) | Recipes evolve through fractal reflection | | Cost model | Single call (skill text in prompt) | Cache-shared calls (~10% overhead) | | Failure handling | Agent's own judgment | Structured failure handlers per step |-]"
  },
  {
   "section": "6.4 Comparison with Claude Code's Skill System",
   "old": "The key differentiator is **learning**. Claude Code's skills are effective but static --- they encode developer knowledge at deployment time and do not improve through use. Prefrontal's recipes evolve: each execution generates reflection data that can update the recipe itself, creating a compounding loop where recipes get better the more they are used.",
   "new": null,
   "marked": "[-The key differentiator is **learning**. Claude Code's skills are effective but static --- they encode developer knowledge at deployment time and do not improve through use. Prefrontal's recipes evolve: each execution generates reflection data that can update the recipe itself, creating a compounding loop where recipes get better the more they are used.-]"
  },
  {
   "section": "6. Capability 4 — Recipe Loops (The Structural Gap, Closed)",
   "old": null,
   "new": "## 6. Capability 4 — Recipe Loops (The Structural Gap, Closed)",
   "marked": "{+## 6. Capability 4 — Recipe Loops (The Structural Gap, Closed)+}"
  },
  {
   "section": "6.1 Why loops are the dividing line",
   "old": null,
   "new": "### 6.1 Why loops are the dividing line",
   "marked": "{+### 6.1 Why loops are the dividing line+}"
  },
  {
   "section": "6.1 Why loops are the dividing line",
   "old": null,
   "new": "A straight-line recipe is a checklist. A checklist cannot express \"keep collecting findings until there are no new ones,\" or \"retry this verification up to five times,\" or \"iterate the draft until it crosses a quality marker.\" Those are the shape of real iterative work, and their absence is precisely the structural gap that separates a static playbook from a hand-coded agent workflow. A loop construct — even a bounded one — is the feature that closes the gap, because sequence + branch + bounded iteration is the minimal vocabulary of a general execution substrate. With loops, recipes stop being checklists and become *programs* for behaviour.",
   "marked": "{+A straight-line recipe is a checklist. A checklist cannot express \"keep collecting findings until there are no new ones,\" or \"retry this verification up to five times,\" or \"iterate the draft until it crosses a quality marker.\" Those are the shape of real iterative work, and their absence is precisely the structural gap that separates a static playbook from a hand-coded agent workflow. A loop construct — even a bounded one — is the feature that closes the gap, because sequence + branch + bounded iteration is the minimal vocabulary of a general execution substrate. With loops, recipes stop being checklists and become *programs* for behaviour.+}"
  },
  {
   "section": "6.2 Three bounded loop modes",
   "old": null,
   "new": "### 6.2 Three bounded loop modes",
   "marked": "{+### 6.2 Three bounded loop modes+}"
  },
  {
   "section": "6.2 Three bounded loop modes",
   "old": null,
   "new": "A step whose leading directive is `loop:` repeats — whether the step is a plain worker dispatch or a `uses:` sub-recipe call — under one of three termination conditions:",
   "marked": "{+A step whose leading directive is `loop:` repeats — whether the step is a plain worker dispatch or a `uses:` sub-recipe call — under one of three termination conditions:+}"
  },
  {
   "section": "6.2 Three bounded loop modes",
   "old": null,
   "new": "- `loop: count N` — run exactly *N* times (or until an iteration fails). - `loop: until-dry [max M]` — re-run until the worker's done-note signals it found nothing new this pass, capped at *M*. - `loop: until MARKER [max M]` — re-run until a step note contains a named marker, capped at *M*.",
   "marked": "{+- `loop: count N` — run exactly *N* times (or until an iteration fails). - `loop: until-dry [max M]` — re-run until the worker's done-note signals it found nothing new this pass, capped at *M*. - `loop: until MARKER [max M]` — re-run until a step note contains a named marker, capped at *M*.+}"
  },
  {
   "section": "6.2 Three bounded loop modes",
   "old": null,
   "new": "The \"dry\" test is a small natural-language classifier over the worker's done-note: an empty note, or one containing phrases like *no new*, *nothing left*, *complete*, *exhausted*, *all covered*, counts as dry and terminates the loop. This lets a worker signal exhaustion in prose rather than via a rigid protocol.",
   "marked": "{+The \"dry\" test is a small natural-language classifier over the worker's done-note: an empty note, or one containing phrases like *no new*, *nothing left*, *complete*, *exhausted*, *all covered*, counts as dry and terminates the loop. This lets a worker signal exhaustion in prose rather than via a rigid protocol.+}"
  },
  {
   "section": "6.2 Three bounded loop modes",
   "old": null,
   "new": "``` function RUN_LOOPED_STEP(step, loop, ctx): for i in 1 .. loop.max: result <- EXECUTE_ONCE(step, ctx, iteration = i) if not result.ok: break # failure stops the loop if loop.mode == \"until-dry\" and IS_DRY(result.note): break if loop.mode == \"until-marker\" and result.note contains loop.marker: break # count mode: continue to loop.max mark step done with last result.note",
   "marked": "{+``` function RUN_LOOPED_STEP(step, loop, ctx): for i in 1 .. loop.max: result <- EXECUTE_ONCE(step, ctx, iteration = i) if not result.ok: break # failure stops the loop if loop.mode == \"until-dry\" and IS_DRY(result.note): break if loop.mode == \"until-marker\" and result.note contains loop.marker: break # count mode: continue to loop.max mark step done with last result.note+}"
  },
  {
   "section": "6.2 Three bounded loop modes",
   "old": null,
   "new": "function IS_DRY(note): if note is empty: return true return note matches /no new | nothing left | complete | exhausted | finished | all (covered|done)/ ```",
   "marked": "{+function IS_DRY(note): if note is empty: return true return note matches /no new | nothing left | complete | exhausted | finished | all (covered|done)/ ```+}"
  },
  {
   "section": "6.3 Bounded by construction — the anti-runaway guarantee",
   "old": null,
   "new": "### 6.3 Bounded by construction — the anti-runaway guarantee",
   "marked": "{+### 6.3 Bounded by construction — the anti-runaway guarantee+}"
  },
  {
   "section": "6.3 Bounded by construction — the anti-runaway guarantee",
   "old": null,
   "new": "A self-driving loop in an autonomous agent is a liability unless it is *provably* bounded. Every loop is therefore clamped twice: a per-loop default maximum, and an absolute hard cap that no recipe (authored or hand-written) can exceed. A loop count is clamped into `[1, HARD_CAP]` at parse time, so even a maliciously or accidentally enormous `count` collapses to the hard ceiling. The substrate is expressive enough to iterate and *constitutionally incapable* of spinning forever — the executive analogue of perseveration control, the prefrontal function that stops a behaviour that has stopped being productive.",
   "marked": "{+A self-driving loop in an autonomous agent is a liability unless it is *provably* bounded. Every loop is therefore clamped twice: a per-loop default maximum, and an absolute hard cap that no recipe (authored or hand-written) can exceed. A loop count is clamped into `[1, HARD_CAP]` at parse time, so even a maliciously or accidentally enormous `count` collapses to the hard ceiling. The substrate is expressive enough to iterate and *constitutionally incapable* of spinning forever — the executive analogue of perseveration control, the prefrontal function that stops a behaviour that has stopped being productive.+}"
  },
  {
   "section": "6.3 Bounded by construction — the anti-runaway guarantee",
   "old": null,
   "new": "`loop:` and `uses:` compose on the same leading directive lines, so the most powerful single construct the substrate offers is \"loop a whole sub-recipe until it reports dry\" — iterate an entire nested workflow to fixpoint, bounded.",
   "marked": "{+`loop:` and `uses:` compose on the same leading directive lines, so the most powerful single construct the substrate offers is \"loop a whole sub-recipe until it reports dry\" — iterate an entire nested workflow to fixpoint, bounded.+}"
  },
  {
   "section": "6.5 Failure Modes and Limitations",
   "old": "### 6.5 Failure Modes and Limitations",
   "new": null,
   "marked": "[-### 6.5 Failure Modes and Limitations-]"
  },
  {
   "section": "6.5 Failure Modes and Limitations",
   "old": "While cache-shared orchestration minimizes overhead, it is vulnerable to **cache evictions**. If the session goes dormant and Anthropic evicts the prompt cache, Phase 1 incurs a full context token cost. Furthermore, complex recipes with many parallel subagents can exhaust API rate limits, requiring the orchestrator to pace execution or queue sub-tasks. ## 7. Implementation Status",
   "new": null,
   "marked": "[-While cache-shared orchestration minimizes overhead, it is vulnerable to **cache evictions**. If the session goes dormant and Anthropic evicts the prompt cache, Phase 1 incurs a full context token cost. Furthermore, complex recipes with many parallel subagents can exhaust API rate limits, requiring the orchestrator to pace execution or queue sub-tasks. ## 7. Implementation Status-]"
  },
  {
   "section": "7.1 What Is Built (v2.4 Baseline)",
   "old": "### 7.1 What Is Built (v2.4 Baseline)",
   "new": null,
   "marked": "[-### 7.1 What Is Built (v2.4 Baseline)-]"
  },
  {
   "section": "7.1 What Is Built (v2.4 Baseline)",
   "old": "The following components are deployed and operational:",
   "new": null,
   "marked": "[-The following components are deployed and operational:-]"
  },
  {
   "section": "7.1 What Is Built (v2.4 Baseline)",
   "old": "- **Exploration gate**: blocks mutating tools until read-only operations are performed. Live, hooked into every turn. - **Anti-gold-plating rules**: 11 engineering discipline injections. Live. - **Forcing questions**: 5 pre-action questions for complex tasks. Live. - **Denial tracking**: escalation after 3 consecutive tool denials. Live. - **Permission hooks**: user-defined shell script gates. Live. - **FAAR tracker**: task outcome recording with category, model, tokens. Live. - **Effort router**: expensive model warnings on subagent spawns. Live. - **CORF trigger**: high-stakes decision flagging. Live. - **Feature flags**: per-hook enable/disable via gateway RPC. Live. - **Call tree panel**: real-time agent topology in Tinker UI. Live. - **Guardian process**: 3-minute health checks with auto-recovery. Live. - **Tool concurrency partitioner**: read-only vs. mutating classification. Tested, wiring pending. - **Prompt cache boundary**: static/dynamic prompt split. Tested, wiring pending. - **Fork subagents**: cache-shared child agents. Tested, wiring pending. - **Deferred tool loading**: on-demand schema loading. Tested, wiring pending.",
   "new": null,
   "marked": "[-- **Exploration gate**: blocks mutating tools until read-only operations are performed. Live, hooked into every turn. - **Anti-gold-plating rules**: 11 engineering discipline injections. Live. - **Forcing questions**: 5 pre-action questions for complex tasks. Live. - **Denial tracking**: escalation after 3 consecutive tool denials. Live. - **Permission hooks**: user-defined shell script gates. Live. - **FAAR tracker**: task outcome recording with category, model, tokens. Live. - **Effort router**: expensive model warnings on subagent spawns. Live. - **CORF trigger**: high-stakes decision flagging. Live. - **Feature flags**: per-hook enable/disable via gateway RPC. Live. - **Call tree panel**: real-time agent topology in Tinker UI. Live. - **Guardian process**: 3-minute health checks with auto-recovery. Live. - **Tool concurrency partitioner**: read-only vs. mutating classification. Tested, wiring pending. - **Prompt cache boundary**: static/dynamic prompt split. Tested, wiring pending. - **Fork subagents**: cache-shared child agents. Tested, wiring pending. - **Deferred tool loading**: on-demand schema loading. Tested, wiring pending.-]"
  },
  {
   "section": "7.1 What Is Built (v2.4 Baseline)",
   "old": "Total: ~3,300 lines of TypeScript, 151 tests, 11 test files, 6 RPC endpoints.",
   "new": null,
   "marked": "[-Total: ~3,300 lines of TypeScript, 151 tests, 11 test files, 6 RPC endpoints.-]"
  },
  {
   "section": "7.2 What Is New in v3.1",
   "old": "### 7.2 What Is New in v3.1",
   "new": null,
   "marked": "[-### 7.2 What Is New in v3.1-]"
  },
  {
   "section": "7.2 What Is New in v3.1",
   "old": "The following components are proposed and specified but not yet implemented:",
   "new": null,
   "marked": "[-The following components are proposed and specified but not yet implemented:-]"
  },
  {
   "section": "7.2 What Is New in v3.1",
   "old": "- **Recipe engine**: recipe parsing, step tracking, gate evaluation, failure handler dispatch. - **Recipe library**: 6 built-in recipes (debug, feature, investigate, refactor, review, deploy) plus custom recipe loading from memory hierarchy. - **Intent classifier**: three-tier strategy (keyword, structure, LLM) for recipe selection. - **Orchestrator loop**: Prefrontal as first call with plan injection into main agent context. - **Subagent supervisor**: progress monitoring, stall detection, cross-subagent coordination, intervention. - **Progress reporter**: WebSocket event emission for recipe step progress, subagent status, elapsed time. - **Reflection orchestrator**: mandatory post-recipe reflection with recipe context injection. - **Recipe evolution**: automatic recipe updates based on reflection findings. - **UI extensions**: recipe overlay on call tree, cost tracking per step, stall indicators.",
   "new": null,
   "marked": "[-- **Recipe engine**: recipe parsing, step tracking, gate evaluation, failure handler dispatch. - **Recipe library**: 6 built-in recipes (debug, feature, investigate, refactor, review, deploy) plus custom recipe loading from memory hierarchy. - **Intent classifier**: three-tier strategy (keyword, structure, LLM) for recipe selection. - **Orchestrator loop**: Prefrontal as first call with plan injection into main agent context. - **Subagent supervisor**: progress monitoring, stall detection, cross-subagent coordination, intervention. - **Progress reporter**: WebSocket event emission for recipe step progress, subagent status, elapsed time. - **Reflection orchestrator**: mandatory post-recipe reflection with recipe context injection. - **Recipe evolution**: automatic recipe updates based on reflection findings. - **UI extensions**: recipe overlay on call tree, cost tracking per step, stall indicators.-]"
  },
  {
   "section": "7.3 Roadmap",
   "old": "### 7.3 Roadmap",
   "new": null,
   "marked": "[-### 7.3 Roadmap-]"
  },
  {
   "section": "7.3 Roadmap",
   "old": "**Phase 1 (Foundation)**: Recipe format specification, parser, and built-in library. Intent classifier with keyword and structure matching. Estimated: 1--2 sessions.",
   "new": null,
   "marked": "[-**Phase 1 (Foundation)**: Recipe format specification, parser, and built-in library. Intent classifier with keyword and structure matching. Estimated: 1--2 sessions.-]"
  },
  {
   "section": "7.3 Roadmap",
   "old": "**Phase 2 (Orchestration)**: Prefrontal as first call. Orchestrator loop with plan injection. Single-agent execution (no parallelism yet). Estimated: 2--3 sessions.",
   "new": null,
   "marked": "[-**Phase 2 (Orchestration)**: Prefrontal as first call. Orchestrator loop with plan injection. Single-agent execution (no parallelism yet). Estimated: 2--3 sessions.-]"
  },
  {
   "section": "7.3 Roadmap",
   "old": "**Phase 3 (Parallelism)**: Subagent supervisor. Progress reporter. Stall detection. Wire the existing fork-subagent module into the recipe engine. Estimated: 2--3 sessions.",
   "new": null,
   "marked": "[-**Phase 3 (Parallelism)**: Subagent supervisor. Progress reporter. Stall detection. Wire the existing fork-subagent module into the recipe engine. Estimated: 2--3 sessions.-]"
  },
  {
   "section": "7.3 Roadmap",
   "old": "**Phase 4 (Reflection)**: Reflection orchestrator. Recipe-aware reflection context. Recipe evolution from reflection findings. Estimated: 1--2 sessions.",
   "new": null,
   "marked": "[-**Phase 4 (Reflection)**: Reflection orchestrator. Recipe-aware reflection context. Recipe evolution from reflection findings. Estimated: 1--2 sessions.-]"
  },
  {
   "section": "7.3 Roadmap",
   "old": "**Phase 5 (UI)**: Recipe overlay on call tree. Cost tracking. Progress panel. Estimated: 1--2 sessions.",
   "new": null,
   "marked": "[-**Phase 5 (UI)**: Recipe overlay on call tree. Cost tracking. Progress panel. Estimated: 1--2 sessions.-]"
  },
  {
   "section": "7.3 Roadmap",
   "old": "**Phase 6 (Learning)**: Recipe selection improves from usage data. Gate thresholds adapt. Recipes fork into variants for different contexts. This phase has no fixed endpoint --- it is the compounding loop itself.",
   "new": null,
   "marked": "[-**Phase 6 (Learning)**: Recipe selection improves from usage data. Gate thresholds adapt. Recipes fork into variants for different contexts. This phase has no fixed endpoint --- it is the compounding loop itself.-]"
  },
  {
   "section": "7. Capability 5 — Dynamic Effort Routing (Effort Regulation)",
   "old": null,
   "new": "## 7. Capability 5 — Dynamic Effort Routing (Effort Regulation)",
   "marked": "{+## 7. Capability 5 — Dynamic Effort Routing (Effort Regulation)+}"
  },
  {
   "section": "7.1 From classify-and-log to classify-and-drive",
   "old": null,
   "new": "### 7.1 From classify-and-log to classify-and-drive",
   "marked": "{+### 7.1 From classify-and-log to classify-and-drive+}"
  },
  {
   "section": "7.1 From classify-and-log to classify-and-drive",
   "old": null,
   "new": "The prefrontal cortex meters effort: it does not spend the same metabolic budget on \"pass the salt\" as on \"prove this theorem.\" An agent that reasons at full intensity on a greeting and at minimum intensity on an architecture decision is mis-regulated in both directions — wasteful on the trivial, negligent on the hard. Earlier effort routing only *classified* the turn and logged the result, which changed nothing. The substrate makes the classification **drive** the turn.",
   "marked": "{+The prefrontal cortex meters effort: it does not spend the same metabolic budget on \"pass the salt\" as on \"prove this theorem.\" An agent that reasons at full intensity on a greeting and at minimum intensity on an architecture decision is mis-regulated in both directions — wasteful on the trivial, negligent on the hard. Earlier effort routing only *classified* the turn and logged the result, which changed nothing. The substrate makes the classification **drive** the turn.+}"
  },
  {
   "section": "7.2 The four tiers and the signals behind them",
   "old": null,
   "new": "### 7.2 The four tiers and the signals behind them",
   "marked": "{+### 7.2 The four tiers and the signals behind them+}"
  },
  {
   "section": "7.2 The four tiers and the signals behind them",
   "old": null,
   "new": "Each turn is scored into one of four tiers — **trivial → standard → deep → ultra** — from cheap, language-level signals: prompt length, the number of clauses/sub-tasks (conjunctions, list markers, line breaks as a proxy for \"how many things am I being asked to do\"), the presence of code or file paths, the count of distinct \"hard work\" verbs (*architect, design, investigate, refactor, migrate, audit, debug, optimise, …*), the count of \"maximum effort / breadth\" cues (*comprehensive, exhaustive, end-to-end, entire codebase, deep dive, be generous, …*, weighted double), and a word-boundary-checked set of conversational/acknowledgement tokens that mark a turn as trivial.",
   "marked": "{+Each turn is scored into one of four tiers — **trivial → standard → deep → ultra** — from cheap, language-level signals: prompt length, the number of clauses/sub-tasks (conjunctions, list markers, line breaks as a proxy for \"how many things am I being asked to do\"), the presence of code or file paths, the count of distinct \"hard work\" verbs (*architect, design, investigate, refactor, migrate, audit, debug, optimise, …*), the count of \"maximum effort / breadth\" cues (*comprehensive, exhaustive, end-to-end, entire codebase, deep dive, be generous, …*, weighted double), and a word-boundary-checked set of conversational/acknowledgement tokens that mark a turn as trivial.+}"
  },
  {
   "section": "7.2 The four tiers and the signals behind them",
   "old": null,
   "new": "``` function CLASSIFY_EFFORT(prompt): score <- 0 if words > 40: score += 1; if words > 120: score += 1; if words > 300: score += 1 if clauses >= 4: score += 1; if clauses >= 10: score += 1 if has_code: score += 1 if has_paths: score += 1 score += min(4, count_distinct(deep_verbs)) score += min(4, 2 * count(ultra_cues)) # breadth cues weigh double if questions >= 3: score += 1",
   "marked": "{+``` function CLASSIFY_EFFORT(prompt): score <- 0 if words > 40: score += 1; if words > 120: score += 1; if words > 300: score += 1 if clauses >= 4: score += 1; if clauses >= 10: score += 1 if has_code: score += 1 if has_paths: score += 1 score += min(4, count_distinct(deep_verbs)) score += min(4, 2 * count(ultra_cues)) # breadth cues weigh double if questions >= 3: score += 1+}"
  },
  {
   "section": "7.2 The four tiers and the signals behind them",
   "old": null,
   "new": "if trivial_token_hit or (words <= 4 and score == 0): tier <- \"trivial\" elif score >= 7 or ultra_cues >= 2: tier <- \"ultra\" elif score >= 4: tier <- \"deep\" else: tier <- \"standard\" if tier == \"standard\" and count(deep_verbs) >= 3: tier <- \"deep\" # floor return tier ```",
   "marked": "{+if trivial_token_hit or (words <= 4 and score == 0): tier <- \"trivial\" elif score >= 7 or ultra_cues >= 2: tier <- \"ultra\" elif score >= 4: tier <- \"deep\" else: tier <- \"standard\" if tier == \"standard\" and count(deep_verbs) >= 3: tier <- \"deep\" # floor return tier ```+}"
  },
  {
   "section": "7.2 The four tiers and the signals behind them",
   "old": null,
   "new": "A trivial turn must have **no** hard or breadth verbs — the design refuses to down-classify a short prompt that nonetheless asks for hard work.",
   "marked": "{+A trivial turn must have **no** hard or breadth verbs — the design refuses to down-classify a short prompt that nonetheless asks for hard work.+}"
  },
  {
   "section": "7.3 What the tier controls",
   "old": null,
   "new": "### 7.3 What the tier controls",
   "marked": "{+### 7.3 What the tier controls+}"
  },
  {
   "section": "7.3 What the tier controls",
   "old": null,
   "new": "The tier is not advisory; it sets four levers for the turn, injected as guidance the worker adapts to:",
   "marked": "{+The tier is not advisory; it sets four levers for the turn, injected as guidance the worker adapts to:+}"
  },
  {
   "section": "7.3 What the tier controls",
   "old": null,
   "new": "| Tier | Model tier | Thinking budget | Orchestration mode | Token generosity | |------|-----------|-----------------|--------------------|------------------| | **trivial** | minimal | none — answer directly | solo, inline | terse (a sentence or two) | | **standard** | standard | brief; verify before claiming done | solo, inline | normal — cover the ask, no padding | | **deep** | maximum | extended; lay out KNOW / ASSUME / DON'T-KNOW before acting | parallel — fan independent read-only work to subagents | generous | | **ultra** | maximum | maximum; design before implementing | full workflow — understand → design → implement → review, with adversarial verification and a completeness critic at the end | very generous — correctness over cost |",
   "marked": "{+| Tier | Model tier | Thinking budget | Orchestration mode | Token generosity | |------|-----------|-----------------|--------------------|------------------| | **trivial** | minimal | none — answer directly | solo, inline | terse (a sentence or two) | | **standard** | standard | brief; verify before claiming done | solo, inline | normal — cover the ask, no padding | | **deep** | maximum | extended; lay out KNOW / ASSUME / DON'T-KNOW before acting | parallel — fan independent read-only work to subagents | generous | | **ultra** | maximum | maximum; design before implementing | full workflow — understand → design → implement → review, with adversarial verification and a completeness critic at the end | very generous — correctness over cost |+}"
  },
  {
   "section": "7.3 What the tier controls",
   "old": null,
   "new": "For trivial turns the substrate injects *nothing* and keeps the turn cheap and fast; the executive stays dormant when there is nothing to regulate. For deep and ultra turns it shifts the whole posture of the agent — bigger model, more thinking, parallel or full-workflow orchestration, and explicit permission to spend tokens on correctness. This is the lever that lets a single agent be both a quick conversationalist and a rigorous engineer, choosing per turn rather than per deployment.",
   "marked": "{+For trivial turns the substrate injects *nothing* and keeps the turn cheap and fast; the executive stays dormant when there is nothing to regulate. For deep and ultra turns it shifts the whole posture of the agent — bigger model, more thinking, parallel or full-workflow orchestration, and explicit permission to spend tokens on correctness. This is the lever that lets a single agent be both a quick conversationalist and a rigorous engineer, choosing per turn rather than per deployment.+}"
  },
  {
   "section": "8. Conclusion",
   "old": "## 8. Conclusion",
   "new": null,
   "marked": "[-## 8. Conclusion-]"
  },
  {
   "section": "8. Conclusion",
   "old": "The history of software engineering is a history of structured workflows replacing ad hoc improvisation. Waterfall, agile, TDD, CI/CD --- each methodology succeeded not by making developers smarter but by making their process more structured. The same transition is now happening in AI agent architecture.",
   "new": null,
   "marked": "[-The history of software engineering is a history of structured workflows replacing ad hoc improvisation. Waterfall, agile, TDD, CI/CD --- each methodology succeeded not by making developers smarter but by making their process more structured. The same transition is now happening in AI agent architecture.-]"
  },
  {
   "section": "8. Conclusion",
   "old": "Version 2.4 of this paper demonstrated that intelligence compounds through architecture. Four mechanisms --- fractal reflection, tiered memory, CORF parallelism, and adaptive routing --- produced a 96% improvement in composite intelligence over six months. But v2.4's architecture was defensive: it prevented bad behaviour more effectively than it produced good behaviour. The guards worked; the highway was missing.",
   "new": null,
   "marked": "[-Version 2.4 of this paper demonstrated that intelligence compounds through architecture. Four mechanisms --- fractal reflection, tiered memory, CORF parallelism, and adaptive routing --- produced a 96% improvement in composite intelligence over six months. But v2.4's architecture was defensive: it prevented bad behaviour more effectively than it produced good behaviour. The guards worked; the highway was missing.-]"
  },
  {
   "section": "8. Conclusion",
   "old": "Version 3.0 proposes the highway. By transforming Prefrontal from a guard system into a recipe execution engine, we complete the cognitive cycle that v2.4 acknowledged was only half-built. Pre-action planning selects the right recipe. During-action monitoring supervises execution. Post-action reflection extracts lessons and improves the recipes themselves. The compounding loop closes: each recipe execution makes the next execution of that recipe better.",
   "new": null,
   "marked": "[-Version 3.0 proposes the highway. By transforming Prefrontal from a guard system into a recipe execution engine, we complete the cognitive cycle that v2.4 acknowledged was only half-built. Pre-action planning selects the right recipe. During-action monitoring supervises execution. Post-action reflection extracts lessons and improves the recipes themselves. The compounding loop closes: each recipe execution makes the next execution of that recipe better.-]"
  },
  {
   "section": "8. Conclusion",
   "old": "The convergent evolution evidence is now three-layered. Claude Code's skills are recipes executed by a `while(true)` loop. Journey Kits proposes recipes as the atomic unit of agent value. Meta-Harness demonstrates that harness optimisation --- the automated discovery of better recipes --- produces 6x performance gains. Three independent teams, working from different premises, arrived at the same conclusion: **the recipe is the unit of agent intelligence**.",
   "new": null,
   "marked": "[-The convergent evolution evidence is now three-layered. Claude Code's skills are recipes executed by a `while(true)` loop. Journey Kits proposes recipes as the atomic unit of agent value. Meta-Harness demonstrates that harness optimisation --- the automated discovery of better recipes --- produces 6x performance gains. Three independent teams, working from different premises, arrived at the same conclusion: **the recipe is the unit of agent intelligence**.-]"
  },
  {
   "section": "8. Conclusion",
   "old": "The honest assessment remains that much of v3.1 is specified but not yet implemented. The recipe engine, the orchestrator loop, the subagent supervisor, and the reflection orchestrator exist as designs in this paper, not as code in the repository. The v2.4 baseline --- guards, observability, monitoring --- is live and validated. The v3.1 additions are the next implementation target.",
   "new": null,
   "marked": "[-The honest assessment remains that much of v3.1 is specified but not yet implemented. The recipe engine, the orchestrator loop, the subagent supervisor, and the reflection orchestrator exist as designs in this paper, not as code in the repository. The v2.4 baseline --- guards, observability, monitoring --- is live and validated. The v3.1 additions are the next implementation target.-]"
  },
  {
   "section": "8. Conclusion",
   "old": "The architectural insight is clear: prompt caching makes orchestration nearly free. What remains is wiring existing components into this cognitive cycle.",
   "new": null,
   "marked": "[-The architectural insight is clear: prompt caching makes orchestration nearly free. What remains is wiring existing components into this cognitive cycle.-]"
  },
  {
   "section": "8. Conclusion",
   "old": "The intern who never makes the same mistake twice writes things down. The intern who gets promoted writes *recipes* --- structured workflows that make the next person as effective as they are. Version 3.0 is about building agents that write recipes.",
   "new": null,
   "marked": "[-The intern who never makes the same mistake twice writes things down. The intern who gets promoted writes *recipes* --- structured workflows that make the next person as effective as they are. Version 3.0 is about building agents that write recipes.-]"
  },
  {
   "section": "8. Capability 6 — The RECIPES Observability Panel (Metacognitive Monitoring)",
   "old": null,
   "new": "## 8. Capability 6 — The RECIPES Observability Panel (Metacognitive Monitoring)",
   "marked": "{+## 8. Capability 6 — The RECIPES Observability Panel (Metacognitive Monitoring)+}"
  },
  {
   "section": "8.1 Why observability is a first-class capability, not a nicety",
   "old": null,
   "new": "### 8.1 Why observability is a first-class capability, not a nicety",
   "marked": "{+### 8.1 Why observability is a first-class capability, not a nicety+}"
  },
  {
   "section": "8.1 Why observability is a first-class capability, not a nicety",
   "old": null,
   "new": "An executive that runs invisibly is impossible to trust or to debug. If a human collaborator cannot see *which* program is running, *where* it is, and *how* each worker is doing, then every long-running turn is an opaque wait, and every failure is a mystery. The substrate therefore treats observability as a designed capability with its own surface: the **RECIPES** panel.",
   "marked": "{+An executive that runs invisibly is impossible to trust or to debug. If a human collaborator cannot see *which* program is running, *where* it is, and *how* each worker is doing, then every long-running turn is an opaque wait, and every failure is a mystery. The substrate therefore treats observability as a designed capability with its own surface: the **RECIPES** panel.+}"
  },
  {
   "section": "8.2 The split-of-concerns invariant",
   "old": null,
   "new": "### 8.2 The split-of-concerns invariant",
   "marked": "{+### 8.2 The split-of-concerns invariant+}"
  },
  {
   "section": "8.2 The split-of-concerns invariant",
   "old": null,
   "new": "One rule governs the panel and is the most load-bearing invariant of the whole system:",
   "marked": "{+One rule governs the panel and is the most load-bearing invariant of the whole system:+}"
  },
  {
   "section": "8.2 The split-of-concerns invariant",
   "old": null,
   "new": "> **Chat carries substance; the panel carries orchestration mechanics. Never the reverse.**",
   "marked": "{+> **Chat carries substance; the panel carries orchestration mechanics. Never the reverse.**+}"
  },
  {
   "section": "8.2 The split-of-concerns invariant",
   "old": null,
   "new": "The substantive answer — what was found, what changed, what is stuck — goes in the chat. The orchestration mechanics — which recipes were searched, which step is active, which subagent is doing what — go in the panel. Pushing dispatch chatter into the chat drowns the substance; pushing substance into the panel hides the answer. If a person has to flip between surfaces to understand where the agent is, the split was drawn wrong.",
   "marked": "{+The substantive answer — what was found, what changed, what is stuck — goes in the chat. The orchestration mechanics — which recipes were searched, which step is active, which subagent is doing what — go in the panel. Pushing dispatch chatter into the chat drowns the substance; pushing substance into the panel hides the answer. If a person has to flip between surfaces to understand where the agent is, the split was drawn wrong.+}"
  },
  {
   "section": "8.3 What the panel renders",
   "old": null,
   "new": "### 8.3 What the panel renders",
   "marked": "{+### 8.3 What the panel renders+}"
  },
  {
   "section": "8.3 What the panel renders",
   "old": null,
   "new": "The panel renders the full life-cycle of a recipe run as several stacked sections:",
   "marked": "{+The panel renders the full life-cycle of a recipe run as several stacked sections:+}"
  },
  {
   "section": "8.3 What the panel renders",
   "old": null,
   "new": "- **Discovery.** Catalog size, the scored candidate recipes with their scores, the matching threshold, and what was selected (or a visible NO-MATCH). This makes task-set selection auditable: a wrong recipe choice is now a thing you can *see*, not infer. - **Composition.** When more than one recipe contributed (via match-merge or `composes:`), a summary of which recipes contributed how many steps, and how many steps survived de-duplication. Each step row in the plan carries a badge naming its source recipe, so provenance is not lost in the merge. - **Plan with per-step status.** The ordered steps, the single active step, and each step's `pending / in_progress / done / error` status — the externalised working-memory cursor. - **Per-step fan-out — subagent vitals.** Under the active step, one row per dispatched subagent: a stable colour derived from its run identity, its model, its status, elapsed time, and the tool it is currently using. This is where \"the agent is working\" becomes \"this subagent, on this model, is reading this file, and has been for forty seconds.\" - **The provenance / decision trail.** A running log of the executive's decisions, each tagged with a small fixed vocabulary of verbs — **searched**, **matched**, **merged**, **composed**, **authored**, plus the in-flight verbs **dispatch / complete / note / transition / warn**. Reading the trail top to bottom reconstructs exactly how the substrate reasoned its way from prompt to plan to execution.",
   "marked": "{+- **Discovery.** Catalog size, the scored candidate recipes with their scores, the matching threshold, and what was selected (or a visible NO-MATCH). This makes task-set selection auditable: a wrong recipe choice is now a thing you can *see*, not infer. - **Composition.** When more than one recipe contributed (via match-merge or `composes:`), a summary of which recipes contributed how many steps, and how many steps survived de-duplication. Each step row in the plan carries a badge naming its source recipe, so provenance is not lost in the merge. - **Plan with per-step status.** The ordered steps, the single active step, and each step's `pending / in_progress / done / error` status — the externalised working-memory cursor. - **Per-step fan-out — subagent vitals.** Under the active step, one row per dispatched subagent: a stable colour derived from its run identity, its model, its status, elapsed time, and the tool it is currently using. This is where \"the agent is working\" becomes \"this subagent, on this model, is reading this file, and has been for forty seconds.\" - **The provenance / decision trail.** A running log of the executive's decisions, each tagged with a small fixed vocabulary of verbs — **searched**, **matched**, **merged**, **composed**, **authored**, plus the in-flight verbs **dispatch / complete / note / transition / warn**. Reading the trail top to bottom reconstructs exactly how the substrate reasoned its way from prompt to plan to execution.+}"
  },
  {
   "section": "8.4 The compact-expand decision trail",
   "old": null,
   "new": "### 8.4 The compact-expand decision trail",
   "marked": "{+### 8.4 The compact-expand decision trail+}"
  },
  {
   "section": "8.4 The compact-expand decision trail",
   "old": null,
   "new": "A trail that grows without bound becomes noise, and a panel that stays verbose for hours after work ends is worse than no panel. The decision trail is therefore **compact by default and expandable on demand**, and it self-folds: when the last subagent completes and the call tree returns to idle, the recipe header and the accumulated trail fold away while the persistent plan (a task tracker, not an in-flight indicator) remains. The state is kept in memory for the next job's resumption; the panel simply stops painting it. The executive's monitor is loud while there is something to monitor and quiet when there is not — the metacognitive analogue of attention that disengages when the task is done.",
   "marked": "{+A trail that grows without bound becomes noise, and a panel that stays verbose for hours after work ends is worse than no panel. The decision trail is therefore **compact by default and expandable on demand**, and it self-folds: when the last subagent completes and the call tree returns to idle, the recipe header and the accumulated trail fold away while the persistent plan (a task tracker, not an in-flight indicator) remains. The state is kept in memory for the next job's resumption; the panel simply stops painting it. The executive's monitor is loud while there is something to monitor and quiet when there is not — the metacognitive analogue of attention that disengages when the task is done.+}"
  },
  {
   "section": "8.4 The compact-expand decision trail",
   "old": null,
   "new": "**Figure 2 (described in §11).** The life-cycle state machine the RECIPES panel renders: `searched → matched → merged/composed → seeded → running → looping/composing → done`, with the `no-match → authoring → matchable-next-turn` branch and the `no-match → trivial → idle` branch. Every transition emits a provenance-trail verb.",
   "marked": "{+**Figure 2 (described in §11).** The life-cycle state machine the RECIPES panel renders: `searched → matched → merged/composed → seeded → running → looping/composing → done`, with the `no-match → authoring → matchable-next-turn` branch and the `no-match → trivial → idle` branch. Every transition emits a provenance-trail verb.+}"
  },
  {
   "section": "References",
   "old": "## References",
   "new": null,
   "marked": "[-## References-]"
  },
  {
   "section": "References",
   "old": "Anthropic. (2026). Claude Code source code [Accidentally exposed, March 2026]. Analysis based on publicly available descriptions.",
   "new": null,
   "marked": "[-Anthropic. (2026). Claude Code source code [Accidentally exposed, March 2026]. Analysis based on publicly available descriptions.-]"
  },
  {
   "section": "References",
   "old": "Berman, M. (2026). Journey Kits: npm for AI agent workflows. https://journeykits.ai",
   "new": null,
   "marked": "[-Berman, M. (2026). Journey Kits: npm for AI agent workflows. https://journeykits.ai-]"
  },
  {
   "section": "References",
   "old": "Chen, X. et al. (2026). MemexRL: Learning to manage agent memory through reinforcement. *arXiv preprint*.",
   "new": null,
   "marked": "[-Chen, X. et al. (2026). MemexRL: Learning to manage agent memory through reinforcement. *arXiv preprint*.-]"
  },
  {
   "section": "References",
   "old": "Chollet, F. (2019). On the measure of intelligence. *arXiv preprint arXiv:1911.01547*.",
   "new": null,
   "marked": "[-Chollet, F. (2019). On the measure of intelligence. *arXiv preprint arXiv:1911.01547*.-]"
  },
  {
   "section": "References",
   "old": "Khattab, O. et al. (2023). DSPy: Compiling declarative language model calls into self-improving pipelines. *arXiv preprint arXiv:2310.03714*.",
   "new": null,
   "marked": "[-Khattab, O. et al. (2023). DSPy: Compiling declarative language model calls into self-improving pipelines. *arXiv preprint arXiv:2310.03714*.-]"
  },
  {
   "section": "References",
   "old": "Lee, J. et al. (2026). Meta-Harness: Automatically optimising agent scaffolding for terminal benchmarks. *arXiv preprint*.",
   "new": null,
   "marked": "[-Lee, J. et al. (2026). Meta-Harness: Automatically optimising agent scaffolding for terminal benchmarks. *arXiv preprint*.-]"
  },
  {
   "section": "References",
   "old": "Li, W. et al. (2026). CraniMem: Neural memory compression with hippocampal indexing for LLM agents. *arXiv preprint*.",
   "new": null,
   "marked": "[-Li, W. et al. (2026). CraniMem: Neural memory compression with hippocampal indexing for LLM agents. *arXiv preprint*.-]"
  },
  {
   "section": "References",
   "old": "Madaan, A. et al. (2023). Self-Refine: Iterative refinement with self-feedback. *NeurIPS 2023*.",
   "new": null,
   "marked": "[-Madaan, A. et al. (2023). Self-Refine: Iterative refinement with self-feedback. *NeurIPS 2023*.-]"
  },
  {
   "section": "References",
   "old": "Maharana, A. et al. (2024). LoCoMo: Long-context memory evaluation for conversational agents. *arXiv preprint*.",
   "new": null,
   "marked": "[-Maharana, A. et al. (2024). LoCoMo: Long-context memory evaluation for conversational agents. *arXiv preprint*.-]"
  },
  {
   "section": "References",
   "old": "Nouse Research. (2026). Hermes Agent: Self-improving skill libraries for autonomous agents.",
   "new": null,
   "marked": "[-Nouse Research. (2026). Hermes Agent: Self-improving skill libraries for autonomous agents.-]"
  },
  {
   "section": "References",
   "old": "Packer, C. et al. (2023). MemGPT: Towards LLMs as operating systems. *arXiv preprint arXiv:2310.08560*.",
   "new": null,
   "marked": "[-Packer, C. et al. (2023). MemGPT: Towards LLMs as operating systems. *arXiv preprint arXiv:2310.08560*.-]"
  },
  {
   "section": "References",
   "old": "Park, J. S. et al. (2023). Generative agents: Interactive simulacra of human behavior. *UIST 2023*.",
   "new": null,
   "marked": "[-Park, J. S. et al. (2023). Generative agents: Interactive simulacra of human behavior. *UIST 2023*.-]"
  },
  {
   "section": "References",
   "old": "Park, S. et al. (2026). Governed Memory: Access control and governance for agent memory systems. *arXiv preprint*.",
   "new": null,
   "marked": "[-Park, S. et al. (2026). Governed Memory: Access control and governance for agent memory systems. *arXiv preprint*.-]"
  },
  {
   "section": "References",
   "old": "Serra, O. (2026). AMYGDALA: Adaptive modulation of agent disposition via affective learned association. *Working paper*.",
   "new": null,
   "marked": "[-Serra, O. (2026). AMYGDALA: Adaptive modulation of agent disposition via affective learned association. *Working paper*.-]"
  },
  {
   "section": "References",
   "old": "Serra, O. & Jarvis. (2026). PREFRONTAL v2.4: Compounded Intelligence --- How Persistent Agents Get Smarter by Remembering What They Learn. *Working paper*.",
   "new": null,
   "marked": "[-Serra, O. & Jarvis. (2026). PREFRONTAL v2.4: Compounded Intelligence --- How Persistent Agents Get Smarter by Remembering What They Learn. *Working paper*.-]"
  },
  {
   "section": "References",
   "old": "Shinn, N. et al. (2023). Reflexion: Language agents with verbal reinforcement learning. *NeurIPS 2023*.",
   "new": null,
   "marked": "[-Shinn, N. et al. (2023). Reflexion: Language agents with verbal reinforcement learning. *NeurIPS 2023*.-]"
  },
  {
   "section": "References",
   "old": "Tan, P. (2026). GStack: Multi-perspective code review through role-based prompt specialisation.",
   "new": null,
   "marked": "[-Tan, P. (2026). GStack: Multi-perspective code review through role-based prompt specialisation.-]"
  },
  {
   "section": "References",
   "old": "Wang, G. et al. (2023). Voyager: An open-ended embodied agent with large language models. *arXiv preprint arXiv:2305.16291*.",
   "new": null,
   "marked": "[-Wang, G. et al. (2023). Voyager: An open-ended embodied agent with large language models. *arXiv preprint arXiv:2305.16291*.-]"
  },
  {
   "section": "References",
   "old": "Zhang, L. et al. (2026). A survey of memory architectures for LLM-based agents. *arXiv preprint*.",
   "new": null,
   "marked": "[-Zhang, L. et al. (2026). A survey of memory architectures for LLM-based agents. *arXiv preprint*.-]"
  },
  {
   "section": "9. Integration with the Surrounding Cognitive Systems",
   "old": null,
   "new": "## 9. Integration with the Surrounding Cognitive Systems",
   "marked": "{+## 9. Integration with the Surrounding Cognitive Systems+}"
  },
  {
   "section": "9. Integration with the Surrounding Cognitive Systems",
   "old": null,
   "new": "The substrate does not stand alone; it sits among the other organs of the agent's cognition and coordinates them. Each retains its autonomous function and gains a coordination point.",
   "marked": "{+The substrate does not stand alone; it sits among the other organs of the agent's cognition and coordinates them. Each retains its autonomous function and gains a coordination point.+}"
  },
  {
   "section": "9.1 Identity",
   "old": null,
   "new": "### 9.1 Identity",
   "marked": "{+### 9.1 Identity+}"
  },
  {
   "section": "9.1 Identity",
   "old": null,
   "new": "A single persistent identity — personality, values, voice — is loaded into every call the substrate makes: the worker's execution calls, any tiebreak or reflection call, and every subagent dispatch. There is no separate \"planner persona\" to introduce voice discontinuities. The executive and the worker are the same self, wearing different instructions. This is what keeps a parallel fan-out of five subagents reading as one coherent agent rather than five strangers.",
   "marked": "{+A single persistent identity — personality, values, voice — is loaded into every call the substrate makes: the worker's execution calls, any tiebreak or reflection call, and every subagent dispatch. There is no separate \"planner persona\" to introduce voice discontinuities. The executive and the worker are the same self, wearing different instructions. This is what keeps a parallel fan-out of five subagents reading as one coherent agent rather than five strangers.+}"
  },
  {
   "section": "9.2 Memory",
   "old": null,
   "new": "### 9.2 Memory",
   "marked": "{+### 9.2 Memory+}"
  },
  {
   "section": "9.2 Memory",
   "old": null,
   "new": "Memory retrieval supplies the context the matcher and the worker share, and the substrate uses it two ways. Recipe-contextual retrieval injects prior executions of the same recipe class into the plan (\"last time this recipe ran on this module, the root cause was in the injection layer\"). Reflection-driven writes push freshly learned lessons back through the indexing pipeline so they are retrievable next session. Bi-temporal validity on memory edges — facts that become *superseded* rather than overwritten — is the natural upgrade path here, so a recipe's contextual hints reflect what is true *now* rather than what was once true.",
   "marked": "{+Memory retrieval supplies the context the matcher and the worker share, and the substrate uses it two ways. Recipe-contextual retrieval injects prior executions of the same recipe class into the plan (\"last time this recipe ran on this module, the root cause was in the injection layer\"). Reflection-driven writes push freshly learned lessons back through the indexing pipeline so they are retrievable next session. Bi-temporal validity on memory edges — facts that become *superseded* rather than overwritten — is the natural upgrade path here, so a recipe's contextual hints reflect what is true *now* rather than what was once true.+}"
  },
  {
   "section": "9.3 Learned action gating",
   "old": null,
   "new": "### 9.3 Learned action gating",
   "marked": "{+### 9.3 Learned action gating+}"
  },
  {
   "section": "9.3 Learned action gating",
   "old": null,
   "new": "A learned action-gating system (the agent's affective intuition for which operations are dangerous) sits beneath the worker's tool calls and complements the recipe's structural gates. The integration is bidirectional: gating now receives recipe context — which step, which recipe, which preconditions were met — so it can learn that \"a file write during the *fix* step, after a successful *diagnose* step, is safe\" while \"a file write with no prior investigation is suspect.\" Structural gates (the recipe's *done-when* criteria) and learned gates (the affective network) reinforce each other; the recipe gives the intuition a vocabulary.",
   "marked": "{+A learned action-gating system (the agent's affective intuition for which operations are dangerous) sits beneath the worker's tool calls and complements the recipe's structural gates. The integration is bidirectional: gating now receives recipe context — which step, which recipe, which preconditions were met — so it can learn that \"a file write during the *fix* step, after a successful *diagnose* step, is safe\" while \"a file write with no prior investigation is suspect.\" Structural gates (the recipe's *done-when* criteria) and learned gates (the affective network) reinforce each other; the recipe gives the intuition a vocabulary.+}"
  },
  {
   "section": "9.4 Deliberation and budget",
   "old": null,
   "new": "### 9.4 Deliberation and budget",
   "marked": "{+### 9.4 Deliberation and budget+}"
  },
  {
   "section": "9.4 Deliberation and budget",
   "old": null,
   "new": "When a step is genuinely high-stakes, it can fan out to multiple models for a structured deliberation and synthesise the result — the recipe step is the natural activation point for cross-model debate that otherwise has no obvious trigger. And the effort router's model-tier choices are exactly where budget-aware prompting belongs: under budget pressure, the same classifier that picks \"maximum\" can be told to step down a tier, so the executive regulates spend as well as effort.",
   "marked": "{+When a step is genuinely high-stakes, it can fan out to multiple models for a structured deliberation and synthesise the result — the recipe step is the natural activation point for cross-model debate that otherwise has no obvious trigger. And the effort router's model-tier choices are exactly where budget-aware prompting belongs: under budget pressure, the same classifier that picks \"maximum\" can be told to step down a tier, so the executive regulates spend as well as effort.+}"
  },
  {
   "section": "9.5 Reflection, orchestrated",
   "old": null,
   "new": "### 9.5 Reflection, orchestrated",
   "marked": "{+### 9.5 Reflection, orchestrated+}"
  },
  {
   "section": "9.5 Reflection, orchestrated",
   "old": null,
   "new": "Post-action reflection is no longer a turn-by-turn ritual that fires regardless of whether anything happened. The substrate scales it to the work: a full reflection (with recipe context, execution trace, and plan-versus-outcome comparison) after a substantive recipe completes; a lightweight pass after a simple task; an extended root-cause reflection after a failure — with the authority to *recommend a recipe update*. Matching reflection depth to task complexity preserves the compounding benefit of learning while eliminating the latency tax of reflecting on a greeting. Reflection is the ADAPT phase of the cycle, and its most important output is sometimes not a memory note but an improved recipe.",
   "marked": "{+Post-action reflection is no longer a turn-by-turn ritual that fires regardless of whether anything happened. The substrate scales it to the work: a full reflection (with recipe context, execution trace, and plan-versus-outcome comparison) after a substantive recipe completes; a lightweight pass after a simple task; an extended root-cause reflection after a failure — with the authority to *recommend a recipe update*. Matching reflection depth to task complexity preserves the compounding benefit of learning while eliminating the latency tax of reflecting on a greeting. Reflection is the ADAPT phase of the cycle, and its most important output is sometimes not a memory note but an improved recipe.+}"
  },
  {
   "section": "Appendix A: Recipe Execution Pseudocode",
   "old": "## Appendix A: Recipe Execution Pseudocode",
   "new": null,
   "marked": "[-## Appendix A: Recipe Execution Pseudocode-]"
  },
  {
   "section": "Appendix A: Recipe Execution Pseudocode",
   "old": "``` ALGORITHM: RecipeExecution(user_message, context, recipe_library)",
   "new": null,
   "marked": "[-``` ALGORITHM: RecipeExecution(user_message, context, recipe_library)-]"
  },
  {
   "section": "Appendix A: Recipe Execution Pseudocode",
   "old": "Input: user_message (raw user request) context (SOUL.md, memory hierarchy, session history) recipe_library (set of available recipes) Output: response to user, set of memory writes W",
   "new": null,
   "marked": "[-Input: user_message (raw user request) context (SOUL.md, memory hierarchy, session history) recipe_library (set of available recipes) Output: response to user, set of memory writes W-]"
  },
  {
   "section": "Phase 1: PLAN (cache-shared LLM call) intent <- classify_intent(user_message) if intent.complexity < THRESHOLD_SIMPLE: return passthrough(user_message, context) # no orchestration",
   "old": "# Phase 1: PLAN (cache-shared LLM call) intent <- classify_intent(user_message) if intent.complexity < THRESHOLD_SIMPLE: return passthrough(user_message, context) # no orchestration",
   "new": null,
   "marked": "[-# Phase 1: PLAN (cache-shared LLM call) intent <- classify_intent(user_message) if intent.complexity < THRESHOLD_SIMPLE: return passthrough(user_message, context) # no orchestration-]"
  },
  {
   "section": "Phase 1: PLAN (cache-shared LLM call) intent <- classify_intent(user_message) if intent.complexity < THRESHOLD_SIMPLE: return passthrough(user_message, context) # no orchestration",
   "old": "recipe <- select_recipe(intent, recipe_library) plan <- compose_plan(recipe, context)",
   "new": null,
   "marked": "[-recipe <- select_recipe(intent, recipe_library) plan <- compose_plan(recipe, context)-]"
  },
  {
   "section": "Phase 1: PLAN (cache-shared LLM call) intent <- classify_intent(user_message) if intent.complexity < THRESHOLD_SIMPLE: return passthrough(user_message, context) # no orchestration",
   "old": "if plan.estimated_duration > 5 minutes: present_plan_to_user(plan) if user.redirects: plan <- revise_plan(user.feedback)",
   "new": null,
   "marked": "[-if plan.estimated_duration > 5 minutes: present_plan_to_user(plan) if user.redirects: plan <- revise_plan(user.feedback)-]"
  },
  {
   "section": "Phase 1: PLAN (cache-shared LLM call) intent <- classify_intent(user_message) if intent.complexity < THRESHOLD_SIMPLE: return passthrough(user_message, context) # no orchestration",
   "old": "subagents <- allocate_subagents(plan, context)",
   "new": null,
   "marked": "[-subagents <- allocate_subagents(plan, context)-]"
  },
  {
   "section": "Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "old": "# Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "new": null,
   "marked": "[-# Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)-]"
  },
  {
   "section": "Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "old": "while not S.complete: events <- collect_events(workers, timeout=S.expected_duration)",
   "new": null,
   "marked": "[-while not S.complete: events <- collect_events(workers, timeout=S.expected_duration)-]"
  },
  {
   "section": "Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "old": "if stall_detected(events, S): intervene(workers, S, context)",
   "new": null,
   "marked": "[-if stall_detected(events, S): intervene(workers, S, context)-]"
  },
  {
   "section": "Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "old": "if cross_subagent_update(events): relay_findings(events, subagents)",
   "new": null,
   "marked": "[-if cross_subagent_update(events): relay_findings(events, subagents)-]"
  },
  {
   "section": "Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "old": "emit_progress(S, workers)",
   "new": null,
   "marked": "[-emit_progress(S, workers)-]"
  },
  {
   "section": "Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "old": "if not gate_satisfied(S.gate, workers.output): if S.failure_handler exists: execute(S.failure_handler) else: escalate_to_user(S, workers.output)",
   "new": null,
   "marked": "[-if not gate_satisfied(S.gate, workers.output): if S.failure_handler exists: execute(S.failure_handler) else: escalate_to_user(S, workers.output)-]"
  },
  {
   "section": "Phase 2: EXECUTE (supervised subagent dispatch) for each step S in plan.steps: workers <- subagents[S] dispatch(workers, S.task, S.tools)",
   "old": "response <- aggregate_results(plan, subagents)",
   "new": null,
   "marked": "[-response <- aggregate_results(plan, subagents)-]"
  },
  {
   "section": "Phase 3: REFLECT (cache-shared LLM call) reflection_context <- { recipe: recipe, plan: plan, execution_trace: subagents.traces, response: response }",
   "old": "# Phase 3: REFLECT (cache-shared LLM call) reflection_context <- { recipe: recipe, plan: plan, execution_trace: subagents.traces, response: response }",
   "new": null,
   "marked": "[-# Phase 3: REFLECT (cache-shared LLM call) reflection_context <- { recipe: recipe, plan: plan, execution_trace: subagents.traces, response: response }-]"
  },
  {
   "section": "Phase 3: REFLECT (cache-shared LLM call) reflection_context <- { recipe: recipe, plan: plan, execution_trace: subagents.traces, response: response }",
   "old": "W <- FractalReflection(reflection_context, memory_files)",
   "new": null,
   "marked": "[-W <- FractalReflection(reflection_context, memory_files)-]"
  },
  {
   "section": "Phase 3: REFLECT (cache-shared LLM call) reflection_context <- { recipe: recipe, plan: plan, execution_trace: subagents.traces, response: response }",
   "old": "if reflection.recipe_update: update_recipe(recipe, reflection.recipe_update)",
   "new": null,
   "marked": "[-if reflection.recipe_update: update_recipe(recipe, reflection.recipe_update)-]"
  },
  {
   "section": "Phase 3: REFLECT (cache-shared LLM call) reflection_context <- { recipe: recipe, plan: plan, execution_trace: subagents.traces, response: response }",
   "old": "return response, W ```",
   "new": null,
   "marked": "[-return response, W ```-]"
  },
  {
   "section": "Appendix B: Built-in Recipe Index",
   "old": "## Appendix B: Built-in Recipe Index",
   "new": null,
   "marked": "[-## Appendix B: Built-in Recipe Index-]"
  },
  {
   "section": "Appendix B: Built-in Recipe Index",
   "old": "| Recipe | Trigger Patterns | Steps | Key Gate | |--------|-----------------|-------|----------| | debug | \"fix\", \"bug\", stack traces | 6 | Reproduce before fix | | feature | \"add\", \"implement\" | 7 | Design before code | | investigate | \"why\", \"check\" | 5 | Scope before search | | refactor | \"clean up\", \"refactor\" | 6 | Measure before change | | review | PR URLs, diff blocks | 5 | Read completely before opining | | deploy | \"deploy\", \"release\" | 7 | Verify at every stage |",
   "new": null,
   "marked": "[-| Recipe | Trigger Patterns | Steps | Key Gate | |--------|-----------------|-------|----------| | debug | \"fix\", \"bug\", stack traces | 6 | Reproduce before fix | | feature | \"add\", \"implement\" | 7 | Design before code | | investigate | \"why\", \"check\" | 5 | Scope before search | | refactor | \"clean up\", \"refactor\" | 6 | Measure before change | | review | PR URLs, diff blocks | 5 | Read completely before opining | | deploy | \"deploy\", \"release\" | 7 | Verify at every stage |-]"
  },
  {
   "section": "10. Evaluation Design",
   "old": null,
   "new": "## 10. Evaluation Design",
   "marked": "{+## 10. Evaluation Design+}"
  },
  {
   "section": "10.1 First-attempt accuracy",
   "old": null,
   "new": "### 10.1 First-attempt accuracy",
   "marked": "{+### 10.1 First-attempt accuracy+}"
  },
  {
   "section": "10.1 First-attempt accuracy",
   "old": null,
   "new": "The substrate should raise first-attempt accuracy by structurally preventing the most common failure modes — the same way the prefrontal cortex prevents impulsive errors by holding the plan. Each gate targets a known failure:",
   "marked": "{+The substrate should raise first-attempt accuracy by structurally preventing the most common failure modes — the same way the prefrontal cortex prevents impulsive errors by holding the plan. Each gate targets a known failure:+}"
  },
  {
   "section": "10.1 First-attempt accuracy",
   "old": null,
   "new": "| Failure mode (executive deficit) | Mechanism that prevents it | |----------------------------------|----------------------------| | Fixing before reproducing (impulse) | debug recipe's *reproduce* gate before *fix* | | Coding before designing (impulse) | feature recipe's *design* gate before *implement* | | Searching before scoping (impulse) | investigate recipe's *scope* gate before *search* | | Declaring done before verifying (premature closure) | every recipe's terminal *verify* step | | Stopping an iterative task early (under-persistence) | `until-dry` loops that run to exhaustion | | Over- or under-investing effort (mis-regulation) | effort router driving model/thinking/tokens per tier |",
   "marked": "{+| Failure mode (executive deficit) | Mechanism that prevents it | |----------------------------------|----------------------------| | Fixing before reproducing (impulse) | debug recipe's *reproduce* gate before *fix* | | Coding before designing (impulse) | feature recipe's *design* gate before *implement* | | Searching before scoping (impulse) | investigate recipe's *scope* gate before *search* | | Declaring done before verifying (premature closure) | every recipe's terminal *verify* step | | Stopping an iterative task early (under-persistence) | `until-dry` loops that run to exhaustion | | Over- or under-investing effort (mis-regulation) | effort router driving model/thinking/tokens per tier |+}"
  },
  {
   "section": "10.1 First-attempt accuracy",
   "old": null,
   "new": "The headline metric is the change in weighted first-attempt accuracy across a representative task mix, attributing each delta to the gate responsible.",
   "marked": "{+The headline metric is the change in weighted first-attempt accuracy across a representative task mix, attributing each delta to the gate responsible.+}"
  },
  {
   "section": "10.2 Matching quality",
   "old": null,
   "new": "### 10.2 Matching quality",
   "marked": "{+### 10.2 Matching quality+}"
  },
  {
   "section": "10.2 Matching quality",
   "old": null,
   "new": "Matching is evaluated on a labelled set of prompts with a known correct recipe (including paraphrases, inflections, and typos), reporting top-1 and top-3 accuracy and, separately, the **NO-MATCH precision** — how often a true coverage gap is correctly flagged versus a real match being missed. The confidence tiers are evaluated by calibration: high-confidence selections should be right far more often than low-confidence ones.",
   "marked": "{+Matching is evaluated on a labelled set of prompts with a known correct recipe (including paraphrases, inflections, and typos), reporting top-1 and top-3 accuracy and, separately, the **NO-MATCH precision** — how often a true coverage gap is correctly flagged versus a real match being missed. The confidence tiers are evaluated by calibration: high-confidence selections should be right far more often than low-confidence ones.+}"
  },
  {
   "section": "10.3 Authoring quality and library health",
   "old": null,
   "new": "### 10.3 Authoring quality and library health",
   "marked": "{+### 10.3 Authoring quality and library health+}"
  },
  {
   "section": "10.3 Authoring quality and library health",
   "old": null,
   "new": "For on-the-fly authoring: the rate at which an authored recipe is re-matched and successfully reused on subsequent turns (the loop-closure rate), the validation rejection rate (how often a draft is malformed), and a periodic audit of library health — duplicate slugs, dead recipes that never match, and recipes whose steps never satisfy their gates.",
   "marked": "{+For on-the-fly authoring: the rate at which an authored recipe is re-matched and successfully reused on subsequent turns (the loop-closure rate), the validation rejection rate (how often a draft is malformed), and a periodic audit of library health — duplicate slugs, dead recipes that never match, and recipes whose steps never satisfy their gates.+}"
  },
  {
   "section": "10.4 Loop termination",
   "old": null,
   "new": "### 10.4 Loop termination",
   "marked": "{+### 10.4 Loop termination+}"
  },
  {
   "section": "10.4 Loop termination",
   "old": null,
   "new": "Every loop mode is checked for the two failure directions: premature termination (an `until-dry` loop that stops while work remains) and non-termination (caught structurally by the hard cap, but worth measuring as *how often the cap is the thing that stops a loop*, which signals a mis-specified condition).",
   "marked": "{+Every loop mode is checked for the two failure directions: premature termination (an `until-dry` loop that stops while work remains) and non-termination (caught structurally by the hard cap, but worth measuring as *how often the cap is the thing that stops a loop*, which signals a mis-specified condition).+}"
  },
  {
   "section": "10.5 Cost and latency",
   "old": null,
   "new": "### 10.5 Cost and latency",
   "marked": "{+### 10.5 Cost and latency+}"
  },
  {
   "section": "10.5 Cost and latency",
   "old": null,
   "new": "Because matching is local and effort-gated, the per-turn overhead should be near-zero for trivial turns and small for the rest. The evaluation reports overhead as a function of effort tier and of context-cache hit rate, and the latency the executive adds *before* visible work — which, for complex turns, is expected to be repaid many times over by fewer wrong turns and the user's ability to watch progress rather than wait blindly.",
   "marked": "{+Because matching is local and effort-gated, the per-turn overhead should be near-zero for trivial turns and small for the rest. The evaluation reports overhead as a function of effort tier and of context-cache hit rate, and the latency the executive adds *before* visible work — which, for complex turns, is expected to be repaid many times over by fewer wrong turns and the user's ability to watch progress rather than wait blindly.+}"
  },
  {
   "section": "10.5 Cost and latency",
   "old": null,
   "new": "---",
   "marked": "{+---+}"
  },
  {
   "section": "11. Suggested Diagrams (D2)",
   "old": null,
   "new": "## 11. Suggested Diagrams (D2)",
   "marked": "{+## 11. Suggested Diagrams (D2)+}"
  },
  {
   "section": "11. Suggested Diagrams (D2)",
   "old": null,
   "new": "These are descriptions for a designer; the diagrams themselves are not drawn here. D2 is suggested for its clean layered layout and first-class containers.",
   "marked": "{+These are descriptions for a designer; the diagrams themselves are not drawn here. D2 is suggested for its clean layered layout and first-class containers.+}"
  },
  {
   "section": "11. Suggested Diagrams (D2)",
   "old": null,
   "new": "1. **The executive-function cycle (Figure 1).** A vertical D2 flow of the five phases — PLAN, MATCH/COMPOSE/AUTHOR, EXECUTE (with loops), OBSERVE, ADAPT — each phase as a container, annotated on the right with the prefrontal function it implements. A back-edge from ADAPT to the recipe library shows recipe improvement feeding the next turn.",
   "marked": "{+1. **The executive-function cycle (Figure 1).** A vertical D2 flow of the five phases — PLAN, MATCH/COMPOSE/AUTHOR, EXECUTE (with loops), OBSERVE, ADAPT — each phase as a container, annotated on the right with the prefrontal function it implements. A back-edge from ADAPT to the recipe library shows recipe improvement feeding the next turn.+}"
  },
  {
   "section": "11. Suggested Diagrams (D2)",
   "old": null,
   "new": "2. **The recipe-run life-cycle state machine (Figure 2).** A D2 state diagram of `searched → matched → merged/composed → seeded → running → looping/composing → done`, with the `no-match → authoring → matchable-next-turn` branch and the `no-match → trivial → idle` branch. Annotate each transition with the provenance verb it emits, since the figure doubles as a legend for the RECIPES trail.",
   "marked": "{+2. **The recipe-run life-cycle state machine (Figure 2).** A D2 state diagram of `searched → matched → merged/composed → seeded → running → looping/composing → done`, with the `no-match → authoring → matchable-next-turn` branch and the `no-match → trivial → idle` branch. Annotate each transition with the provenance verb it emits, since the figure doubles as a legend for the RECIPES trail.+}"
  },
  {
   "section": "11. Suggested Diagrams (D2)",
   "old": null,
   "new": "3. **Composition algebra — inline vs. call.** A side-by-side D2 figure contrasting `composes:` (static step-merge: sub-recipe steps flattened into one plan, with de-dup) against `uses:` (dynamic call: a step transferring control to a nested plan on a child session and returning), with the depth cap and cycle guard drawn explicitly as the recursion's safety rails.",
   "marked": "{+3. **Composition algebra — inline vs. call.** A side-by-side D2 figure contrasting `composes:` (static step-merge: sub-recipe steps flattened into one plan, with de-dup) against `uses:` (dynamic call: a step transferring control to a nested plan on a child session and returning), with the depth cap and cycle guard drawn explicitly as the recursion's safety rails.+}"
  },
  {
   "section": "11. Suggested Diagrams (D2)",
   "old": null,
   "new": "4. **The RECIPES panel anatomy.** A D2 container diagram of the panel's stacked sections — Discovery, Composition, Plan-with-badges, per-step Fan-out (subagent vitals), and the compact/expandable Trail — placed beside the chat surface, with a bold boundary marking the split-of-concerns invariant (substance left, mechanics right).",
   "marked": "{+4. **The RECIPES panel anatomy.** A D2 container diagram of the panel's stacked sections — Discovery, Composition, Plan-with-badges, per-step Fan-out (subagent vitals), and the compact/expandable Trail — placed beside the chat surface, with a bold boundary marking the split-of-concerns invariant (substance left, mechanics right).+}"
  },
  {
   "section": "11. Suggested Diagrams (D2)",
   "old": null,
   "new": "---",
   "marked": "{+---+}"
  },
  {
   "section": "12. Conclusion",
   "old": null,
   "new": "## 12. Conclusion",
   "marked": "{+## 12. Conclusion+}"
  },
  {
   "section": "12. Conclusion",
   "old": null,
   "new": "The history of engineering is the history of structure replacing improvisation: not by making practitioners smarter, but by giving their work a shape that makes good outcomes the default. The prefrontal cortex did the same thing for cognition long before engineering existed — it is the structure that lets a capable brain act coherently rather than impulsively, by holding the plan, selecting the program, sequencing the sub-routines, suppressing the wrong move, watching the result, and metering the effort.",
   "marked": "{+The history of engineering is the history of structure replacing improvisation: not by making practitioners smarter, but by giving their work a shape that makes good outcomes the default. The prefrontal cortex did the same thing for cognition long before engineering existed — it is the structure that lets a capable brain act coherently rather than impulsively, by holding the plan, selecting the program, sequencing the sub-routines, suppressing the wrong move, watching the result, and metering the effort.+}"
  },
  {
   "section": "12. Conclusion",
   "old": null,
   "new": "A deployed language agent has the capability of a frontier model and, without an executive, the coherence of a reflex. This paper has argued that the missing executive is best built as a **recipe execution substrate**, and that the substrate becomes genuinely executive only when it can do six things: match intent to a program robustly and with calibrated confidence; compose programs from programs, statically and dynamically, with the safety rails a call stack requires; author a new program when none fits and keep it; loop a program under a bounded condition; regulate the effort each turn deserves and drive the turn accordingly; and make the whole thing observable without drowning the answer.",
   "marked": "{+A deployed language agent has the capability of a frontier model and, without an executive, the coherence of a reflex. This paper has argued that the missing executive is best built as a **recipe execution substrate**, and that the substrate becomes genuinely executive only when it can do six things: match intent to a program robustly and with calibrated confidence; compose programs from programs, statically and dynamically, with the safety rails a call stack requires; author a new program when none fits and keep it; loop a program under a bounded condition; regulate the effort each turn deserves and drive the turn accordingly; and make the whole thing observable without drowning the answer.+}"
  },
  {
   "section": "12. Conclusion",
   "old": null,
   "new": "Of these, the loop is the quiet pivot. Sequence and selection make a checklist; sequence, selection, *and bounded iteration* make a substrate expressive enough to encode the iterative, exhaust-the-search, retry-until-clean work that real tasks demand — which is exactly the structural gap that separated a static playbook from a hand-coded workflow, now closed. And on-the-fly authoring is the quiet flywheel: a substrate that writes its own missing programs grows its competence inside the very conversations that expose its gaps.",
   "marked": "{+Of these, the loop is the quiet pivot. Sequence and selection make a checklist; sequence, selection, *and bounded iteration* make a substrate expressive enough to encode the iterative, exhaust-the-search, retry-until-clean work that real tasks demand — which is exactly the structural gap that separated a static playbook from a hand-coded workflow, now closed. And on-the-fly authoring is the quiet flywheel: a substrate that writes its own missing programs grows its competence inside the very conversations that expose its gaps.+}"
  },
  {
   "section": "12. Conclusion",
   "old": null,
   "new": "The intern who never repeats a mistake writes things down. The intern who gets promoted writes *recipes* — programs that make the next person as effective as they are. The agent described here writes its own recipes, composes them, loops them, runs them at the right intensity, and shows its work. That is not a better worker. It is an executive.",
   "marked": "{+The intern who never repeats a mistake writes things down. The intern who gets promoted writes *recipes* — programs that make the next person as effective as they are. The agent described here writes its own recipes, composes them, loops them, runs them at the right intensity, and shows its work. That is not a better worker. It is an executive.+}"
  },
  {
   "section": "12. Conclusion",
   "old": null,
   "new": "---",
   "marked": "{+---+}"
  },
  {
   "section": "References to Companion Papers",
   "old": null,
   "new": "## References to Companion Papers",
   "marked": "{+## References to Companion Papers+}"
  },
  {
   "section": "References to Companion Papers",
   "old": null,
   "new": "The following companion working papers describe the surrounding organs of the agent's cognition. Each is summarised inline; this paper is self-contained and does not depend on having read them.",
   "marked": "{+The following companion working papers describe the surrounding organs of the agent's cognition. Each is summarised inline; this paper is self-contained and does not depend on having read them.+}"
  },
  {
   "section": "References to Companion Papers",
   "old": null,
   "new": "- **ENGRAM / Total Recall (memory consolidation).** The episodic-memory and consolidation layer. Supplies the retrieval the matcher and worker share, and the write path the ADAPT phase uses. - **HIPPOCAMPUS (instant recall).** The fast structured-index layer over memory; the auto-seed hot path depends on fast, cache-friendly retrieval. Bi-temporal validity on edges keeps recipe hints current. - **MNEMOSYNE (memory enhancements).** Contradiction handling, compaction capture, task-conditioned scoring — the natural place to make retrieval recipe-aware. - **CEREBELLUM (sleep consolidation).** Background consolidation and failure-driven self-improvement — the principled engine for recipe *evolution* (mutate + benchmark against real traces, keep an archive). - **SYNAPSE / Round Table (multi-model deliberation).** Cross-provider debate; a high-stakes recipe step is the natural trigger. - **AMYGDALA (learned intuition).** A neural action-gating system; learned gates sit beneath tool calls and complement the recipe's structural gates. - **MYELIN (budget prompting).** The effort router's model-tier choice is where budget awareness applies. - **The Wondering Machine (curiosity / intrinsic motivation).** Between tasks, an intrinsically motivated agent could mine the accumulated NO-MATCH signal to *propose* recipes to author.",
   "marked": "{+- **ENGRAM / Total Recall (memory consolidation).** The episodic-memory and consolidation layer. Supplies the retrieval the matcher and worker share, and the write path the ADAPT phase uses. - **HIPPOCAMPUS (instant recall).** The fast structured-index layer over memory; the auto-seed hot path depends on fast, cache-friendly retrieval. Bi-temporal validity on edges keeps recipe hints current. - **MNEMOSYNE (memory enhancements).** Contradiction handling, compaction capture, task-conditioned scoring — the natural place to make retrieval recipe-aware. - **CEREBELLUM (sleep consolidation).** Background consolidation and failure-driven self-improvement — the principled engine for recipe *evolution* (mutate + benchmark against real traces, keep an archive). - **SYNAPSE / Round Table (multi-model deliberation).** Cross-provider debate; a high-stakes recipe step is the natural trigger. - **AMYGDALA (learned intuition).** A neural action-gating system; learned gates sit beneath tool calls and complement the recipe's structural gates. - **MYELIN (budget prompting).** The effort router's model-tier choice is where budget awareness applies. - **The Wondering Machine (curiosity / intrinsic motivation).** Between tasks, an intrinsically motivated agent could mine the accumulated NO-MATCH signal to *propose* recipes to author.+}"
  },
  {
   "section": "References to Companion Papers",
   "old": null,
   "new": "---",
   "marked": "{+---+}"
  },
  {
   "section": "Appendix A — The Turn, End to End (Pseudocode)",
   "old": null,
   "new": "## Appendix A — The Turn, End to End (Pseudocode)",
   "marked": "{+## Appendix A — The Turn, End to End (Pseudocode)+}"
  },
  {
   "section": "Appendix A — The Turn, End to End (Pseudocode)",
   "old": null,
   "new": "``` function HANDLE_TURN(prompt, context, library): # PLAN: effort regulation tier <- CLASSIFY_EFFORT(prompt) if tier != \"trivial\": inject_effort_guidance(tier) if tier == \"trivial\": return answer_inline(prompt, context) # executive dormant",
   "marked": "{+``` function HANDLE_TURN(prompt, context, library): # PLAN: effort regulation tier <- CLASSIFY_EFFORT(prompt) if tier != \"trivial\": inject_effort_guidance(tier) if tier == \"trivial\": return answer_inline(prompt, context) # executive dormant+}"
  },
  {
   "section": "MATCH / COMPOSE / AUTHOR: task-set selection if context.has_in_progress_plan(): plan <- context.resume_plan() # never clobber an explicit/prior plan else: result <- MATCH_RECIPES(prompt, library) # fuzzy + confidence emit_trail(\"searched\", catalog_size) if result.confidence == \"none\": emit_trail(\"no-match\") spec <- AUTHOR_RECIPE(prompt) # synthesise + validate + persist if VALIDATE(spec).ok: library.add(spec); emit_trail(\"authored\", spec.slug) plan <- seed_plan_from(spec) else: plan <- implicit_two_step_plan() else: emit_trail(\"matched\", result.matches) plan <- BUILD_MERGED_PLAN(result.matches, library) # composes: inlined if plan.from_multiple(): emit_trail(\"merged\", plan.sources) persist(plan)",
   "old": null,
   "new": "# MATCH / COMPOSE / AUTHOR: task-set selection if context.has_in_progress_plan(): plan <- context.resume_plan() # never clobber an explicit/prior plan else: result <- MATCH_RECIPES(prompt, library) # fuzzy + confidence emit_trail(\"searched\", catalog_size) if result.confidence == \"none\": emit_trail(\"no-match\") spec <- AUTHOR_RECIPE(prompt) # synthesise + validate + persist if VALIDATE(spec).ok: library.add(spec); emit_trail(\"authored\", spec.slug) plan <- seed_plan_from(spec) else: plan <- implicit_two_step_plan() else: emit_trail(\"matched\", result.matches) plan <- BUILD_MERGED_PLAN(result.matches, library) # composes: inlined if plan.from_multiple(): emit_trail(\"merged\", plan.sources) persist(plan)",
   "marked": "{+# MATCH / COMPOSE / AUTHOR: task-set selection if context.has_in_progress_plan(): plan <- context.resume_plan() # never clobber an explicit/prior plan else: result <- MATCH_RECIPES(prompt, library) # fuzzy + confidence emit_trail(\"searched\", catalog_size) if result.confidence == \"none\": emit_trail(\"no-match\") spec <- AUTHOR_RECIPE(prompt) # synthesise + validate + persist if VALIDATE(spec).ok: library.add(spec); emit_trail(\"authored\", spec.slug) plan <- seed_plan_from(spec) else: plan <- implicit_two_step_plan() else: emit_trail(\"matched\", result.matches) plan <- BUILD_MERGED_PLAN(result.matches, library) # composes: inlined if plan.from_multiple(): emit_trail(\"merged\", plan.sources) persist(plan)+}"
  },
  {
   "section": "EXECUTE (loops + sub-recipe calls): sequencing for group in plan.parallelism_groups: # groups run sequentially dispatch_all(group) in parallel: # steps within a group fan out for step in group: loop <- parse_loop(step); sub <- parse_uses(step) if loop: RUN_LOOPED_STEP(step, loop, context) elif sub: emit_trail(\"composed\", sub); RUN_RECIPE(sub, child(context)) else: dispatch_worker(step) # OBSERVE: panel updates with step status + subagent vitals barrier() response <- aggregate(plan)",
   "old": null,
   "new": "# EXECUTE (loops + sub-recipe calls): sequencing for group in plan.parallelism_groups: # groups run sequentially dispatch_all(group) in parallel: # steps within a group fan out for step in group: loop <- parse_loop(step); sub <- parse_uses(step) if loop: RUN_LOOPED_STEP(step, loop, context) elif sub: emit_trail(\"composed\", sub); RUN_RECIPE(sub, child(context)) else: dispatch_worker(step) # OBSERVE: panel updates with step status + subagent vitals barrier() response <- aggregate(plan)",
   "marked": "{+# EXECUTE (loops + sub-recipe calls): sequencing for group in plan.parallelism_groups: # groups run sequentially dispatch_all(group) in parallel: # steps within a group fan out for step in group: loop <- parse_loop(step); sub <- parse_uses(step) if loop: RUN_LOOPED_STEP(step, loop, context) elif sub: emit_trail(\"composed\", sub); RUN_RECIPE(sub, child(context)) else: dispatch_worker(step) # OBSERVE: panel updates with step status + subagent vitals barrier() response <- aggregate(plan)+}"
  },
  {
   "section": "ADAPT: learning + regulation reflection <- REFLECT(scaled_to = tier, trace = plan.trace) persist_lessons(reflection.memory_writes) if reflection.recipe_update: library.update(reflection.recipe_update) close_plan(plan) return response ```",
   "old": null,
   "new": "# ADAPT: learning + regulation reflection <- REFLECT(scaled_to = tier, trace = plan.trace) persist_lessons(reflection.memory_writes) if reflection.recipe_update: library.update(reflection.recipe_update) close_plan(plan) return response ```",
   "marked": "{+# ADAPT: learning + regulation reflection <- REFLECT(scaled_to = tier, trace = plan.trace) persist_lessons(reflection.memory_writes) if reflection.recipe_update: library.update(reflection.recipe_update) close_plan(plan) return response ```+}"
  },
  {
   "section": "Appendix B — Recipe Document Schema (Illustrative)",
   "old": null,
   "new": "## Appendix B — Recipe Document Schema (Illustrative)",
   "marked": "{+## Appendix B — Recipe Document Schema (Illustrative)+}"
  },
  {
   "section": "Appendix B — Recipe Document Schema (Illustrative)",
   "old": null,
   "new": "``` --- frontmatter --- schema: recipe/1.0 slug: debug # also the on-disk directory name; traversal-safe title: Debug & Fix summary: Systematic debugging — reproduce, diagnose, fix, verify tags: [bug, error, crash, broken, not working, fails, exception, fix] composes: [] # static step-merge (recipes built from recipes) parallelism: groups: [[0],[1],[2],[3]] # 0-based; serial chain (data-dependent)",
   "marked": "{+``` --- frontmatter --- schema: recipe/1.0 slug: debug # also the on-disk directory name; traversal-safe title: Debug & Fix summary: Systematic debugging — reproduce, diagnose, fix, verify tags: [bug, error, crash, broken, not working, fails, exception, fix] composes: [] # static step-merge (recipes built from recipes) parallelism: groups: [[0],[1],[2],[3]] # 0-based; serial chain (data-dependent)+}"
  },
  {
   "section": "Appendix B — Recipe Document Schema (Illustrative)",
   "old": null,
   "new": "--- body --- ### 1. Reproduce done-when: the exact failure is described with evidence Read the error. Run the failing case. Identify the trigger conditions.",
   "marked": "{+--- body --- ### 1. Reproduce done-when: the exact failure is described with evidence Read the error. Run the failing case. Identify the trigger conditions.+}"
  },
  {
   "section": "2. Diagnose done-when: root cause identified with file:line Trace the cause through code; follow evidence, do not guess.",
   "old": null,
   "new": "### 2. Diagnose done-when: root cause identified with file:line Trace the cause through code; follow evidence, do not guess.",
   "marked": "{+### 2. Diagnose done-when: root cause identified with file:line Trace the cause through code; follow evidence, do not guess.+}"
  },
  {
   "section": "3. Fix done-when: minimal change applied Smallest fix that addresses the root cause. One concern per change.",
   "old": null,
   "new": "### 3. Fix done-when: minimal change applied Smallest fix that addresses the root cause. One concern per change.",
   "marked": "{+### 3. Fix done-when: minimal change applied Smallest fix that addresses the root cause. One concern per change.+}"
  },
  {
   "section": "4. Verify done-when: the original error is gone and tests pass loop: until-dry max 3 # re-run verification until nothing new fails Run the failing test, then the broader suite, then trigger the original scenario. ```",
   "old": null,
   "new": "### 4. Verify done-when: the original error is gone and tests pass loop: until-dry max 3 # re-run verification until nothing new fails Run the failing test, then the broader suite, then trigger the original scenario. ```",
   "marked": "{+### 4. Verify done-when: the original error is gone and tests pass loop: until-dry max 3 # re-run verification until nothing new fails Run the failing test, then the broader suite, then trigger the original scenario. ```+}"
  },
  {
   "section": "4. Verify done-when: the original error is gone and tests pass loop: until-dry max 3 # re-run verification until nothing new fails Run the failing test, then the broader suite, then trigger the original scenario. ```",
   "old": null,
   "new": "*(In a composite recipe, a step body might instead open with `uses: adversarial-verify` to call that recipe as a sub-routine, or with both `loop: until-dry` and `uses: <recipe>` to iterate a whole nested workflow to exhaustion.)*",
   "marked": "{+*(In a composite recipe, a step body might instead open with `uses: adversarial-verify` to call that recipe as a sub-routine, or with both `loop: until-dry` and `uses: <recipe>` to iterate a whole nested workflow to exhaustion.)*+}"
  }
 ]
}
