# pag

> Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a…

Page: Ontology · Algorithms
Canonical: https://banes-lab.com/ontology/algorithms#algo-domain-pag

Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a grammar, what it composes and is composed by, which forces and principles it answers to, what grounds it and what it grounds, and an exemplar where the record carries one. The diagram shows what composes what inside the domain.

Relations diagram

What composes what inside this domain.

```mermaid
flowchart LR
n_pag_document_declaration["PAG Document Declaration"]
n_pag_keyword_ontology["PAG Keyword Ontology"]
n_pag_node_decomposition["PAG Node Decomposition"]
n_pag_validation_gate["PAG Handoff Gate"]
n_pag_explicit_control_flow["PAG Explicit Control Flow"]
n_pag_constraint_boundary["PAG Invariant Record"]
n_pag_tool_invocation["PAG Semantic Operation"]
n_pag_coordination_construct["PAG Structure Declaration"]
n_pag_ambiguity_reduction["PAG Ambiguity Reduction"]
n_pag_authoring_kernel["PAG Authoring Kernel"]
n_pag_well_formedness_validation["PAG Well-Formedness Validation"]
n_pag_instruction_concern["<PAG Instruction Concern>"]
n_pag_authoring_kernel --> n_pag_document_declaration
n_pag_authoring_kernel --> n_pag_keyword_ontology
n_pag_authoring_kernel --> n_pag_node_decomposition
n_pag_authoring_kernel --> n_pag_validation_gate
n_pag_authoring_kernel --> n_pag_explicit_control_flow
n_pag_authoring_kernel --> n_pag_tool_invocation
n_pag_authoring_kernel --> n_pag_coordination_construct
n_pag_authoring_kernel --> n_pag_constraint_boundary
n_pag_authoring_kernel --> n_pag_well_formedness_validation
n_pag_well_formedness_validation --> n_pag_validation_gate
n_pag_well_formedness_validation --> n_pag_explicit_control_flow
```

### PAG Document Declaration

