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·cresolution
resolve <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