# configuration/strings/orchestration.strings.ts

> 62 lines of code and 6 definitions.

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

## Definitions

- `DAG_SAMPLE` (lexical_declaration, line 6)
- `MACHINE_SAMPLE` (lexical_declaration, line 9)
- `PARALLEL_SAMPLE` (lexical_declaration, line 12)
- `DECLARED_DIAGRAM` (lexical_declaration, line 15)
- `ORDINAL_DIAGRAM` (lexical_declaration, line 18)
- `ORCHESTRATION_SECTION` (lexical_declaration, line 21, exported)

## Source

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

const DAG_SAMPLE =
    '# NODE 5 — PROJECT   [epistemic · reasoning · graph · yields: edge-list]\n@purpose: "Declare the order as edges, so a reader who did not write it can still resolve it"\n@cue: "DECLARE_THE_EDGES"\n\nCONTRACT:\n  input:        <the units of work>\n  transform:    for each unit → name what it depends on → refuse a cycle → name the groups that are independent\n  constraints:  a successor is declared by name, never derived from a position; at most one unit that holds the others is open at a time\n  output:       DAG <units>\n  handoff:      acyclic AND every unit names its dependencies (yields: edge-list + boolean)\n\nDAG <units>:\n    NODE <unit-a>:\n        <what settles it>\n    NODE <unit-b> AFTER <unit-a>:\n        <what settles it>\n    NODE <unit-c> DEPENDS_ON [<unit-a>]:\n        <what settles it>\n    PARALLEL_GROUP: <unit-b>, <unit-c>\n\nHANDOFF GATE (evidence-bearing):\n  rule_id: "PROJECT"   yields: edge-list + boolean\n  [check] no unit depends on itself through any path (evidence: the walk over DAG <units>) over: <units> measured: <acyclic> / <units>\n  [check] every successor is named, none is a number (evidence: the AFTER and DEPENDS_ON clauses)\n  [check] at most one holding unit is open (evidence: count of open holds)\n  result: pass → NODE 6 | a cycle → REPAIR (owner: NODE 5) | unknown → BLOCKED';

const MACHINE_SAMPLE =
    "# a lifecycle as a closed set of states · a transition names its trigger and its guard\nSTATE_MACHINE <unit>:\n    STATE <planned>:\n        ENTRY: <no artifact exists yet>\n    STATE <open>:\n        ENTRY: <a party has begun>\n    STATE <settled>:\n        ENTRY: <every condition of the exit holds>\n    STATE <retired>:\n        ENTRY: <what the settlement implies has landed>\n\n    TRANSITION FROM <planned> TO <open> ON <first-reading>\n    TRANSITION FROM <open> TO <settled> ON <exit-condition>\n        GUARD: <every party that must agree has agreed>\n    TRANSITION FROM <settled> TO <retired> ON <implied-work-landed>\n        GUARD: <nothing the settlement distributed is still open>\n    TRANSITION FROM <open> TO <planned> ON <artifact-removed>\n        GUARD: <no argument has landed yet>\n\nFUNCTION state_of(unit):\n  # derived from the tree on every read · never written by a party\n  IF NOT EXISTS(unit.artifact): RETURN <planned>\n  IF every_exit_condition_holds(unit) AND implied_work_landed(unit): RETURN <retired>\n  IF every_exit_condition_holds(unit): RETURN <settled>\n  RETURN <open>";

const PARALLEL_SAMPLE =
    '# NODE 6 — ACT   [epistemic · formalisation · computation · yields: procedures]\nCONTRACT:\n  input:        DAG <units>\n  transform:    run each independent group as bounded readers → join their artifacts → a participant waits rather than returns\n  constraints:  a bounded reader receives a task and nothing shared; whether a group runs together is the harness\'s fact, declared independence is the document\'s\n  output:       artifacts[] per group\n  handoff:      every group joined or explicitly still open (yields: procedure)\n\nPARALLEL:\n    TASK "<investigate unit b · mutate nothing>" WITH agent: <role-b> → <artifact-b>\n    TASK "<investigate unit c · mutate nothing>" WITH agent: <role-c> → <artifact-c>\nEND\nAWAIT <artifact-b>, <artifact-c> INTO <artifacts>\n\n# a participant does not join · it waits, and a wait is a call rather than a halt\nWAIT ON <the shared surface> AS <party> INTO <change>\nIF <change> == <changed>:\n    READ_RESOURCE <the shared surface> whole INTO <current>';

const DECLARED_DIAGRAM =
    'flowchart TB\n    prose["Prose · \'first do this, then that, meanwhile the other\'"]\n    implied["Ordering implied by sentence order · the model reconstructs it"]\n    declared["A construct · DAG, STATE_MACHINE, PARALLEL, AWAIT, WAIT"]\n    explicit["Edges, states and groups every reader shares"]\n    prose --> implied\n    declared --> explicit';

