import { EXEMPLAR_SECTION_ICON } from "#configuration/icons/grammar.icons"; import { EXEMPLAR_SECTION_ID } from "#core/ids/grammar.ids"; import { PAG_LANGUAGE } from "#configuration/constants/code.constants"; import type { Section } from "#types/document.types"; const HEADER_SAMPLE = "---\nname: {task_name}\ntype: DEBUG\nversion: 1.0.0\n---\n\nTHIS DEBUG RESOLVES a symptom to an evidence-scored root cause and one minimal fix by walking the ten-node loop across four reasoning layers\n\n%% META %%:\n priority: EVIDENCE > ROOT_CAUSE > SPEED\n trust: procedural_trace = TRUSTED, test_result = TRUSTED, prior_knowledge = UNTRUSTED, a_hypothesis = UNTRUSTED_UNTIL_SCORED\n objective: {bug_report}\n recursion_limit: {limits.max_fix_attempts}\n parameters: every taxonomy, threshold and command resolves from {convention.*}, {limits.*} and {toolchain.*}, never typed\n\nTHE FOUR LAYERS · each answers one question about this document\n substrate how does a fix come to be grounds the path from differential to fix\n epistemic how is the bug known orient · see · derive · project · act\n conative which line is worth pursuing intent · constrain mandatory, always\n evaluative is it fixed, and are we done verify · commit · terminate mandatory, always\n\nYIELDS-SHAPE LEGEND · every decision resolves to a typed shape\n set-theory -> set or boolean logic -> boolean graph -> edge-list optimisation -> boolean or ranking\n analysis -> operation computation -> procedure probability -> a number in zero to one dynamical-systems -> boolean or counter"; const NODE_SAMPLE = '# NODE 2 — INTENT [conative · teleology · optimisation · yields: ranking]\n@purpose: "extract the differential and rank the candidate lines by worth, so one line is traced and the rest are not"\n@axis_question: "which line is worth pursuing?"\n@cue: "rank before you trace"\n@mandatory\n\nCONTRACT:\n input: the session from NODE 1 · the symptom, what works, what breaks\n transform: detect the works-versus-breaks differential; rank the candidate lines by probability times severity minus cost\n constraints: a line is admissible only inside {limits.max_fix_attempts}\n output: , and the selected line\n handoff: the selected line is the argmax of the admissible · yields a boolean over a ranking\n\nDECLARE tel: object\nSET tel = {\n objective: "find and fix the root cause", # yields: a set\n utility: FUNCTION(line) -> probability(line) * severity(line), # yields: a number\n cost: FUNCTION(line) -> what tracing it costs, # yields: a number\n priority: FUNCTION(ranked) -> ranked[0] is admissible # yields: a boolean over a ranking\n}\n\n# OUTPUT CONTRACT\nSET = RANK BY tel.utility - tel.cost\n\nHANDOFF GATE (evidence-bearing):\n rule_id: "INTENT" yields: ranking\n [check] the selected line is the argmax of utility minus cost (evidence: the ranking)\n [check] holds more than one admissible line (evidence: a count above one)\n [check] no line was traced before the ranking existed (evidence: the trace log starts after this gate)\n result: pass -> NODE 3 | one admissible line -> REPAIR (owner: NODE 1) | unknown -> BLOCKED'; const SPINE_SAMPLE = "# THE LOOP SPINE · declared once, every node cites it\n# node layer axis yields transition out\n# orient epistemic ontology a set, with evidence sequences -> intent\n# intent conative teleology an objective, a ranking GATE worth -> see | redirect\n# see epistemic analysis lenses, edges sequences -> derive\n# derive epistemic reasoning claims sequences -> project\n# project epistemic reasoning an ordered graph sequences -> act\n# act epistemic formalisation procedures sequences -> constrain\n# constrain conative teleology admissibility GATE -> verify | repair\n# verify evaluative verification a report GATE evidence · refutes back to the earliest owner\n# commit evaluative representation the artifact sequences -> terminate\n# terminate evaluative termination stop GATE stop -> STOP | blocked -> ask\n\n# REPAIR EDGE · verify fails backward to the earliest node that can supply the missing evidence, bounded by {recursion_limit}\n# a repair invalidates every dependent record forward · nothing downstream is restored"; const FAMILY_SAMPLE = '# the families · each a document type, each walked by the model and axis its type declares\nCHECKLIST pattern-cycle formalisation a plan, produced by owned nodes\nDEBUG epistemology analysis a symptom to an evidence-scored cause and one fix\nVERIFICATION epistemology verification claims adjudicated against implementation evidence\nAUDIT epistemology verification an agent measured against its contract, then corrected\nDISTILLATION epistemology reasoning repeated behaviour to one proven base\nTRANSLATION epistemology representation a rendering audited line by line against its source\nCOMPOSITION pattern-cycle formalisation a structure rendered from anchors and modifiers\n\n# the genesis question each answers · one question, one family\n"how does a plan come to be?" -> CHECKLIST\n"how does a fix come to be?" -> DEBUG\n"how does a verdict come to be?" -> VERIFICATION, AUDIT\n"how does a base come to be?" -> DISTILLATION\n"how does a rendering come to be?" -> TRANSLATION, COMPOSITION'; const WALK_DIAGRAM = 'flowchart TB\n type["The document type · declares the model and the axis"]\n layers["Four layers · substrate, epistemic, conative, evaluative"]\n nodes["Nodes · each typed to the shape it yields, each reading the prior output"]\n gate["One evidence-bearing gate per node"]\n spine["The spine · transitions declared once"]\n artifact["The artifact the loop terminates on"]\n type --> layers --> nodes --> gate --> artifact\n spine --> nodes\n gate -. repairs back, bounded .-> nodes'; const WALK_VS_READ_DIAGRAM = 'flowchart LR\n read["Read a template for ideas"]\n shaped["Write something template-shaped"]\n none["None of its guarantees"]\n walk["Walk its nodes as the spine declares"]\n artifact["The artifact the loop terminates on"]\n read -. the tempting path .-> shaped --> none\n walk --> artifact'; export const EXEMPLAR_SECTION: Section = { icon: EXEMPLAR_SECTION_ICON, id: EXEMPLAR_SECTION_ID, intro: "A template family is a document type whose nodes are the nodes of the reasoning loop, and the families lists them with the genesis question each answers. The document has no runtime; what walks it is the reasoning model its type declares, on the axis its type names, and an adapter performs the effects, the walk type to artifact draws. Every node states its layer, its axis, the shape its decision yields, the contract it transforms, and one evidence-bearing gate, as one node shows beneath family header. The transitions are declared once in loop spine and every node cites it. A template is used by walking its nodes as the spine declares, which is what execute the template means, and walk or read is the difference that decides whether its guarantees hold.", subsections: [ { blocks: [ { application: "Open a family document by declaring its type, its trust anchor, its recursion limit and the slots every host fact resolves through. State the four layers and the question each answers about this document, and the shape legend every decision is typed by. Give each node a purpose, an axis question, a cue and a contract, type its decisions, and close it on a gate whose checks carry their evidence. Declare the spine once and let every handoff cite it. Select the family by the genesis question the artifact answers.", boundary: "A template family fits an artifact that will be walked; what is read rather than walked is stated under from intent to structure.", cause: "A node that reads only the prior node's output cannot skip a decision, and a gate that owes a shape cannot be satisfied by a different one.", decision: "Select the family by the genesis question the artifact answers, and let the type declare who walks it and on which axis.", failureMode: "A debugging document is walked as a plan, the ranking of candidate lines is skipped, and the first hypothesis is traced to the end.", kind: "lesson", principle: "A template family is a document type whose nodes are typed contracts, walked by the reasoning model its type declares.", problem: "A family document that does not say who walks it and on which axis leaves the reader to pick.", validation: "For each node, name the layer, the axis and the shape its header declares, and the gate that carries evidence. A node missing any of the four is prose in a family's clothes.", }, { kind: "text", text: "The trust anchor says which inputs are evidence and which are claims, so a hypothesis is untrusted until it is scored and prior knowledge is untrusted throughout.", }, { kind: "text", text: "A node is design by contract at the scale of one decision. The repair edge is the one a fixed pipeline lacks, and validation gates says what it does.", }, { kind: "text", text: "Families are selected by the genesis question, and each inlines its whole structure rather than importing a shared spine. That is the one place duplication is deliberate: independence is what makes each family walkable on its own. Its loop, its typing and its gates are domain-neutral and transfer to any tree unchanged. Its catalogues, the taxonomies it cites and the thresholds it names, are slots the adapter resolves, as limits states.", }, { code: HEADER_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "family header" }, { code: NODE_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "one node" }, { code: SPINE_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "loop spine" }, { code: FAMILY_SAMPLE, kind: "code", language: PAG_LANGUAGE, title: "the families" }, { caption: "type to artifact", kind: "mermaid", text: WALK_DIAGRAM }, { caption: "walk or read", kind: "mermaid", text: WALK_VS_READ_DIAGRAM }, ], title: "Typed nodes, one gate each", }, ], title: "Template families", };