# configuration/strings/pattern.strings.ts

> 61 lines of code and 6 definitions.

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

## Definitions

- `BINDING_SAMPLE` (lexical_declaration, line 6)
- `ADMISSIBLE_SAMPLE` (lexical_declaration, line 9)
- `CYCLE_SAMPLE` (lexical_declaration, line 12)
- `BINDING_DIAGRAM` (lexical_declaration, line 15)
- `CYCLE_DIAGRAM` (lexical_declaration, line 18)
- `PATTERN_SECTION` (lexical_declaration, line 21, exported)

## Source

```typescript
import { PAG_LANGUAGE } from "#configuration/constants/code.constants";
import { PATTERN_SECTION_ICON } from "#configuration/icons/grammar.icons";
import { PATTERN_SECTION_ID } from "#core/ids/grammar.ids";
import type { Section } from "#types/document.types";

const BINDING_SAMPLE =
    '# NODE 1 — ORIENT   [epistemic · ontology · set-theory · yields: run-context]\n@purpose: "Bind the run to exactly one phase kind before touching anything, so the op-set is a contract rather than restraint"\n@cue: "DISCLOSE_THEN_BIND"\n\nCONTRACT:\n  input:        <the invocation>\n  transform:    detect the phase kind → bind its allowed and forbidden operations → bind the one artifact it emits\n  constraints:  INVESTIGATE and ACTION are mutually exclusive; the checks that heal rewrite the tree, so they belong to ACTION\n  output:       run_context { phase, allowed_ops, forbidden_ops, artifact }\n  handoff:      phase bound to exactly one AND the two op-sets disjoint (yields: boolean)\n\nFUNCTION bind_phase(invocation):\n  DETERMINE kind FROM invocation   # INVESTIGATE | ACTION\n  IF kind == "INVESTIGATE":\n    RETURN {phase: "INVESTIGATE", allowed_ops: [DISCOVER_RESOURCES, READ_RESOURCE, SEARCH_CONTENT, ANALYZE_CONTENT], forbidden_ops: [<mutation>, <gap fixing>], artifact: <investigation report>}\n  IF kind == "ACTION":\n    RETURN {phase: "ACTION", allowed_ops: [<bounded fix>, PERSIST_ARTIFACT, EXECUTE_TOOL], forbidden_ops: [<gap discovery>], artifact: <action log>}\n\nHANDOFF GATE (evidence-bearing):\n  rule_id: "ORIENT"   yields: boolean\n  [check] phase bound to exactly one of INVESTIGATE | ACTION (evidence: run_context.phase)\n  [check] allowed and forbidden op-sets are disjoint (evidence: run_context.allowed_ops, forbidden_ops)\n  [check] the artifact the phase emits is the one its kind emits (evidence: run_context.artifact)\n  result: pass → NODE 2 | undetectable kind → REPAIR (owner: NODE 1) | unknown → BLOCKED';

const ADMISSIBLE_SAMPLE =
    '# NODE 7 — CONSTRAIN   [conative · teleology · optimisation · yields: admissibility boolean]\n@purpose: "Ask after the operations exist whether they stayed inside the bound op-set · a declaration is not evidence that it held"\n@cue: "ADMISSIBLE_BEFORE_VERIFY"\n\nCONTRACT:\n  input:        observations + run_context\n  transform:    for each observation → did it mutate under INVESTIGATE, did it discover under ACTION\n  constraints:  a breach routes to the node that owns the fix, never a repair in place, because repairing in place is the same breach in the node that found it\n  output:       admissibility { ok, op_violations[] }\n  handoff:      GATE — op-sets honoured (yields: boolean)\n\nFUNCTION assess_admissibility(observations, run_context):\n  DECLARE op_violations: array\n  SET op_violations = []\n  FOR EACH o IN observations:\n    IF run_context.phase == "INVESTIGATE" AND o CAUSED <mutation>: APPEND {claim: o.claim, violation: "mutation under INVESTIGATE"} TO op_violations\n    IF run_context.phase == "ACTION" AND o DISCOVERED <new scope>: APPEND {claim: o.claim, violation: "discovery under ACTION"} TO op_violations\n  RETURN {ok: op_violations.length == 0, op_violations: op_violations}\n\nHANDOFF GATE (teleology admissibility gate):\n  rule_id: "CONSTRAIN"   yields: boolean\n  [check] admissibility.op_violations.length == 0 (evidence: INVESTIGATE no mutation / ACTION no discovery)\n  [check] every observation was classified against the phase (evidence: one verdict per observation) over: observations measured: <classified> / <observations>\n  [check] every breach names the node that owns the fix (evidence: op_violations[].owner)\n  result: pass → NODE 8 | a breach → REPAIR (owner: NODE 6) | unknown → BLOCKED';

const CYCLE_SAMPLE =
    "# the shape that follows is a cycle rather than a line · the edge back is where a missed repair is caught\nINVESTIGATE  → <a report of evidence · every claim verified, contradicted or unverified>\nACTION       → <a log of bounded changes against that report · nothing discovered>\nINVESTIGATE  → <the same report, with what is settled removed>\nSTOP when    <every gap is resolved or carried forward with a reason>";

const BINDING_DIAGRAM =
    'flowchart TB\n    phase["A run"]\n    kind{"Bound to which?"}\n    inv["INVESTIGATE · discovers, never fixes · emits a report"]\n    act["ACTION · fixes against known evidence, never discovers · emits a log"]\n    mixed["Both · mutated under a read-only contract, findings describe a tree that moved"]\n    phase --> kind\n    kind -- one --> inv\n    kind -- the other --> act\n    kind -. neither, or both .-> mixed';

const CYCLE_DIAGRAM =
    'flowchart LR\n    i1["Investigate"]\n    a1["Act"]\n    i2["Investigate · verify"]\n    stop["Stop · every gap resolved or carried with a reason"]\n    i1 --> a1 --> i2\n    i2 -- gaps remain --> a1\n    i2 -- none --> stop';

export const PATTERN_SECTION: Section = {
    icon: PATTERN_SECTION_ICON,
    id: PATTERN_SECTION_ID,
    intro: "This section covers how a run is bound to one of two kinds before it touches anything, as derived in agents as executed contracts and shown in <cite>two kinds</cite>. The orient node binds the kind, as written in <cite>binding the kind</cite>, and the constrain node asks afterwards whether the binding held, as written in <cite>admissibility</cite>. <cite>the cycle</cite> and <cite>cycle, not line</cite> show the shape the two kinds make together.",
    subsections: [
        {
            blocks: [
                {
                    application:
                        "In practice, every run is bound to one kind in its orient node, and the operations it permits and forbids are derived from that kind rather than listed by hand. An investigation discovers, reads, searches and analyzes, and it persists exactly one report. An action reads the report, repairs each gap in dependency order, and logs what changed. The constrain node then checks, once the operations exist, that each stayed inside its set, and a breach is routed to the node that owns the fix.",
                    boundary:
                        "A single-party task with one read and one write is one action run, and splitting it into an investigation and an action doubles the document for nothing. The binding matters where the findings will be read by a party that did not produce them.",
                    cause: "A finding is a claim about a tree, and a tree the finder also mutated is a different tree from the one the finding describes.",
                    decision:
                        "The kind is bound in the orient node before any operation, rather than declared in prose in the hope that the operations stay within it.",
                    failureMode:
                        "A run finds a defect, repairs it in passing, and reports the defect as open, so the next run repairs it again against a tree where it no longer exists.",
                    kind: "lesson",
                    principle:
                        "For this reason a run either investigates or acts, and the operations allowed to each have nothing in common.",
                    problem: "A run asked to look starts repairing what it sees.",
                    validation:
                        "To check this, list the operations of a run and mark each as reading or writing. A run that has both kinds is unbound, and its first write is where it splits.",
                },
                {
                    kind: "text",
                    text: "The binding is a property of the run, declared in its orient node before any operation, and the permitted operations follow from it, which is state isolation applied to a run. An investigation may discover, read, search and analyze resources, and it may persist one artifact, its report. It may not edit, write anywhere else, or run a command that changes the tree, and that includes the verification chain, because the chain's early stages rewrite the tree. An action may persist, execute and fix, but it may not widen its scope, because scope discovered in the middle of an action is a finding that was never reported and will never be verified. The same binding is taught in agents as executed contracts; here it is the contract of one node.",
                },
                {
                    kind: "text",
                    text: "The shape that follows is a cycle rather than a line. The work is investigated, then acted on, then investigated again to verify what the action did, and it stops when the second investigation finds every gap either resolved or carried forward with a reason. Each investigation reads the same report and removes what is settled, so the report converges rather than growing. A fixed pipeline of positions cannot express this, because it has no edge back, and the edge back is where a repair that missed is caught.",
                },
                {
                    kind: "text",
                    text: "A run declared as an investigation can still contain a write that went unnoticed, and a check that reads only the declaration passes it. So the constrain node checks the observations against the operations the binding allowed, and a breach is routed to the node that owns the fix rather than repaired in place, because a repair made in place is the same breach, committed by the node that found it.",
                },
                { code: BINDING_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "binding the kind" },
                { code: ADMISSIBLE_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "admissibility" },
                { code: CYCLE_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "the cycle" },
                { caption: "two kinds", kind: "mermaid", text: BINDING_DIAGRAM },
                { caption: "cycle, not line", kind: "mermaid", text: CYCLE_DIAGRAM },
            ],
            title: "Investigate or act",
        },
    ],
    title: "Phase binding",
};
```