const ORDINAL_DIAGRAM =
    'flowchart LR\n    ordinal["An ordinal · a position in a total order"]\n    hidden["A unit raised before its predecessor settles · every number still intact"]\n    name["A declared successor · an edge in a partial order"]\n    caught["A successor nobody created, or a unit no predecessor declared · both decidable"]\n    ordinal -. preserves the violation .-> hidden\n    name --> caught';

export const ORCHESTRATION_SECTION: Section = {
    icon: ORCHESTRATION_SECTION_ICON,
    id: ORCHESTRATION_SECTION_ID,
    intro: "Orchestration is the part of a document that says how work is ordered and where it runs in parallel, and the grammar does not let that be implied. A document declares its structure with constructs, each tied to the representation it makes explicit, as shown in <cite>prose or construct</cite>. A dependency graph covers a partial order with forward dependencies; <cite>dependency graph</cite> declares one by name, and <cite>name, never number</cite> shows what the name gains. A finite state machine covers a lifecycle drawn from a closed set of states, as shown in <cite>state machine</cite>. Alongside these are a priority queue for a ranking, a flowchart for the rendered view of any of them, a surface for state that several parties share, a parallel block for readers that return, and a wait for a reader that never returns; <cite>join and wait</cite> writes that last pair. The same idea is taught in the plan is a graph. Here it is the project stage of the loop, and it yields an edge-list. Ordering carried by the order of sentences is temporal coupling, and a model given prose reconstructs a structure of its own.",
    subsections: [
        {
            blocks: [
                {
                    application:
                        "In practice, an order is modelled as a dependency graph whose nodes name what they depend on, so the order is partial and a number never stands in for an edge. A lifecycle is modelled as a finite state machine whose states form a closed set, whose transitions name their trigger and their guard, and whose current state is derived from the tree by a function rather than written by a party. Independent investigations run as bounded readers in a parallel block, with their artifacts joined by an await, and a participant waits through a command with its turn kept open.",
                    boundary:
                        "Whether a declared parallel group actually runs in parallel is a fact about the harness. The grammar declares that the readers are independent, the binding decides what that gains, and a harness with no concurrency runs them in order without the document changing.",
                    cause: "A sentence has an order and a graph has edges, and only the second survives being read by a party that did not write it.",
                    decision:
                        "The order goes in a graph and the lifecycle in a state machine, rather than the units being numbered and the sequence narrated.",
                    failureMode:
                        "A sequence of decisions is numbered, one is raised out of dependency order because the next number was free, and every citation of the displaced decision resolves to the wrong thing with nothing erroring.",
                    kind: "lesson",
                    principle:
                        "For this reason concurrency and event ordering are declared as structure, never implied by the order of the text.",
                    problem:
                        "Ordering implied by the order in which sentences appear is reconstructed by every reader, and each reconstructs it differently.",
                    validation:
                        "To check this, reorder the sentences of a node and run it again. Where the outcome changed, the ordering was carried by prose, and the repair is the construct that carries it explicitly.",
                },
                {
                    kind: "text",
                    text: "A dependency graph is the construct for work whose order is a set of edges rather than a line. A node names what it depends on and what comes after it, and the successor is declared by name rather than derived from a position, for the reason given in the board and the venue. A directed acyclic graph turns a circular dependency into a defect the reader can see. Where one unit holds every other party's work, at most one such unit is open at a time, because two holds are two waits with no defined order between them.",
                },
                {
                    kind: "text",
                    text: "A finite state machine is the construct for a lifecycle, and its states form a closed set because a mechanism can join on a value from a closed set but not on a sentence. A unit moves forward through its states over its life and never backwards, with one correction allowed where an act is reversed before anything depends on it. The current state is a derived state, a function over the tree, and no party writes it. Both constructs are declarative configuration of a run, where a paragraph would only imply the configuration.",
                },
                {
                    kind: "text",
                    text: "A parallel block with an await is the construct for readers that return: each is spawned with a task, receives nothing shared, and returns exactly one typed artifact. Investigations that read a tree and write nothing belong there, one per concern, because reading contends with nothing. A wait is the construct for a participant, which never returns; for a participant, posting and waiting are one operation, and a wait is a call rather than a halt. The two constructs are not interchangeable, because an await joins a reader that was always going to end, while a wait keeps open a reader that must not end.",
                },
                { code: DAG_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "dependency graph" },
                { code: MACHINE_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "state machine" },
                { code: PARALLEL_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "join and wait" },
                { caption: "prose or construct", kind: "mermaid", text: DECLARED_DIAGRAM },
                { caption: "name, never number", kind: "mermaid", text: ORDINAL_DIAGRAM },
            ],
            title: "Structure is declared",
        },
    ],
    title: "Orchestration as declared structure",
};
```