- Stage: [orient](https://banes-lab.com/records/stage/orient.md)
- Axis: [ontology](https://banes-lab.com/records/reason/axis-ontology.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Bind a document to a declared type and its default verb (THIS <TYPE> <VERB> <description>) after the YAML frontmatter and before any node, then declare in the meta block what the document is for, which sources ground which, what it trusts, what it may touch and what it declares outside itself, and how far repair may recurse.

Invariant
A PAG document announces what kind of instruction it is, and what it may touch, before it instructs.

Flow

```text
Frontmatter → TypeDeclaration → DefaultVerb → MetaBlock → Jurisdiction → DeclaredContract
```

Productions

```bnf
PagDocumentDeclaration ::= <Frontmatter> "->" <TypeDeclaration> "->" <MetaBlock> "->" <DeclaredContract>
PagDocumentType ::= "AGENT" | "WORKFLOW" | "PROTOCOL" | "POLICY" | "CHECKLIST" | "TEMPLATE" | "TASK" | "INSTRUCTION" | "PROMPT" | "COMMAND" | "TEST" | "DEBUG" | "VERIFICATION" | "DISTILLATION" | "AUDIT" | "TRANSLATION" | "COMPOSITION"
PagDocumentVerb ::= "IS" | "ENFORCES" | "EXECUTES" | "PERFORMS" | "PROVIDES" | "IMPLEMENTS" | "DEFINES" | "MANAGES" | "COORDINATES" | "HAS" | "GENERATES" | "RESOLVES" | "FINDS" | "FIXES" | "VERIFIES" | "CLASSIFIES" | "DISTILLS" | "ABSTRACTS" | "ELIMINATES" | "AUDITS" | "MEASURES" | "SCORES" | "CORRECTS" | "RENDERS" | "COMPOSES" | "FOLDS"
PagMetaField ::= "objective" | "priority" | "trust" | "jurisdiction" | "recursion_limit"
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Named in the derivation of
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [metaprogramming_modeling](https://banes-lab.com/records/force/metaprogramming-modeling.md)

Grounds
none

Before

```text
A document instructs with no declared type — its semantic contract, its authority and its jurisdiction are implicit.
```

After

```text
frontmatter → THIS {AGENT|WORKFLOW|CHECKLIST} {IS|EXECUTES|ENFORCES} description → META block{objective, priority, trust, jurisdiction, recursion_limit} → declared contract
```

### PAG Keyword Ontology

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Draw every operative token from a fixed, uppercase, code-frequent vocabulary partitioned into semantic categories, each token grounded to a record in the reasoning ontology, and bind targets to sources through explicit prepositions, so the model completes recognised structured patterns rather than interpreting prose.

Invariant
Explicit high-frequency uppercase tokens, each grounded to a reasoning record, reduce interpretive variance; prose does not.

Flow

```text
ProseIntent → KeywordCategory → UppercaseToken → ReasoningGround → PrepositionBinding → StructuredDirective
```

Productions

```bnf
PagKeywordOntology ::= <KeywordCategory> "->" <KeywordToken> "->" <ReasoningGround> "->" <PrepositionBinding> "->" <StructuredDirective>
PagKeywordCategory ::= "semantic_operation" | "node" | "action" | "control_flow" | "declaration" | "modifier" | "coordination" | "state_machine" | "dag" | "priority_queue" | "flowchart" | "document_type" | "document_verb" | "meta" | "validation" | "report" | "invariant" | "contextual"
PagPreposition ::= "FROM" | "TO" | "INTO" | "WITH" | "USING" | "AGAINST" | "IN" | "AS"
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Named in the derivation of
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[metaprogramming_modeling](https://banes-lab.com/records/force/metaprogramming-modeling.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
'Get the data and check it' — prose the model must interpret.
```

After

```text
prose intent → uppercase token{READ_RESOURCE|ANALYZE_CONTENT|VALIDATE_ARTIFACT} + preposition{FROM|INTO|AGAINST} → structured directive, low interpretive variance
```

### PAG Node Decomposition

- Stage: [project](https://banes-lab.com/records/stage/project.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [graph](https://banes-lab.com/records/reason/math-type-graph.md)
- Yields: edge-list

Details

Intent
Group directives into nodes, each one decision on one reasoning axis, headed by its layer, axis, math type and the shape its decision yields, tagged with the substrate stage its artifact comes to be at, and contracted so that its input names the prior node's output or a declared slot, its transform is stated in semantic operations, and its output is the one record the next node reads.

Invariant
Each node is one bounded decision whose data flow from the prior node is declared by identity, never inferred from a name.

Flow

```text
DirectiveSet → NodeHeader → GenesisStage → Contract → DeclaredInput → NodeOutput
```

Productions

```bnf
PagNodeDecomposition ::= <DirectiveSet> "->" <NodeSet> "->" <DataFlowGraph>
PagNodeHeader ::= "#" "NODE" <NodeNumber> "—" <NodeTitle> "[" <Layer> "·" <Axis> "·" <MathType> "·" "yields:" <Shape> "]"
PagNodeContract ::= "CONTRACT:" "input:" <PriorOutputOrSlot> "transform:" <SemanticOperations> "output:" <NodeOutput> <OptionalFreshness>
PagScopeRule ::= "declare_before_use" "," "document_wide_scope" "," "prior_output_only"
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Named in the derivation of
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[modularity](https://banes-lab.com/records/force/modularity.md), [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)

Grounds
none

Before

```text
Directives poured in one flat block, forward-referencing later work, with no statement of what each block decides or what shape its decision takes.
```

After

```text
directives → nodes{# NODE n — NAME [layer · axis · math type · yields: shape], @genesis, CONTRACT input/transform/output, one gate} → a node reads only the prior node's output → explicit data flow
```

### PAG Handoff Gate

- Stage: [verify](https://banes-lab.com/records/stage/verify.md)
- Axis: [verification](https://banes-lab.com/records/reason/axis-verification.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Close every node with a handoff gate of three-to-five checks, each a claim about the output with the evidence that settles it and the population it was measured over, a refusal condition named before any irreversible write, the standing of the read set beside the verdict, and a result line that routes pass to the next node, each failure to the earliest node that owns its repair, and unknown to blocked.

Invariant
A node boundary is trusted only when its checks carry evidence and a population, its writes are refused before they land, and its unknown is routed; unknown is not pass.

Flow

```text
NodeOutput → CheckWithEvidence → Population → Refusal → Standing → ThreeVerdicts → ResultLine
```

Productions

```bnf
PagHandoffGate ::= <NodeOutput> "->" <CheckLineSet> "->" <OptionalRefusal> "->" <OptionalStanding> "->" <ResultLine>
PagCheckLine ::= "[check]" <Claim> "(evidence:" <Evidence> ")" "over:" <Set> "measured:" <Count> "/" <Count>
PagVerdict ::= "pass" | "fail" | "unknown"
PagResultLine ::= "result:" "pass" "->" <NextNode> "|" <Failure> "->" "REPAIR" "(owner:" <Node> ")" "|" "unknown" "->" "BLOCKED"
PagGateConstraint ::= "evidence_per_check" "," "population_declared" "," "three_to_five_checks" "," "refusal_before_write" "," "unknown_routed"
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md), [PAG Well-Formedness Validation](https://banes-lab.com/records/algo/pag-well-formedness-validation.md)

Named in the derivation of
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [model_governance](https://banes-lab.com/records/force/model-governance.md), [modularity](https://banes-lab.com/records/force/modularity.md)

Grounds
[ver-evidence](https://banes-lab.com/records/reason/node-ver-evidence.md), [ver-population](https://banes-lab.com/records/reason/node-ver-population.md), [ver-refusal](https://banes-lab.com/records/reason/node-ver-refusal.md), [ver-standing](https://banes-lab.com/records/reason/node-ver-standing.md), [ter-block](https://banes-lab.com/records/reason/node-ter-block.md)

Before

```text
A node ends with 'looks good' — a vague assertion with no evidence, no population, no refusal, and only two verdicts.
```

After

```text
node output → 3-5 checks{[check] claim (evidence: what settles it) over: set measured: n / N} + refuse: condition before write + standing: moved-set + result: pass → next | failure → REPAIR (owner) | unknown → BLOCKED
```

### PAG Explicit Control Flow

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Express branching with IF / ELSE IF / ELSE, iteration with FOR EACH over a collection (never a bare FOR), and failure handling with TRY / CATCH, every conditional colon-terminated and every branch a complete directive sequence.

Invariant
Control flow is explicit and colon-delimited so the model does not infer structure from prose sequence.

Flow

```text
Condition → BranchSet → IterationForm → FailureForm → DeterministicPath
```

Productions

```bnf
PagControlFlow ::= <Conditional> | <Iteration> | <FailureHandling>
PagIteration ::= "FOR" "EACH" <Iterator> "IN" <Collection> ":" <DirectiveSet>
PagControlConstraint ::= "colon_terminated" "," "for_each_not_for" "," "complete_branch_directives"
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md), [PAG Well-Formedness Validation](https://banes-lab.com/records/algo/pag-well-formedness-validation.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [control_coordination](https://banes-lab.com/records/force/control-coordination.md)

Grounds
none

Before

```text
Branching and iteration inferred from prose order; a bare FOR, a missing colon.
```

After

```text
IF/ELSE IF/ELSE + FOR EACH x IN collection + TRY/CATCH → every conditional colon-terminated, complete branch directives
```

### PAG Invariant Record

- Stage: [constrain](https://banes-lab.com/records/stage/constrain.md)
- Axis: [teleology](https://banes-lab.com/records/reason/axis-teleology.md)
- Math type: [optimisation](https://banes-lab.com/records/reason/math-type-optimisation.md)
- Yields: boolean | ranking

Details

Intent
State every behavioural invariant as a record with four slots: the property in a form that could be false, the set it quantifies over, the parties it binds, and the objector, the check that would disagree if the property stopped holding or none as declared debt, so an unwatched invariant is visible rather than assumed.

Invariant
An invariant is stated with its property, its set, its parties and its objector, or it is indistinguishable from a property a reader happened to infer.

Flow

```text
BehaviorPolicy → Property → Set → Parties → Objector → InvariantRecord
```

Productions

```bnf
PagInvariantBlock ::= "#" "CROSS-NODE" "INVARIANTS" <InvariantRecord>+
PagInvariantRecord ::= "INVARIANT" <Name> ":" <Property> "over:" <Set> "binds:" <Parties> "objector:" (<CheckRef> | "none")
PagInvariantQuality ::= "falsifiable" "," "quantified" "," "delivered" "," "watched"
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Named in the derivation of
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[model_governance](https://banes-lab.com/records/force/model-governance.md), [security_governance](https://banes-lab.com/records/force/security-governance.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
Behavioural rules as a bullet list under ALWAYS and NEVER — no set the rule ranges over, no party it binds, nothing that would disagree if it stopped holding.
```

After

```text
INVARIANT name: property over: set binds: parties objector: check | none → each invariant stated in a form that could be false, with what watches it
```

### PAG Semantic Operation

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
Name every external effect as one of the semantic operations (discover, read, search, analyze, extract, calculate, compose, validate, persist, execute, request a decision, report) with a uniform WITH / USING parameter clause and an INTO / arrow result binding, so the document names what it does and an adapter binding resolves how, and no host's tool name enters the document.

Invariant
Every external effect is a semantic operation with explicit parameters and an explicit result binding, and the host's tools are the adapter's data.

Flow

```text
SemanticOperation → OperationTarget → ParameterClause → ResultBinding → AdapterBinding
```

Productions

```bnf
PagToolInvocation ::= <SemanticOperation> <OperationTarget> <OptionalParamClause> <OptionalResultClause>
PagSemanticOperation ::= "DISCOVER_RESOURCES" | "READ_RESOURCE" | "SEARCH_CONTENT" | "ANALYZE_CONTENT" | "EXTRACT_FACTS" | "CALCULATE_METRIC" | "COMPOSE_ARTIFACT" | "VALIDATE_ARTIFACT" | "PERSIST_ARTIFACT" | "EXECUTE_TOOL" | "REQUEST_DECISION" | "REPORT_RESULT"
PagResultBinding ::= "INTO" <Identifier> | "->" <Identifier> | "AS" <Identifier>
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Named in the derivation of
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md)

Grounds
none

Before

```text
An external effect described in prose, or named by one host's tool, so the document runs in one place only.
```

After

```text
semantic operation{READ_RESOURCE|PERSIST_ARTIFACT|EXECUTE_TOOL|REQUEST_DECISION} + WITH/USING params + INTO/-> result → a named effect the adapter binds to a host's tool
```

### PAG Structure Declaration

- Stage: [project](https://banes-lab.com/records/stage/project.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [graph](https://banes-lab.com/records/reason/math-type-graph.md)
- Yields: edge-list

Details

Intent
Make a document's structure explicit with the declaration that names it: a DAG for a dependency graph, a STATE_MACHINE for a lifetime or a set of derived states, a PRIORITY_QUEUE for a ranking, a FLOWCHART for the rendered projection of a declared structure, and for a shared surface the coordination model's SURFACE, RECORD and ITEM with their typed edges, derived states and the one post-and-wait operation, so ordering, ownership and state are declared as structure rather than narrated as prose.

Invariant
Ordering, ownership and state are declared through explicit structure constructs a check can read, never implied by textual order.

Flow

```text
StructureNeed → StructureDeclaration → DeclaredEdges → DerivedState → ReadableStructure
```

Productions

```bnf
PagStructure ::= <Dag> | <StateMachine> | <PriorityQueue> | <Flowchart> | <Surface>
PagStructureForm ::= "DAG" | "STATE_MACHINE" | "PRIORITY_QUEUE" | "FLOWCHART" | "SURFACE"
PagSurface ::= "SURFACE" <SurfaceKey> ":" ("RECORD" <RecordId> "subject:" <SubjectKey> <EdgeClause>*)+
PagEdgeKind ::= "PARENT" | "SATISFIED_BY" | "BLOCKS" | "ANSWERS" | "REFUTES" | "SUPERSEDES"
```

Composes
none

Composed by
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[control_coordination](https://banes-lab.com/records/force/control-coordination.md), [event_messaging](https://banes-lab.com/records/force/event-messaging.md), [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md)

Grounds
none

Before

```text
Concurrency, ordering, lifetimes and ownership implied by the order sentences appear in.
```

After

```text
a declared structure → DAG{dependency graph} | STATE_MACHINE{lifetime, derived states} | PRIORITY_QUEUE{ranking} | FLOWCHART{rendered projection} | SURFACE{RECORD, ITEM, typed edges, WAIT} → the structure is explicit and a check can read it
```

### PAG Ambiguity Reduction

- Stage: [derive](https://banes-lab.com/records/stage/derive.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Replace interpretive prose with explicit structured tokens so the model completes recognized patterns, while accepting that output stays probabilistic: the grammar reduces input ambiguity, it does not constrain output tokens or guarantee determinism.

Invariant
PAG shapes the input toward consistent completion and does not always apply; it reduces the variance of the output without making it deterministic.

Flow

```text
ProseAmbiguity → TokenStructure → PatternRecognition → ReducedVariance
```

Productions

```bnf
PagAmbiguityReduction ::= <ProseIntent> "->" <StructuredPattern> "->" <ReducedInterpretationLoad>
PagApplicabilityBound ::= "input_shaping_only" "," "probabilistic_output" "," "not_always_applicable"
```

Composes
none

Forces
[model_governance](https://banes-lab.com/records/force/model-governance.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
Prose intent claimed to guarantee deterministic model output.
```

After

```text
prose → structured tokens → reduced interpretation load; input-shaping only, output stays probabilistic (less variance, never deterministic)
```

### PAG Authoring Kernel

- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
Compose a PAG document as frontmatter and typed declaration, then a meta block with jurisdiction, then nodes each headed by its layer, axis, math type and yields, contracted to read the prior node's output, and closed by a handoff gate with evidence, population, refusal and the three verdicts, drawing directives from the semantic operations, control flow and structure declarations, and closing with invariant records and a report.

Invariant
A well-formed PAG document is a node-gated, keyword-typed, invariant-bounded instruction contract whose every verdict carries its population.

Flow

```text
Declaration → MetaBlock → Nodes → Gates → Directives → Invariants → Report → PagDocument
```

Productions

```bnf
PagAuthoringKernel ::= <PagDocumentDeclaration> "->" <PagKeywordOntology> "->" <PagNodeDecomposition> "->" <PagHandoffGate> "->" <PagControlFlow> "->" <PagToolInvocation> "->" <PagStructure> "->" <PagInvariantBlock>
```

Composes
[PAG Document Declaration](https://banes-lab.com/records/algo/pag-document-declaration.md), [PAG Keyword Ontology](https://banes-lab.com/records/algo/pag-keyword-ontology.md), [PAG Node Decomposition](https://banes-lab.com/records/algo/pag-node-decomposition.md), [PAG Handoff Gate](https://banes-lab.com/records/algo/pag-validation-gate.md), [PAG Explicit Control Flow](https://banes-lab.com/records/algo/pag-explicit-control-flow.md), [PAG Semantic Operation](https://banes-lab.com/records/algo/pag-tool-invocation.md), [PAG Structure Declaration](https://banes-lab.com/records/algo/pag-coordination-construct.md), [PAG Invariant Record](https://banes-lab.com/records/algo/pag-constraint-boundary.md)

Forces
[metaprogramming_modeling](https://banes-lab.com/records/force/metaprogramming-modeling.md), [model_governance](https://banes-lab.com/records/force/model-governance.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
[derivation-loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)

Derivation map

orient
[PAG Document Declaration](https://banes-lab.com/records/algo/pag-document-declaration.md)

see
[PAG Keyword Ontology](https://banes-lab.com/records/algo/pag-keyword-ontology.md)

project
[PAG Node Decomposition](https://banes-lab.com/records/algo/pag-node-decomposition.md)

constrain
[PAG Invariant Record](https://banes-lab.com/records/algo/pag-constraint-boundary.md)

act
[PAG Semantic Operation](https://banes-lab.com/records/algo/pag-tool-invocation.md)

verify
[PAG Handoff Gate](https://banes-lab.com/records/algo/pag-validation-gate.md)

terminate
[PAG Well-Formedness Validation](https://banes-lab.com/records/algo/pag-well-formedness-validation.md)

Before

```text
An instruction written as prose, ungated, untyped and unwatched.
```

After

```text
frontmatter + typed declaration → meta block with jurisdiction → nodes each headed, contracted and closed by a handoff gate → directives{semantic operations, control flow, structure declarations} → INVARIANT records → REPORT
```

### PAG Well-Formedness Validation

- Stage: [terminate](https://banes-lab.com/records/stage/terminate.md)
- Axis: [termination](https://banes-lab.com/records/reason/axis-termination.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Scan a PAG document for structural and epistemic defects, each named for the shape it catches — a retired unit head, a node without a gate, a check without evidence, a gate without a population or with an empty one, an unknown left unrouted, a write without a refusal, an artifact without freshness, a node declared twice, an input naming no source, an invariant missing its set, parties or objector, a bare invariant block, a lowercase keyword, a bare FOR, a missing colon, a vague condition — and emit a token-based, regex-free verdict.

Invariant
A PAG document is trusted only after a deterministic well-formedness scan whose defect set is the epistemology's failure taxonomy, never because it reads fluently.

Flow

```text
PagDocument → DefectScan → DefectSet → WellFormednessVerdict
```

Productions

```bnf
PagWellFormedness ::= <PagDocument> "->" <DefectScanSet> "->" <WellFormednessVerdict>
PagDefect ::= "retired_unit_head" | "node_without_gate" | "node_tag_malformed" | "node_declared_twice" | "input_without_source" | "check_without_evidence" | "gate_without_population" | "empty_population" | "result_missing" | "unknown_unrouted" | "write_without_refusal" | "artifact_without_freshness" | "invariant_without_set" | "invariant_without_parties" | "invariant_without_objector" | "bare_invariant_block" | "gate_too_few_conditions" | "gate_too_many_conditions" | "vague_condition" | "for_without_each" | "lowercase_keyword" | "missing_colon" | "no_declaration"
PagWellFormednessVerdict ::= "well_formed" | "ill_formed"
```

Composes
[PAG Handoff Gate](https://banes-lab.com/records/algo/pag-validation-gate.md), [PAG Explicit Control Flow](https://banes-lab.com/records/algo/pag-explicit-control-flow.md)

Named in the derivation of
[PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [model_governance](https://banes-lab.com/records/force/model-governance.md)

Grounds
none

Before

```text
A PAG document trusted because it reads fluently.
```

After

```text
document → defect scan{retired unit head, node without gate, check without evidence, gate without population, empty population, unknown unrouted, write without refusal, artifact without freshness, node declared twice, input without source, invariant without set/parties/objector, bare invariant block, lowercase keyword, for without each, missing colon, vague condition} → well-formed | ill-formed
```

### <PAG Instruction Concern>

- Meta record

Details

Intent
<Declare document type and jurisdiction> → <Draw grounded uppercase directives> → <Decompose into headed, contracted, gated nodes> → <Bind semantic operations and structure declarations> → <Bound with invariant records> → <Validate well-formedness against the failure taxonomy>

Invariant
Any PAG artifact should be treated as a structured instruction contract whose tokens are drawn from a fixed ontology grounded in the reasoning face, whose nodes are closed by evidence-bearing gates that carry their population and route unknown to blocked, and whose invariants name their objector, reducing interpretive ambiguity without guaranteeing deterministic output.

Flow

```text
DocumentType → Keywords → Nodes → Gates → OperationsAndStructure → Invariants → WellFormedness
```

Productions

```bnf
PagInstructionConcern ::= <PagDocumentDeclaration> "->" <PagKeywordOntology> "->" <PagNodeDecomposition> "->" <PagHandoffGate> "->" <PagToolInvocation> "->" <PagStructure> "->" <PagInvariantBlock> "->" <PagWellFormedness>
```

Composes
none

Forces
[metaprogramming_modeling](https://banes-lab.com/records/force/metaprogramming-modeling.md), [model_governance](https://banes-lab.com/records/force/model-governance.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

## Links to

- [Orient](https://banes-lab.com/records/stage/orient.md)
- [Ontology](https://banes-lab.com/records/reason/axis-ontology.md)
- [Set Theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- [PAG Authoring Kernel](https://banes-lab.com/records/algo/pag-authoring-kernel.md)
- [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)
- [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)
- [metaprogramming_modeling](https://banes-lab.com/records/force/metaprogramming-modeling.md)
- [See](https://banes-lab.com/records/stage/see.md)
- [Analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)
- [Project](https://banes-lab.com/records/stage/project.md)
- [Reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- [Graph](https://banes-lab.com/records/reason/math-type-graph.md)
- [modularity](https://banes-lab.com/records/force/modularity.md)
- [domain_boundary](https://banes-lab.com/records/force/domain-boundary.md)
- [Verify](https://banes-lab.com/records/stage/verify.md)
- [Verification](https://banes-lab.com/records/reason/axis-verification.md)
- [Logic](https://banes-lab.com/records/reason/math-type-logic.md)
- [PAG Well-Formedness Validation](https://banes-lab.com/records/algo/pag-well-formedness-validation.md)
- [model_governance](https://banes-lab.com/records/force/model-governance.md)
- [Ver Evidence](https://banes-lab.com/records/reason/node-ver-evidence.md)
- [Ver Population](https://banes-lab.com/records/reason/node-ver-population.md)
- [Ver Refusal](https://banes-lab.com/records/reason/node-ver-refusal.md)
- [Ver Standing](https://banes-lab.com/records/reason/node-ver-standing.md)
- [Ter Block](https://banes-lab.com/records/reason/node-ter-block.md)
- [Act](https://banes-lab.com/records/stage/act.md)
- [Formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- [control_coordination](https://banes-lab.com/records/force/control-coordination.md)
- [Constrain](https://banes-lab.com/records/stage/constrain.md)
- [Teleology](https://banes-lab.com/records/reason/axis-teleology.md)
- [Optimisation](https://banes-lab.com/records/reason/math-type-optimisation.md)
- [security_governance](https://banes-lab.com/records/force/security-governance.md)
- [Computation](https://banes-lab.com/records/reason/math-type-computation.md)
- [runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md)
- [event_messaging](https://banes-lab.com/records/force/event-messaging.md)
- [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md)
- [Derive](https://banes-lab.com/records/stage/derive.md)
- [PAG Document Declaration](https://banes-lab.com/records/algo/pag-document-declaration.md)
- [PAG Keyword Ontology](https://banes-lab.com/records/algo/pag-keyword-ontology.md)
- [PAG Node Decomposition](https://banes-lab.com/records/algo/pag-node-decomposition.md)
- [PAG Handoff Gate](https://banes-lab.com/records/algo/pag-validation-gate.md)
- [PAG Explicit Control Flow](https://banes-lab.com/records/algo/pag-explicit-control-flow.md)
- [PAG Semantic Operation](https://banes-lab.com/records/algo/pag-tool-invocation.md)
- [PAG Structure Declaration](https://banes-lab.com/records/algo/pag-coordination-construct.md)
- [PAG Invariant Record](https://banes-lab.com/records/algo/pag-constraint-boundary.md)
- [The derivation loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)
- [Terminate](https://banes-lab.com/records/stage/terminate.md)
- [Termination](https://banes-lab.com/records/reason/axis-termination.md)
