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

From v4.4 (2 Jun) to v4.5 (2 Jun): 9,029 words to 8,985 words, 117 words in new or rewritten paragraphs and 161 taken out, 11 paragraphs changed.

## Change note of v4.5

**Two figures added; the diagram-plan section removed**

Adds figures for recipe composition (4.2) and for the panel (8.3), and removes the section that listed diagrams still to be drawn.

## Changed paragraphs

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

### 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 reports what has shipped beyond the six core capabilities and the one extension that remains open; Section 12 [-lists suggested diagrams;-] {+concludes;+} Section 13 [-concludes; Section 14-] states the surrounding cognitive stack the substrate depends on.

### 4.2 Dynamic composition — runtime sub-recipe calls (`uses:`)

{+![Composition algebra: `composes:` flattens sub-recipe steps into one plan at build time (de-duplicated, depth- and cycle-guarded); `uses:` transfers control at run time into a nested plan on a child session and folds its terminal note back as the step's outcome. Both are bounded by a depth cap and a cycle guard.](images/fig-composition.pdf)+}

### 8.3 What the panel renders

{+![The RECIPES panel sits beside the chat, divided by the split-of-concerns boundary: the chat carries the substantive answer, the panel carries orchestration mechanics. The panel stacks Discovery (catalog size, scored candidates, threshold, NO-MATCH), Composition (source badges, de-dup count), the Plan with per-step status, per-step Fan-out (one subagent-vitals row per dispatch), and the compact, expandable decision trail.](images/fig-panel.pdf)+}

### 11.2 The self-improving library — shipped

Section 5 makes the library self-*expanding* (it authors when nothing matches) and Section 9.5 makes it self-*updating* (a reflection pass can recommend a change). The missing piece was self-*improvement*: feeding real execution outcomes back into the matcher so its scoring weights stop being purely hand-tuned. That loop is now closed, with a deliberate division of labour between subsystems. A background consolidation layer — the offline process that runs between turns to compact and learn from accumulated experience — owns the *offline* measurement: it distils a per-recipe **fitness** from accumulated execution episodes — success rate, latency, token [-cost — attributing each-] {+cost. Each+} episode {+attributes+} to a recipe only via an explicit `recipe:<owner/slug>` tag the runner sets at dispatch, so an untagged episode is never counted against any recipe (no false attribution).

### 12. Suggested Diagrams (D2)

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

### 12. Suggested Diagrams (D2)

[-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. Figures 1 and 2 are already rendered (the executive cycle and the life-cycle state machine, §2.1 and §8.4); the two below would complete the set.-]

### 12. Suggested Diagrams (D2)

[-1. **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.-]

### 12. Suggested Diagrams (D2)

[-2. **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).-]

### 13. Conclusion

[-## 13. Conclusion-]

### 12. Conclusion

{+## 12. Conclusion+}

### 13. The Surrounding Cognitive Stack

## [-14.-] {+13.+} The Surrounding Cognitive Stack
