# PREFRONTAL: The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function: v4.0 → v4.1

From v4.0 (30 May) to v4.1 (2 Jun): 7,254 words to 8,800 words, 1,645 words in new or rewritten paragraphs and 99 taken out, 34 paragraphs changed.

## Change note of v4.1

**New section on limitations and what comes next**

Adds section 11, which names five things the design does not do yet: reading a saved plan back after a crash, a library that improves from results, importing recipes from outside, sharing recipes as versioned packages, and searching over alternative recipes. It also says what the section does not claim. The architecture diagram in 2.1 becomes a drawn figure.

## Changed paragraphs

Marks: [-removed-] {+added+}.

### PREFRONTAL v4.1: The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function

# PREFRONTAL [-v4.0:-] {+v4.1:+} The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function

### PREFRONTAL v4.1: The Recipe Execution Substrate — How a Composable, Self-Authoring, Looping Workflow Engine Becomes an Agent's Executive Function

**Oscar Serra¹, Jarvis¹** ¹Independent Research [-*30 May-] {+*2 June+} 2026 — [-v4.0*-] {+v4.1*+}

### 1.2 What a recipe is, and why it is the right unit

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-] {+A+} recipe is *not* a prompt and *not* a script.

### 1.3 The gap this paper closes

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 {+is honest about what the substrate does *not* yet do and lays out the roadmap that closes those gaps; Section 12+} lists suggested diagrams; Section [-12-] {+13+} concludes.

### 2.1 The cycle

[-``` 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 ```-]

### 2.1 The cycle

[-**Figure 1 (described in §11).** The five-phase executive cycle, annotated with the executive function each phase implements.-]

### 2.1 The cycle

{+```{=latex} \begin{figure}[H] \centering \includegraphics[width=\linewidth,height=0.85\textheight,keepaspectratio]{images/fig-cycle.pdf} \caption{The five-phase executive cycle, annotated with the executive function each phase implements. The dashed back-edge shows recipe improvement (the ADAPT phase) feeding the next turn.} \end{figure} ```+}

### 5.1 Closing the no-match loop

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,-] {+and+} 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.

### 8.4 The compact-expand decision trail

[-**Figure 2 (described in §11).** The-] {+```{=latex} \begin{figure}[H] \centering \includegraphics[width=\linewidth,height=0.85\textheight,keepaspectratio]{images/fig-statemachine.pdf} \caption{The+} life-cycle state machine the RECIPES panel renders: [-`searched → matched → merged/composed → seeded → running → looping/composing → done`,-] {+\texttt{searched} $\rightarrow$ \texttt{matched} $\rightarrow$ \texttt{merged/composed} $\rightarrow$ \texttt{seeded} $\rightarrow$ \texttt{running} $\rightarrow$ \texttt{looping/composing} $\rightarrow$ \texttt{done},+} with the [-`no-match →-] {+no-match $\rightarrow$+} authoring [-→ matchable-next-turn`-] {+$\rightarrow$ matchable-next-turn+} branch and the [-`no-match →-] {+no-match $\rightarrow$+} trivial [-→ idle`-] {+$\rightarrow$ idle+} branch. Every transition emits a provenance-trail [-verb.-] {+verb, so the figure doubles as a legend for the RECIPES trail.} \end{figure} ```+}

### 11. Suggested Diagrams (D2)

