# configuration/strings/definition.strings.ts

> 56 lines of code and 5 definitions.

Tree: Site tree
Language: typescript
Layer: product
Canonical: https://banes-lab.com/anatomy/tree#file-configuration-strings-definition-strings-ts
Source text: https://banes-lab.com/assets/sources/source.84d39977a304f921cbc623da0fa8bb780fc49342a2c28651a65b084b13326bb1.generated.txt

## Definitions

- `MINIMAL_DOCUMENT` (lexical_declaration, line 8)
- `STAGE_SAMPLE` (lexical_declaration, line 11)
- `CONTRACT_DIAGRAM` (lexical_declaration, line 14)
- `ENGINE_DIAGRAM` (lexical_declaration, line 17)
- `DEFINITION_SECTION` (lexical_declaration, line 20, exported)

## Source

```typescript
import { DEFINITION_SECTION_ID, GRAMMAR_VALIDATION_TAB, LIMITATION_SECTION_ID } from "#core/ids/grammar.ids";
import { DEFINITION_SECTION_ICON } from "#configuration/icons/grammar.icons";
import { GRAMMAR_PAGE } from "#core/ids/page.ids";
import { PAG_LANGUAGE } from "#configuration/constants/code.constants";
import type { Section } from "#types/document.types";
import { tabLink } from "#assets/link.assets";

const MINIMAL_DOCUMENT =
    '---\nname: <document-name>\ntype: TASK\nversion: 1.0.0\n---\n\nTHIS TASK EXECUTES <what the document is for, in one sentence>\n\n%% META %%:\n    objective: "<what finished looks like, checkable against the tree>"\n    jurisdiction: <source> | external: everything else\n    recursion_limit: <a bound on repair>\n\n# NODE 1 — <the first bounded decision>   [epistemic · analysis · logic · yields: boolean]\n@genesis: existence\nCONTRACT:\n  input:     <source>\n  transform: READ_RESOURCE <source> INTO <held>; VALIDATE_ARTIFACT <held> AGAINST <schema>\n  output:    <held>, validated\nHANDOFF GATE:\n  [check] <held> read from <source> (evidence: the read returned content)\n  [check] <held> conforms to <schema> (evidence: the validator\'s report) over: <held> records measured: <conforming> / <records>\n  [check] every <held>.<record> carries the fields NODE 2 reads (evidence: no record with a missing field)\n  result: pass → NODE 2 | unread or nonconforming → REPAIR (owner: NODE 1) | unknown → BLOCKED\n\n# NODE 2 — <the decision that consumes the first>   [epistemic · reasoning · set-theory · yields: set]\n@genesis: difference\nCONTRACT:\n  input:     <held> from NODE 1\n  transform: FOR EACH <item> IN <held>.<collection>: ANALYZE_CONTENT <item> AGAINST <criterion> INTO <finding>; IF <finding>.<met>: APPEND <item> TO <result>\n  output:    <result>\nHANDOFF GATE:\n  [check] every <item> analyzed (evidence: one finding per item) over: <held>.<collection> measured: <analyzed> / <items>\n  [check] <result> holds every <item> that met <criterion> (evidence: the two counts match)\n  [check] no <item> outside <held> appears in <result> (evidence: every result item present in <held>)\n  result: pass → TERMINATE | count mismatch → REPAIR (owner: NODE 1) | unknown → BLOCKED\n\n# CROSS-NODE INVARIANTS\nINVARIANT validate-before-persist: <held> is validated before anything is persisted over: every node binds: the reader objector: [check] <held> conforms to <schema> at NODE 1\nINVARIANT source-untouched: <source> is never modified in place over: <source> binds: the reader objector: none\n\nREPORT:\n  subject: NODE 2\n  verdict: pass | fail | unknown\n  domain: declared <items> measured <analyzed>\n  completion: saturated <bool> complete <bool> verified <bool>';

const STAGE_SAMPLE =
    "# each construct of a document is one stage of the reasoning loop, written down\ndeclaration          orient      what kind of instruction exists, and what it may touch   yields: a set\nkeyword directive    see         the lens the intent is read through                    yields: a structured line\nnode                 project     what follows what, as a contract                       yields: an edge-list\ncontrol flow         act         which branch, which iteration                          yields: a procedure\nsemantic operation   act         which effect, bound to a result                        yields: a procedure\ninvariant record     constrain   what is admissible, and what would object               yields: a boolean\nhandoff gate         verify      what evidence closes the node, over what set           yields: pass, fail or unknown\nreport               commit      the verdict as a representation a checker can challenge yields: an artifact\nwell-formedness      terminate   whether the document may be trusted                    yields: a boolean";

const CONTRACT_DIAGRAM =
    'flowchart TB\n    prose["Prose · \'get the data and check it\'"]\n    interpret["The model interprets · what is get, what is check, what counts as valid"]\n    variance["A different completion each run"]\n    pag["A directive · READ data FROM source, VALIDATE data AGAINST schema"]\n    pattern["The model completes a pattern it has seen"]\n    narrow["A narrower set of completions · still probabilistic"]\n    prose --> interpret --> variance\n    pag --> pattern --> narrow';

const ENGINE_DIAGRAM =
    'flowchart TB\n    doc["A document · typed, contracted, gated, bounded"]\n    scan["A scan · checks the shape, deterministic"]\n    loop["A reasoning loop · orient, intent, see, derive, project, act, constrain, verify, commit, terminate"]\n    binding["A binding · maps each operation to a tool, each slot to a value"]\n    output["Output · a sample, unverified until read"]\n    doc --> scan\n    doc --> loop --> output\n    loop -- an effect --> binding\n    doc -. has no runtime of its own .-> output';

export const DEFINITION_SECTION: Section = {
    icon: DEFINITION_SECTION_ICON,
    id: DEFINITION_SECTION_ID,
    intro: `Pattern Abstract Grammar (PAG) is a structured format for writing the instructions a model is asked to follow. A PAG document declares what kind of instruction it is and what it may touch, and it draws every operative word from a closed vocabulary of uppercase tokens grounded in a reasoning ontology. The work is grouped into nodes; each node reads the previous node's output and closes on a gate of checkable conditions, each with its evidence and the population it covers. The document states its boundaries as invariant records and ends with a report, and <cite>minimal document</cite> shows all of these parts together. Each part is one stage of a reasoning loop written down, as listed in <cite>construct to stage</cite>, so the document makes the loop legible. <cite>prose or directive</cite> shows where variance enters without the grammar, and <cite>scan, loop, binding</cite> shows what walks a document. What the tokens gain is described in why it works, and what the grammar never reaches is described under <a href="${tabLink(GRAMMAR_PAGE, GRAMMAR_VALIDATION_TAB, LIMITATION_SECTION_ID)}">limits</a>.`,
    subsections: [
        {
            blocks: [
                {
                    application:
                        "In practice, an instruction is written as a PAG document when a reasoning loop will walk it. The document declares its type, states a checkable objective, divides the work into nodes with contracts, closes each node on three to five checks that can be settled with evidence, and bounds the whole with invariants.",
                    boundary:
                        "A prompt that asks one question in passing gains nothing from a node structure. The grammar earns its cost where the document will be walked more than once, read by more than one party, or trusted to have done what it says.",
                    cause: "An implicit contract leaves the model to supply the terms, and it supplies them from the completion, so they vary with it.",
                    decision:
                        "The instruction gets a type rather than sharper prose: a declared type, tokens from a closed set and gates with checkable exits, rather than a longer or more careful sentence.",
                    failureMode:
                        "The same request run twice produces two plausible results, and neither you nor the model can say which sentence was read differently.",
                    kind: "lesson",
                    principle:
                        "For this reason I write an instruction as an explicit contract rather than as a request in prose.",
                    problem: "An instruction written as prose leaves its terms to the model that reads it.",
                    validation:
                        "To check this, hand the same document to the model twice and compare both outputs against the gates. Where both runs pass every gate, the structure held; where one fails, the failing gate points to the sentence that was still prose.",
                },
                {
                    kind: "text",
                    text: "A document has no runtime. What walks it is a reasoning loop, the one the methodology page teaches, and every construct of the grammar makes one of that loop's stages explicit. The document type names which reasoning model walks the document and on which axis of the loop it sits, and an adapter outside the document maps each semantic operation to the tool that performs it.",
                },
                {
                    kind: "text",
                    text: "Two kinds of check apply to a document. A scan checks its shape; that is static analysis, deterministic and cheap, and it is what makes the grammar parsable. The loop checks its meaning, and that check is not deterministic, because the loop is walked by a model.",
                },
                { code: MINIMAL_DOCUMENT, kind: "code", language: PAG_LANGUAGE, title: "minimal document" },
                { code: STAGE_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "construct to stage" },
                { caption: "prose or directive", kind: "mermaid", text: CONTRACT_DIAGRAM },
                { caption: "scan, loop, binding", kind: "mermaid", text: ENGINE_DIAGRAM },
            ],
            title: "A contract, not a request",
        },
    ],
    title: "What PAG is",
};
```
