import { AGENT_SECTION_ICON } from "#configuration/icons/grammar.icons"; import { AGENT_SECTION_ID } from "#core/ids/grammar.ids"; import { PAG_LANGUAGE } from "#configuration/constants/code.constants"; import type { Section } from "#types/document.types"; import { templateBodyOf } from "#core/converters/grammar.converter"; const AGENT_TEMPLATE = templateBodyOf("AGENT"); const VERIFIER_TEMPLATE = templateBodyOf("VERIFICATION"); const CREATOR_TEMPLATE = '---\nname: {creator_name}\ntype: TEMPLATE\nversion: 1.0.0\n---\n\nTHIS TEMPLATE GENERATES an agent from inspected evidence\n\n%% META %%:\n objective: "an agent whose every claimed capability traces to evidence and has failed on purpose once"\n jurisdiction: and {project.agent_registry} | external: every other agent\n recursion_limit: 2\n\n# NODE 1 — EVIDENCE [epistemic · ontology · set-theory · yields: set]\n@genesis: existence\nCONTRACT:\n input: \n transform: DISCOVER_RESOURCES "" INTO ; FOR EACH IN : READ_RESOURCE INTO ; EXTRACT_FACTS FROM INTO \n output: \nHANDOFF GATE:\n [check] is non-empty because a search was run (evidence: the search log) over: measured: / \n [check] every capability the agent will claim traces to an item in (evidence: one item per capability)\n [check] nothing in came from prior knowledge (evidence: a source per item)\n result: pass -> NODE 2 | unsourced item -> REPAIR (owner: NODE 1) | unknown -> BLOCKED\n\n# NODE 2 — THE PORTABLE CONTRACT [epistemic · formalisation · computation · yields: procedure]\n@genesis: structure\nCONTRACT:\n input: from NODE 1\n transform: COMPOSE_ARTIFACT FROM · semantic operations only; slots for every host fact, {project.*} {convention.*} {limits.*} {toolchain.*}; no runtime, no tool name, no path, no model\n preserves: every capability\'s trace to its evidence\n output: \nHANDOFF GATE:\n [check] names no harness feature (evidence: a scan of its literals) over: its literals measured: / \n [check] every host fact in is a slot (evidence: no literal path or command)\n [check] every operation in is one an adapter can map (evidence: the operation set)\n result: pass -> NODE 3 | harness name -> REPAIR (owner: NODE 2) | unknown -> BLOCKED\n\n# NODE 3 — RENDERING [evaluative · representation · information-theory · yields: artifact]\n@genesis: transformation\nCONTRACT:\n input: from NODE 2\n transform: COMPOSE_ARTIFACT FROM USING \n output: \n freshness: fingerprint() + fingerprint()\nHANDOFF GATE:\n [check] every operation resolved to a tool (evidence: the adapter\'s map) over: operations measured: / \n [check] every slot resolved to a value or a declared absence (evidence: no unresolved slot)\n [check] the identity the agent writes under is declared in the body the runtime delivers (evidence: the body)\n result: pass -> NODE 4 | unresolved slot -> REPAIR (owner: NODE 2) | unknown -> BLOCKED\n\n# NODE 4 — PROOF BEFORE PERSISTENCE [evaluative · verification · logic · yields: boolean]\n@genesis: constraint\nCONTRACT:\n input: from NODE 3\n transform: EXECUTE_TOOL ON INTO ; EXECUTE_TOOL ON INTO ; VALIDATE_ARTIFACT , AGAINST ; PERSIST_ARTIFACT TO {project.agent_registry}\n output: the persisted agent\nHANDOFF GATE:\n [check] the contradiction reported with its evidence (evidence: )\n [check] the clean case passed for the right reason (evidence: names the check it passed) over: the two cases measured: / \n [check] persisted only after both cases ran (evidence: the two runs precede the write)\n refuse: either run missing before PERSIST_ARTIFACT\n result: pass -> TERMINATE | silent contradiction -> REPAIR (owner: NODE 2) | unknown -> BLOCKED\n\n# CROSS-NODE INVARIANTS\nINVARIANT evidence-first: an agent is generated from inspected evidence, never from intent alone over: every generated agent binds: the creator objector: [check] nothing in evidence came from prior knowledge at NODE 1\nINVARIANT fail-on-purpose: no agent is persisted before it has failed on a planted contradiction over: every generated agent binds: the creator objector: [check] the contradiction reported at NODE 4'; const EXPRESSION_DIAGRAM = 'flowchart TB\n meta["META · the trust anchor as a trust line, the jurisdiction, the phase kind bound at ORIENT"]\n self["A node that reads {self.definition} · the self-audit as a contract"]\n decision["REQUEST_DECISION · resolves ABSENT for a bounded reader"]\n proof["The creator\'s proof gate · fails on purpose, passes for the right reason, then persists"]\n artifact["The terminal node · one typed artifact with its report, never a question"]\n meta --> self --> decision --> proof --> artifact'; export const AGENT_SECTION: Section = { icon: AGENT_SECTION_ICON, id: AGENT_SECTION_ID, intro: "An agent is a document of the agent type, a cognition walked on the reasoning axis, the shape an agent shows; a verifier is a document of the verification type, an epistemology on the verification axis, as a verifier walks it. A creator is a template that generates an agent, the one a creator carries. What an agent is, why it is a walked loop and never a persona, and how a verifier earns trust, is agents as executed contracts and verify the verifier. This section is how a document expresses each, where guarantees live maps the expression, and the first two bodies are the grammar's own template records.", subsections: [ { blocks: [ { application: "Write the trust anchor as the trust line of the meta block, the jurisdiction beneath it, and bind the phase kind in the orient node. Write the self-audit as a node whose contract reads the agent's own definition and tests every capability it claims on a positive and a negative case. Let a decision request resolve absent for a bounded reader, so its terminal node yields the artifact and never a question. Write the creator's proof as a gate that runs the rendered agent on a planted contradiction and on a clean case before the persist line, and refuses the persist while either run is missing.", boundary: "An agent written for a bounded invocation returns instead of asking, the inversion composing a collaboration derives; its terminal node yields the artifact, never a question.", cause: "A capability stated in prose has no node that exercises it, so nothing in the document can show the claim false.", decision: "Express each guarantee of the agent as a node with a gate, rather than as a sentence about the agent in its description.", failureMode: "An agent's description says it calibrates its detectors, no node reads a fixture, and the description is the only place calibration ever happened.", kind: "lesson", principle: "An agent document carries its guarantees as nodes and gates, so each one can be walked and can fail.", problem: "An agent's guarantees stated in its description are read, never walked.", validation: "For each capability the agent's description claims, name the node whose gate exercises it. A capability with no node was adopted from the description, and the document has not shown it.", }, { kind: "text", text: "A claim's kind decides the evidence that can settle it, because a claim of existence needs a presence search and a claim of behaviour needs an execution, so the orient node assigns each claim its kind and the evidence shape that kind requires before anything is probed. The identity the agent writes under is declared in the body the runtime delivers, for the reason agents as executed contracts gives.", }, { code: AGENT_TEMPLATE, kind: "code", language: PAG_LANGUAGE, title: "an agent" }, { code: VERIFIER_TEMPLATE, kind: "code", language: PAG_LANGUAGE, title: "a verifier" }, { code: CREATOR_TEMPLATE, kind: "code", language: PAG_LANGUAGE, title: "a creator" }, { caption: "where guarantees live", kind: "mermaid", text: EXPRESSION_DIAGRAM }, ], title: "Walked, not adopted", }, ], title: "Agent templates", };