[-## 11. Suggested Diagrams (D2)-]

### 11. Limitations and Roadmap

{+## 11. Limitations and Roadmap+}

### 11. Limitations and Roadmap

{+The substrate as specified above is the part that ships and runs. This section is deliberate about its boundary: what the six capabilities do *not* yet do, and the concrete next steps that close each gap. The roadmap is ordered by dependency, because the items are not independent — durable state is a prerequisite for the feedback loop, which is a prerequisite for search. Each item names the seam it attaches to, so the roadmap reads as engineering work, not a wish list.+}

### 11.1 The plan is written, not yet read back — durable checkpointing

{+### 11.1 The plan is written, not yet read back — durable checkpointing+}

### 11.1 The plan is written, not yet read back — durable checkpointing

{+The plan-store is the durable spine of the cycle (§2.3), and the paper's claim is that "the plan *is* the agent's working memory, externalised." Today that spine is **write-mostly**. The runner records each step's status and advances the cursor, and the plan schema already reserves a per-step `artifact` field and a plan-level `currentStep`, but the runner always starts at step 0 and never reads back what a finished step produced. So the resume story in §2.3 is currently an aspiration: a plan interrupted at step 3 of 6 by a gateway crash, the 10-minute per-step wall, or a guardian kill restarts from the top rather than resuming at step 4.+}

### 11.1 The plan is written, not yet read back — durable checkpointing

{+Closing this turns "the plan is the program counter" from a description into a guarantee. The work is contained: on entry, read back an `in_progress` plan with a matching recipe reference and set the start index to its cursor, skipping any step already marked done; on each step's success, persist a bounded digest of the done-note into the reserved `artifact` field and carry prior artifacts forward as upstream context for the next step; for a sub-recipe call, bubble the nested plan's terminal result up as the parent step's artifact. No schema change is needed — both fields already exist. The two load-bearing risks are lossiness (a bounded digest can drop context a later step needs — mitigated by keeping the full note in the plan body and the digest in the bounded field) and read-path atomicity (a partially written plan read during resume must quarantine and fall back to a clean restart rather than crash). This is item one because the next two roadmap items both consume per-step outcomes.+}

### 11.2 The library expands but does not yet self-improve — the feedback loop

{+### 11.2 The library expands but does not yet self-improve — the feedback loop+}

### 11.2 The library expands but does not yet self-improve — the feedback loop

{+Section 5 makes the library self-*expanding*: it authors a recipe when none matches. Section 9.5 makes it self-*updating*: a reflection pass can recommend a recipe change. What is missing is making it self-*improving* — feeding real execution outcomes back into the matcher so the scoring weights (§3.2) stop being hand-tuned constants and become evidence-updated. Right now a high-confidence recipe that fails on every run keeps its high confidence; a class of intent that misses on every turn re-authors from scratch instead of being surfaced once for a durable fix.+}

### 11.2 The library expands but does not yet self-improve — the feedback loop

{+The outcome-capture seam already exists: every plan that closes is a natural training row, so no new call is needed on the hot path. A per-recipe weight delta — derived from closed-plan outcomes plus an explicit "this recipe was wrong" verdict — is read in the scorer and applied after the base score, *before* the confidence tiering. Two guards keep the loop stable: the delta is clamped to a small bounded range so a single mis-attributed failure cannot bury a curated recipe, and the curated base weights remain the floor. The honest caveat is attribution: a closed plan's status reflects the *worker's* execution, not whether the *recipe* was the right structure — so an explicit verdict is higher-signal than an inferred one and should weigh more. The same machinery subsumes the NO-MATCH mining sketched in §3.4: a between-tasks pass buckets the accumulated no-match log by normalised intent and, when a bucket crosses a threshold, proposes a recipe to author — turning authoring from purely reactive into partly active.+}

### 11.3 The format is portable but the ecosystem is not yet a supply — external acquisition

{+### 11.3 The format is portable but the ecosystem is not yet a supply — external acquisition+}

### 11.3 The format is portable but the ecosystem is not yet a supply — external acquisition

{+Section 5.3 establishes `recipe/1.0` as a portable document and the substrate as a general runtime rather than a closed hand-authored set. The portability is real but under-exploited: the matchable library is still almost entirely local. Two outside sources could feed it. Journey kits are a near-native format and the search/install path is already wired to a remote registry; the gaps are a local-only fallback when the registry is unreachable (today it fails silently) and merging remote results with local matches so discovery spans both. Claude Code skills are a *different* shape — a `SKILL.md` plus scripts — and need an adapter that transpiles the skill into a recipe spec and runs it through the **existing** authoring validator (§5.2), so the slug-traversal and phantom-heading guards apply to imported content for free.+}

### 11.3 The format is portable but the ecosystem is not yet a supply — external acquisition

{+The honest limitations here are about trust and fidelity. Skill-to-step transpilation is heuristic — a skill documents *capability*, not always an ordered procedure — so a bad transpile yields a non-executable recipe; gating every import behind the validator and marking bridged recipes low-trust is the guard. Imported content is untrusted, so the sandbox-path resolver that blocks `../` must also refuse to follow symlinks. And an imported `code-review` must not shadow a curated one, so imports are namespaced by owner. Whether bridged recipes are matchable by default or quarantined until a human promotes them is a policy decision, not an engineering one.+}

### 11.4 Recipes are authored but not yet shared as artifacts — the marketplace

{+### 11.4 Recipes are authored but not yet shared as artifacts — the marketplace+}

### 11.4 Recipes are authored but not yet shared as artifacts — the marketplace

{+The capstone of treating a recipe as an artifact is making a tested one a versioned, discoverable object rather than a file that lives in one workshop. The frontmatter already carries owner, version, tested-harness, and authored-by fields, and the publish path is already wired to a remote endpoint, so the remaining work is *semantics* layered on existing plumbing: a semver bump on publish with immutable published versions (a republish that would overwrite an existing version is refused), version-constrained resolution on install (latest / exact / range) with a cache TTL so updates propagate without hammering the API, and a small rating-or-download bonus folded into the same post-score adjustment seam as the feedback loop (§11.2), so there is exactly one place that perturbs base scores. Authored recipes are never auto-published — publishing stays an explicit human action (§5.3) — and only the frontmatter owner may publish a new version of a slug.+}

### 11.4 Recipes are authored but not yet shared as artifacts — the marketplace

{+Two tensions are worth naming rather than hiding. Version immutability collides with the need to retract a bad recipe: the answer is a yank/deprecate flag, not deletion, so pinned consumers do not break. And rating-weighted discovery risks a rich-get-richer bias that buries good new recipes, so the bonus stays small and clamped. The marketplace backend itself is out of scope of the substrate — it is a separate deliverable — and whether it reuses the Journey service or a distinct endpoint is undecided.+}

### 11.5 The substrate runs a recipe but does not yet *find* one — bounded search (ToT/LATS)

{+### 11.5 The substrate runs a recipe but does not yet *find* one — bounded search (ToT/LATS)+}

### 11.5 The substrate runs a recipe but does not yet *find* one — bounded search (ToT/LATS)

{+This is the most ambitious gap and the furthest out. Today the substrate executes a *single* pre-seeded plan top to bottom; loops retry the *same* step to a fixpoint and `uses:` recurses a *fixed* sub-recipe. None of this *searches*. The unrealised degree of freedom is: when a step fails, explore alternate recipes, alternate parameters, or alternate orderings, score the branches, backtrack, and prune — turning the plan from a fixed program into a searched one, and advancing the thesis from "the substrate runs a recipe" to "the substrate finds the recipe that works."+}

### 11.5 The substrate runs a recipe but does not yet *find* one — bounded search (ToT/LATS)

{+Some of the raw material is already present: the matcher already returns a ranked top-N with confidence, so "alternate recipes" is just consuming the list rather than only its first element. The expensive parts are a search controller that maintains a scored frontier, a runner that can snapshot and restore plan state to backtrack into a prior step (which depends entirely on §11.1's per-step artifacts being lossless enough to re-enter a step), and a value estimate good enough that search converges faster than brute force. The risks are why this is last: combinatorial blow-up across recipes × parameters × orderings makes a hard budget (max nodes, max tokens, max wall-time) mandatory not optional, and it interacts badly with loops — a long loop *inside* a searched branch can stall for the better part of an hour. Every backtrack is a real subagent dispatch, so a weak value estimate makes search net-negative. And searched execution is non-deterministic, which collides with the marketplace's need for a recipe's behaviour to be a function of its text — so a deterministic mode that disables search would be the contract for published recipes. A failure-only mode (search only when a step fails) is a reasonable, cheaper first cut, but it is not the full vision.+}

### 11.6 What this section does not claim

{+### 11.6 What this section does not claim+}

### 11.6 What this section does not claim

{+These five items are specified, not shipped. The paper's six capabilities (Sections 3–8) are the implemented substrate; this section is the gap between that substrate and the stronger claims the thesis invites — durable resume, a self-improving library, an ecosystem supply, shared artifacts, and searched execution. Stating the boundary explicitly is the point: a substrate that overstates what it does is no more trustworthy than an agent that declares victory before it verifies.+}

### 11.6 What this section does not claim

{+---+}

### 12. Suggested Diagrams (D2)

{+## 12. Suggested Diagrams (D2)+}

### 12. Conclusion

[-## 12. Conclusion-]

### 13. Conclusion

{+## 13. Conclusion+}

### 13. Conclusion

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-] {+reliably+} 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.
