{
  "instructions": "EN Diagram — structural verification for concurrent systems. Pure math, no AI.\n\n## Syntax\nOne statement per line:\n  actor do: action needs: input1, input2 yields: output1, output2 at: context\n\n- All five parts required.\n- Names span words; whitespace preserved. Quote only if name contains `,`, `:`, or `#`.\n- Shared names = connections: one action's `yields:` matching another's `needs:` wires them automatically. String equality is the link. IMPORTANT: use natural-language names with spaces (`dln proof 1`), not camelCase, snake_case, or prefixes — transforming the name fragments what should be one entity and the whole analysis will be wasted.\n- Multi-actor: `a, b do: action needs: X yields: Y` = one joint action. Identical statements merge.\n- `#` starts a comment.\n\n## Modeling\nSame name = same thing. Put all required inputs in one `needs:` list (AND). Give two actions the same yield-name to offer alternatives (OR). Sequence = one action consuming another's yield. Re-yield stateful resources to keep them persistent; one-shot data stays consumed. Model at the real atomic granularity — split only when the pieces could be accessed independently.\n\n## Targeted modeling\nOne concern per en session. For broad input, pick one subsystem in the user's own terms (a named module, a specific flow, a file) — not a tool or en concept. Model it, report findings plainly, then offer next areas in the same domain terms. Compose narrow models to build larger systems.\n\n## How to use them\nEach call's output — node names, structural properties, verdicts — feeds the next call. Read the output; pick the next tool by what was surprising or unverified, not by running through the list. Tool names are shorthand, not specs — read each description before calling; `compose` and `equivalent` are mode-based, not general analyzers. IMPORTANT: chain calls — keep going as long as something's worth following. Don't fire all six on the same `en` either.\n\nSpeak in the user's domain, not in graph theory. Only call render when the user explicitly asks to visualize.",
  "tools": [
    {
      "name": "structure",
      "description": "What is this system? Returns shape (Pipeline, Fork-Join, DAG, Star, Cycle, Tree, Complete, etc.), stages with roles, bridge nodes, cycles, parallelism, critical path, dominator tree, min-cuts, subsystems, interface nodes, actors (who does what, workload entropy), locations (where work happens, boundary crossings). Levers: node=X returns per-node centrality (betweenness, closeness, eigenvector) for a specific node. detect_findings=true flags named structural risks — unguarded-sink (sinks reachable via only pipeline actions, no JOIN/HUB gating), single-cut-path (source-sink pairs with only one vertex-disjoint path), multi-cut-path (paths with redundant defense, min-cut > 1). See server instructions for EN language syntax.",
      "parameters": [
        {"name": "source", "type": "string", "description": "EN source code, or path to .en/.txt file", "required": true},
        {"name": "node", "type": "string", "description": "Node name. When provided, returns per-node centrality (betweenness, closeness, eigenvector) for this specific node instead of the overview.", "required": false},
        {"name": "detect_findings", "type": "string", "description": "Set to 'true' to flag named structural findings. Possible values: unguarded-sink, single-cut-path, multi-cut-path.", "required": false}
      ]
    },
    {
      "name": "invariant",
      "description": "What's always true — automatic findings and on-demand checks. Automatic outputs: conservationLaws (weighted entity sums constant across executions), sustainableCycles (T-invariants — action sequences returning to start state), depletableSets (entity groups whose simultaneous depletion is irreversible), behavioral.deficiency (0 means structure fully determines dynamics), behavioral.isReversible, behavioral.hasUniqueEquilibrium. On-demand via `rules`: encode domain-specific claims and verify them against the graph — this is how to check things the topology alone can't see (precedence, coverage, centrality bounds, resilience). See the rules parameter for supported sentence shapes.",
      "parameters": [
        {"name": "source", "type": "string", "description": "EN source code, or path to .en/.txt file", "required": true},
        {"name": "rules", "type": "string", "description": "Custom structural rules, one per line. Four supported sentence shapes (regex-matched): (1) `no bridge that is also hub` — flags nodes that are both a bridge and a hub. (2) `every path from X to Y passes through at least one of [A, B, C]` — encodes precedence/coverage; use to check `A must happen before Y produces Z` by rewriting as `every path from Z's input to Z passes through [A]`. (3) `no node with centrality above 0.5` — flags over-central nodes (replace 0.5 with any threshold). (4) `removing any single node disconnects at most N others` — connectivity robustness check. Unrecognized rules return satisfied:false with an explanation listing these shapes.", "required": false}
      ]
    },
    {
      "name": "live",
      "description": "Can it deadlock? Can entities overflow? isStructurallyLive means every siphon contains a trap — no structural deadlock possible. uncoveredSiphons are entity groups that can drain permanently, with the actors and locations affected. isStructurallyBounded means no entity can accumulate without limit. unboundedCycles are action sequences that could cause overflow. See the server instructions for EN language syntax.",
      "parameters": [
        {"name": "source", "type": "string", "description": "EN source code, or path to .en/.txt file", "required": true}
      ]
    },
    {
      "name": "reachable",
      "description": "Can X reach Y? Follows directed data flow first; falls back to undirected. `from` and `to` accept entity names or action names (resolved against the program). Path shows each step with actor and location. locationCrossings counts boundary transitions. defense_nodes checks if guards cover all paths; coverage.fullCoverage=false means unguarded routes exist. See the server instructions for EN language syntax.",
      "parameters": [
        {"name": "source", "type": "string", "description": "EN source code", "required": true},
        {"name": "from", "type": "string", "description": "Starting node name", "required": true},
        {"name": "to", "type": "string", "description": "Target node name", "required": true},
        {"name": "defense_nodes", "type": "string", "description": "Comma-separated guard nodes to check coverage", "required": false}
      ]
    },
    {
      "name": "equivalent",
      "description": "Are two systems the same, or what changes if I change this one? Compare mode (source_a + source_b): structural differences, edit distance, spectral equivalence. isCospectral=true means identical graph structure up to relabeling — topologically the same despite different names, actors, or locations. Evolve mode (source + patch): dry-run a change, shows diff plus new/lost bridge nodes. Patch has three directive types — plain EN statement adds an action; a line starting with `-` (and not containing `do:`) removes the named action; a statement whose action name matches an existing one replaces the original. See the server instructions for EN language syntax.",
      "parameters": [
        {"name": "source_a", "type": "string", "description": "EN source code or path to .en/.txt file for the first system", "required": false},
        {"name": "source_b", "type": "string", "description": "EN source code or path to .en/.txt file for the second system", "required": false},
        {"name": "source", "type": "string", "description": "EN source code for evolve mode", "required": false},
        {"name": "patch", "type": "string", "description": "EN patch for evolve mode. Three directive types: plain EN statement (`actor do: X needs: Y yields: Z at: W`) adds action X; a line starting with `-` (and not containing `do:`) removes the named action; a new statement with an existing action name replaces the original. Multiple directives allowed, one per line.", "required": false}
      ]
    },
    {
      "name": "compose",
      "description": "How do parts combine, or how does a part stand alone? Merge mode (source_a + source_b + links): declare which entities in A are the same as entities in B; the combined graph is wired via string-equality of shared names. Extract mode (source + subsystem): pull a named subsystem out as standalone EN with boundary inputs/outputs, actors, and locations. Valid subsystem names come from structure's `subsystems` field — call structure on the source first to discover them. See the server instructions for EN language syntax.",
      "parameters": [
        {"name": "source_a", "type": "string", "description": "EN source code or path to .en/.txt file for the first system", "required": false},
        {"name": "source_b", "type": "string", "description": "EN source code or path to .en/.txt file for the second system", "required": false},
        {"name": "links", "type": "string", "description": "Entity identifications, one per line. Format: `a.<entity name>=b.<entity name>` (A's entity is the same as B's entity). `#` starts a comment. Example: `a.user session=b.authenticated session`.", "required": false},
        {"name": "source", "type": "string", "description": "EN source code for extract mode", "required": false},
        {"name": "subsystem", "type": "string", "description": "Subsystem name to extract. Valid names come from structure's `subsystems` field — call structure on the source first to discover them.", "required": false}
      ]
    },
    {
      "name": "render",
      "description": "SVG or PNG diagram. Only call when user explicitly asks to visualize. The rendered image is delivered to the user, not injected into the model's context. See the server instructions for EN language syntax.",
      "parameters": [
        {"name": "source", "type": "string", "description": "EN source code, or path to .en/.txt file", "required": true},
        {"name": "theme", "type": "string", "description": "Color theme. Curated presets (each with light + dark variants; pair with `isDark`): `Editorial` (stone paper + rust focal, adapted from cathrynlavery/diagram-design), `Primer` (GitHub design system — blue accent, data-vis roles), `Carbon` (IBM Carbon — sharp 0px corners, corporate blue). Or seed-derived palettes generated on the fly from `color`. Pass 'dark'/'light' for the default variant. Overridden by `color` if provided.", "required": false},
        {"name": "isDark", "type": "string", "description": "true or false. Selects the dark or light variant of a named preset. If omitted, defaults to dark unless theme=light.", "required": false},
        {"name": "type", "type": "string", "description": "Output format: png (default) or svg. PNG is rasterized server-side via Batik.", "required": false},
        {"name": "quality", "type": "string", "description": "Output quality: small, mid, or max", "required": false},
        {"name": "view", "type": "string", "description": "Group by: actors (partition by actor) or locations (partition by location). Default auto-detects topology.", "required": false},
        {"name": "structure_layers", "type": "string", "description": "Bitmask for structure overlays. Bits: 1=subsystems, 2=pipelines, 4=cycles, 8=forks, 16=joins, 32=hubs, 64=deadlock, 128=overflow. Default 255 (all on). Pass 0 to hide all.", "required": false},
        {"name": "color", "type": "string", "description": "Seed color hex (#RRGGBB) to generate a custom theme. Overrides theme parameter. One color generates the entire palette.", "required": false},
        {"name": "direction", "type": "string", "description": "Layout direction: LR (left-to-right) or TB (top-to-bottom). Default auto-detects from condensation DAG aspect ratio.", "required": false},
        {"name": "output", "type": "string", "description": "File path to save the rendered image", "required": false}
      ]
    }
  ]
}
