Templates
A1Core templates
This section covers the template and how an instance is raised from it. A template record has four parts, a declared document type, the slots an instance fills, the constraints every instance must satisfy, and a body in which every slot appears by name, as shown in A1·atemplate record. A1·dtemplate and sibling shows how a template differs from a sibling instance. Raising an instance is a resolution in which each slot is substituted, a slot left unresolved is reported rather than guessed, and a value outside a slot's declared set is a violation. A1·cresolution lists the three outcomes. The record and A1·bworkflow body are the grammar's own workflow template, read from its records rather than restated here.
A1.1Contract, not content
An instance derived from a sibling inherits that sibling's accidents as a contract. Four parties produce four formats for one surface, each derived from a different sibling, and the check that later reads them derives its schema from a fifth. A sibling carries one instance's choices and a template carries the constraint, and a reader copying a sibling cannot tell which is which.
For this reason what every instance must share is stated once, where a tool can hold each new one to it. Shared structure is extracted once a pattern repeats, rather than copied from an earlier example. In practice, a template is written the second time a shape occurs, before the second instance is written, in the order shown in A1·esecond instance. It declares its type, names every slot with whether it is required and, where the values form a closed set, that set, and it names the constraints every instance must satisfy so a check can read them. The body keeps only what every instance shares, with every varying value as a slot. Each new instance is raised by resolving the slots, and an instance whose resolution reports an unresolved slot or a violation is refused.
To check this, take a template and find a value in it that would be wrong for the next instance. That value is content rather than contract, and a slot is the repair. Then resolve the template with one slot missing, and a resolution that raises the instance anyway has guessed. A shape seen once has no template, because one instance cannot show which of its parts are invariant. A template raised from one instance is premature abstraction.
The slots fall into two kinds by who supplies the value. An instance slot is what this document is for, supplied when it is raised. A host slot is a fact about the tree the document will be walked in, namespaced by its subject and filled by the adapter, so one template works in any tree.
The constraints are the family's acceptance criteria, and a check over an instance reads them from the template, as the drop-in describes. What the template excludes is as deliberate as what it carries, so it names no model, no path and no tool, for the reasons described in semantic operations. A correction lands in the template and reaches every later instance, never in the instance where only its author would see it.
A1·atemplate recordtemplate: type: WORKFLOW # a declared document type · nothing else title: <what the family is for> slots: - name: {WORKFLOW_NAME} # the value an instance supplies description: <what the slot holds> required: true kind: string - name: {project.governance_policy} # a host fact · resolved by the adapter, never typed required: true - name: {limits.max_lines} # a bound · resolved from the host's limits required: false - name: {scope} required: true enum: [<investigate>, <action>] # a closed set · a value outside it is a violation constraints: # what every instance must satisfy · named, checkable - declaration_required - gate_per_node - contract_reads_prior_output - population_declared - refusal_before_write - invariant_has_objector - no_autonomous_spawn - single_source_of_truth body: | <the document, with every slot as {name}>
A1·bworkflow body--- name: {WORKFLOW_NAME} type: WORKFLOW version: 1.0.0 --- THIS WORKFLOW EXECUTES {WORKFLOW_PURPOSE} %% META %%: intent: "{WORKFLOW_INTENT}" objective: "{OBJECTIVE}" jurisdiction: {INPUT_SOURCE} and {OUTPUT_TARGET} | external: every other surface recursion_limit: 2 # NODE 1 — {NODE_ONE_TITLE} [epistemic · analysis · set-theory · yields: set] @purpose: "read the input and see it through the analysis the workflow is for" @genesis: existence CONTRACT: input: {INPUT_SOURCE} transform: READ_RESOURCE {INPUT_SOURCE} INTO input; ANALYZE_CONTENT input AGAINST {ANALYSIS_TARGET} INTO analysis output: analysis HANDOFF GATE (evidence-bearing): [check] input read from {INPUT_SOURCE} (evidence: the read returned content) over: {INPUT_SOURCE} measured: <read> / <declared> [check] analysis produced (evidence: a count above zero) [check] every entry of analysis names its source in input (evidence: no entry with an empty source) result: pass → NODE 2 | empty → REPAIR (owner: NODE 1) | unknown → BLOCKED # NODE 2 — {NODE_TWO_TITLE} [epistemic · formalization · computation · yields: procedure] @purpose: "transform every item by one rule, preserving what the next node needs" @genesis: transformation CONTRACT: input: analysis from NODE 1 transform: FOR EACH item IN analysis: COMPOSE_ARTIFACT result FROM item USING {TRANSFORM_RULE}; APPEND result TO results preserves: the source of every item output: results HANDOFF GATE: [check] one result per item (evidence: the two counts match) over: analysis measured: <transformed> / <items> [check] every result conforms to {TRANSFORM_RULE} (evidence: VALIDATE_ARTIFACT passed on each) [check] analysis unchanged (evidence: a witness read) result: pass → NODE 3 | mismatch → REPAIR (owner: NODE 2) | unknown → BLOCKED # NODE 3 — FINALIZATION [evaluative · representation · information-theory · yields: artifact] @purpose: "persist the results once, refuse a stale destination, and report to the parties whose next work they create" @genesis: constraint CONTRACT: input: results from NODE 2 transform: PERSIST_ARTIFACT results TO {OUTPUT_TARGET}; REPORT_RESULT completion TO <the parties whose next work it creates> output: {OUTPUT_TARGET} freshness: fingerprint(results) + fingerprint(this document) HANDOFF GATE: [check] {OUTPUT_TARGET} persisted (evidence: a read returns it) over: results measured: <persisted> / <results> [check] completion reported (evidence: the report) [check] entry count of {OUTPUT_TARGET} matches results (evidence: the two numbers) refuse: {OUTPUT_TARGET} changed since it was read before PERSIST_ARTIFACT standing: moved-set none result: pass → TERMINATE | loss → REPAIR (owner: NODE 3) | unknown → BLOCKED # CROSS-NODE INVARIANTS INVARIANT prior-output-only: a node reads only the prior node's output over: every node binds: the workflow objector: [check] input names NODE n-1 or a slot INVARIANT one-truth: one fact has one home across the nodes over: every artifact binds: the workflow objector: [check] entry count of the output matches results INVARIANT no-spawn: no autonomous party is spawned over: every node binds: the workflow objector: none REPORT: subject: NODE 3 verdict: pass | fail | unknown domain: declared <results> measured <persisted> completion: saturated <bool> complete <bool> verified <bool>
A1·cresolutionresolve <template> WITH <the values an instance supplies> substituted every {name} the instance supplied, replaced in the body unresolved [{OUTPUT_TARGET}] # still in the body · the instance is not ready violations [missing_required_slot:{OBJECTIVE}, # a required slot with no value enum_violation:{scope}] # a value outside the slot's closed set # an instance with a non-empty unresolved or violations list is not raised · nothing guesses a value