# Execute the template

> A plan in this method is produced by running a template against the task, as shown in draft, compare, restructure], rather than by writing a document that…

Page: Methodology · Plan
Canonical: https://banes-lab.com/disciplined-methodology/plan#execute-the-template

This section is stop 23 of 102 in the learning route. Previous: [13 - The plan is a graph](https://banes-lab.com/disciplined-methodology/plan/the-flat-checklist.md). Next: [15 - Ask where it appears](https://banes-lab.com/disciplined-methodology/plan/ask-where-it-appears.md). It builds on [13 - The plan is a graph](https://banes-lab.com/disciplined-methodology/plan/the-flat-checklist.md), [12 - Worth before work](https://banes-lab.com/disciplined-methodology/plan/worth-before-work.md).

A plan in this method is produced by running a template against the task, as shown in [C1·c draft, compare, restructure](https://banes-lab.com/disciplined-methodology/plan#execute-the-template-panel-c), rather than by writing a document that copies the template's headings. The template works like a program. It walks the ten nodes of [the loop](https://banes-lab.com/disciplined-methodology/start/the-loop.md) and asks its questions in a fixed order, from worth through admissibility and evidence to termination, and it produces the artifact the loop ends on. Each node is typed as shown in [C1·a a node contract](https://banes-lab.com/disciplined-methodology/plan#execute-the-template-panel-a), and the resulting plan has the shape shown in [C1·b a plan's shape](https://banes-lab.com/disciplined-methodology/plan#execute-the-template-panel-b). There is one template for each genesis question, as shown in [C1·d one per question](https://banes-lab.com/disciplined-methodology/plan#execute-the-template-panel-d). The grammar page publishes the [template families](https://banes-lab.com/pag/templates/templates-families.md) used here, and [core templates](https://banes-lab.com/pag/templates/templates-core.md) states the rule they all follow: a template carries the contract, never the content.

### Executed, not imitated

A plan that copies a template's headings gets none of the guarantees the template was written to give. It can have every right heading and none of the right answers, and the reader still trusts it because of the headings. This happens because a template copied for its shape gives the look of rigour without any of its questions being answered.

For this reason, when a shape recurs I turn it into a template, and I run the template as a procedure rather than copying it. When the draft and the template disagree, the draft is restructured to fit the template rather than defended. In practice, the first plan is drafted from the task and then compared with the template node by node and gate by gate, with the draft treated as raw material for the restructure. Only current and future work stays in the result, and a task is deleted as soon as it is finished.

To check this, read the plan for its answers rather than its headings, and ask of each heading whether the decision under it could have gone the other way. The full loop applies only to an artifact that is executed. A reference, a specification, a contract or a note describes something rather than runs, and forcing the loop onto it fits it to a shape it does not have.

The restructure adds what the draft is missing: the ranking asked for in [worth before work](https://banes-lab.com/disciplined-methodology/plan/worth-before-work.md), the ordering asked for in [the plan is a graph](https://banes-lab.com/disciplined-methodology/plan/the-flat-checklist.md), an evidence contract on every material claim, and explicit termination. Each evidence contract names what would refute the claim and carries a confidence at or above the threshold, and finding no contradiction does not count as support. Termination requires saturation, completion and [verification](https://banes-lab.com/records/arch/verification.md) together, so a feeling that the work is finished does not end it.

Each template answers one genesis question, and a template is chosen by the question the work raises. The question of how anything comes to be leads to a plan, a checklist or a task set. How a verdict comes to be leads to an audit or a context check, and how a base [abstraction](https://banes-lab.com/records/arch/abstraction.md) comes to be leads to a shared pattern drawn from repeated evidence. How an agent comes to be leads to a reusable investigator, built from the [agent templates](https://banes-lab.com/pag/templates/templates-agents.md) on the grammar page. How a template comes to be leads to a template drawn from a document that has already been executed. When two templates could apply, the artifact the work ends on decides between them, and when none applies, I say so rather than force one to fit.

The time to write a template is when a shape appears for the second time. A single instance is only an artifact, but a second one makes a shape, and unless the second is written from a template, the shape ends up written twice. When the developer or the model reads a sibling file to learn the format, they pick up that sibling's accidents as though they were rules. The template therefore carries the constraint and never the content of one instance, and the checks read their contracts from it, as described in [the drop-in](https://banes-lab.com/disciplined-methodology/start/onboarding.md). Each template also spells out its whole structure. This is the one place where I duplicate on purpose, because the shared structure is what lets each template run on its own, and moving it into an import would take that away from all of them.

A template's loop, types and gates name no domain, so they carry over to any tree unchanged. Its catalogues are worked out again against what exists there, which is the rule the drop-in states for every core. I also keep the gates that run while an artifact is produced apart from the gates that run when it executes, because an artifact that passed its generation gates has not yet passed its execution gates.

Every node of a template carries the same contract, and that contract is what lets a template run as a program rather than be read as a document. A node declares its layer, the mathematical shape its decision yields, the input it reads, which is only the previous node's output, the transformation it applies, the constraints stated at that step, its output, and one handoff gate that carries evidence. The gate in turn names its checks and the evidence each one reads, the node it passes to, and the earliest node a failure is sent back to, with a limit on how far back that can be. Because the yields type is a discriminated union, a gate that owes a ranking cannot be satisfied by a boolean, and the compiler reports the mismatch. The four gates that can never be skipped are a closed subset of the node names rather than a convention the reader has to remember. As a result, a template can be checked by walking its own declarations, and a node without a gate, a gate without evidence, or a decision without a shape fails before anything runs.

C1·a a node contract

```typescript
export const LAYERS = ["epistemic", "conative", "evaluative"] as const;
export const NODES = ["orient", "intent", "see", "derive", "project", "act", "constrain", "verify", "commit", "terminate"] as const;

export type Yields =
| { readonly mathType: "set-theory"; readonly shape: "set" | "boolean" }
| { readonly mathType: "logic"; readonly shape: "boolean" }
| { readonly mathType: "graph"; readonly shape: "edge-list" }
| { readonly mathType: "optimisation"; readonly shape: "boolean" | "ranking" }
| { readonly mathType: "probability"; readonly shape: "number[0,1]" }
| { readonly mathType: "computation"; readonly shape: "procedure" };

export interface Gate<Node extends (typeof NODES)[number]> {
readonly rule: Node;
readonly checks: readonly { readonly claim: string; readonly evidence: string }[];
readonly onPass: Node | "STOP";
readonly onFail: { readonly owner: Node; readonly bounded: true };
}

export interface NodeContract<Node extends (typeof NODES)[number], Input, Output> {
readonly node: Node;
readonly layer: (typeof LAYERS)[number];
readonly yields: Yields;
readonly input: Input;
readonly transform: (input: Input) => Output;
readonly constraints: readonly string[];
readonly output: Output;
readonly handoff: Gate<Node>;
}

export type Mandatory = "intent" | "constrain" | "verify" | "terminate";
```

C1·b a plan's shape

```markdown
# <what this change is for, in one sentence>

## Worth
Objective: the outcome, named so the result can be checked against it.
Not in scope: the nearest things this change will not do.
Branches ranked: the way chosen, and why the others lost.

## Admissible
Hard limits: what no phase may cross, whatever it would gain.
Cost: what this is allowed to take, and the point past which it stops.

## Phases, ordered by dependency
### Phase 1: <name>
Needs: nothing.
Gate: the evidence Phase 2 reads before it starts.
- [ ] task: <one change> — file: <where> — evidence: <what proves it> — verifier: <who reads it> — not: <what this task leaves alone>

### Phase 2: <name>
Needs: the gate of Phase 1.
Gate: ...

## Termination
The run stops when the objective sentence reads true against the tree, not when the list is ticked.
```

C1·c draft, compare, restructure

```mermaid
flowchart TB
draft["Draft · the first plan from the task"]
compare["Compare · node by node, gate by gate, against the template"]
restructure["Restructure · to what the template enforces"]
plan["The plan · worth ranked, phases ordered, gates named, termination stated"]
draft --> compare --> restructure --> plan
compare -. the draft is raw material, the template is the authority .-> draft
```

C1·d one per question

```mermaid
flowchart TB
question{"How does the thing come to be?"}
checklist["A plan, a checklist, a task set"]
claim["A verdict on claims, an audit"]
pattern["A shared abstraction from repeated evidence"]
agent["A reusable specialised investigator"]
layer["A template from an executed document"]
none["None fits · say so rather than force one"]
question -- anything --> checklist
question -- a verdict --> claim
question -- a base --> pattern
question -- an agent --> agent
question -- a template --> layer
question -. no fit .-> none
```

## Links to

- [The loop](https://banes-lab.com/disciplined-methodology/start/the-loop.md)
- [Template families](https://banes-lab.com/pag/templates/templates-families.md)
- [Core templates](https://banes-lab.com/pag/templates/templates-core.md)
- [Worth before work](https://banes-lab.com/disciplined-methodology/plan/worth-before-work.md)
- [The plan is a graph](https://banes-lab.com/disciplined-methodology/plan/the-flat-checklist.md)
- [Verification](https://banes-lab.com/records/arch/verification.md)
- [Abstraction](https://banes-lab.com/records/arch/abstraction.md)
- [Agent templates](https://banes-lab.com/pag/templates/templates-agents.md)
- [The drop-in](https://banes-lab.com/disciplined-methodology/start/onboarding.md)

## Linked from

- [Template families](https://banes-lab.com/pag/templates/templates-families.md)
- [Agents as executed contracts](https://banes-lab.com/disciplined-methodology/collaborate/agents-as-executed-contracts.md)
