Diagram
A native Triform canvas for sketching processes and architectures, backed by portable Mermaid text — draw BPMN flows or UML in the workbench, keep the source diffable, and tag nodes with the same Name, Intention, and Requirements your real elements carry so a diagram becomes a plan you can build from.
Working with it
Opening a Diagram launches a diagram canvas — its dedicated working surface.
How it appears
The same element type rendered as a definition, a circle instance, and a live workspace card.
When to use / not
When to use
- Mapping a process before you build it — a BPMN flowchart of the steps, gateways, and outcomes that later become an app or automation.
- Sketching a system as a UML sequence, class, state, ER, or architecture diagram, with Mermaid as the portable, version-controllable source.
- Capturing planning intent on the canvas — Name, Intention, Readme, and verbal Requirements on each node — so the diagram can seed a template or materialization later.
- Referencing real workspace elements inside a sketch via element_ref, so a node renders with the live element's identity instead of a plain shape.
When not to use
- Actually running the steps you drew — a diagram stores planning state and exposes no operations; build an app or automation to execute the flow.
- Wiring data between elements — diagram is not wirable; use real action and data elements connected by wires for live dataflow.
- Tracking work items or a project board — a planning-board is the tool for status and assignment, not a diagram canvas.
Topology
Created from the library and placed inside an app or circle. It is a top-level building block you compose with other elements.
Properties
export_formatstring- Preferred export format. v1 supports Mermaid text only.
Operations
- activityGET
- attachmentsGET
- batch_statsGET
- composePOST
- contextGET
- createPOST
- deleteDELETE
- disablePOST
- enablePOST
- export_bundleGET
- getGET
- import_bundlePOST
- intentionGET
- promotePOST
- readmeGET
- readme_updatePOST
- remove-modifierPOST
- restorePOST
- schemaGET
- sourceGET
- source_branchesGET
- source_promotePOST
- source_repairPOST
- source_statusGET
- source_validatePOST
- statsGET
- treeGET
- updatePATCH
- update_metaPATCH
- versionGET
Composition
Errors / when it fails
- Diagram Mermaid source must be a non-empty string of at most 100000 characters
- Fails unless:
diagram.mermaid == null || (len(diagram.mermaid) >= 1 and len(diagram.mermaid) <= 100000)
Diagram (diagram)
Category: diagrams | Form: | Symbol: Dg
Mermaid-backed visual planning surface for BPMN-style and UML diagrams
Diagram is a Mermaid-centered planning element. Mermaid text is the canonical portable source, while the workbench renders and edits it as a native Triform canvas. BPMN mode stores process diagrams as Mermaid flowcharts with BPMN-style shape hints; UML modes use Mermaid sequence, class, state, ER, requirement, and architecture syntax. Diagram nodes can carry the same Name, Intention, Readme, and verbal Requirements used by real elements so the diagram can later become a template or materialization input without creating real elements in v1.
Guide
Mermaid-backed visual planning surface for BPMN-style and UML diagrams
What It Does
Diagram is a Mermaid-centered planning element. Mermaid text is the canonical, portable source, while the workbench renders and edits it as a native Triform canvas. BPMN mode stores process diagrams as Mermaid flowcharts with BPMN-style shape hints; UML modes use Mermaid sequence, class, state, ER, requirement, and architecture syntax.
Diagram nodes can carry the same Name, Intention, Readme, and verbal Requirements used by real elements, so a diagram can later become a template or materialization input without creating real elements in v1. A node MAY also carry an optional element_ref pointing at a real workspace element (for example, dropped from the library) — when present, the node renders with the referenced element’s identity (icon, color, slug) instead of its plain BPMN shape.
This is a data element (has_data: true, llm_role: data): it stores diagram state rather than executing on invocation. It is not wirable (wirable: false) and exposes no runtime operations. Its open mode is workbench, routed through the generated diagram-workbench shell role to the workbench-diagram-canvas.
Element Definition
| Property | Value |
|---|---|
| Type | diagram |
| Category | diagrams |
| Form | atom |
| Symbol | Dg / #0EA5E9 |
| Icon | account_tree |
| Open mode | workbench |
| Shell role | diagram-workbench |
States
| State | Initial | Transitions to |
|---|---|---|
provisioned | yes | active |
active | — | provisioned |
error | — | provisioned |
Properties
DiagramProperties — Mermaid source and Triform-side visual metadata. No fields are required.
| Field | Type | Default | Description |
|---|---|---|---|
diagram | object | (BPMN starter flowchart) | Canonical diagram data — see sub-fields below |
diagram.version | integer | 1 | Diagram schema version |
diagram.kind | string (enum) | bpmn | Mermaid family / BPMN profile: flowchart, bpmn, sequence, class, state, er, requirement, architecture |
diagram.mermaid | string | — | Canonical Mermaid source for import/export and agent editing |
diagram.layout | object | — | Triform-only canvas positions, shape hints, and node planning metadata (Mermaid does not preserve these) |
diagram.layout.nodes[] | array | — | Diagram nodes; each holds positional + planning metadata and an optional element_ref |
diagram.layout.nodes[].element_ref | object | absent | Optional pointer to a real workspace element: circle_slug, element_slug, element_type |
export_format | string (enum) | mermaid | Preferred export format. v1 supports Mermaid text only (mermaid) |
Capabilities
| Capability | Description |
|---|---|
mermaid-source | Stores Mermaid text as the canonical import/export and agent-editable diagram source |
bpmn-profile | Maps BPMN-style process shapes onto Mermaid flowchart nodes and edges |
uml-profiles | Supports Mermaid-backed UML-oriented modes such as sequence, class, state, ER, and requirement diagrams |
planning-metadata | Stores Name, Intention, Readme, and structured verbal Requirements on visual nodes without creating real elements |
Attachable Modifiers
The diagram element accepts these attached modifiers (contract.attaches):
| Modifier | Purpose |
|---|---|
auth-policy | Access control over the element |
rate-limit | Request rate limiting |
variable | Attached variable values |
Observability
| Event | Description | Attributes |
|---|---|---|
diagram.updated | Diagram Mermaid source or layout metadata changed | diagram.kind, diagram.node_count, diagram.edge_count |
Operations
This element defines no operations (ops.yaml → operations: {}). It is a data/planning element, not wirable, and exposes no ops/* runtime endpoints. Diagrams are created and edited through standard element CRUD and the diagram workbench.
Quick Start
Creating via API
Element URLs are flat: /api/{circle}/{slug}/.... Create a diagram by POSTing to the project create endpoint. Omitting spec yields the default BPMN starter flowchart (Start → New task → Done).
POST /api/{circle}/{project}/
Content-Type: application/json
{
"element_type": "diagram",
"slug": "my-diagram",
"name": "My Diagram",
"spec": {
"diagram": {
"version": 1,
"kind": "bpmn",
"mermaid": "flowchart LR\n start((Start)) --> task[New task]\n task --> done((Done))"
},
"export_format": "mermaid"
}
}
Editing
Update the Mermaid source (and/or layout) via standard element update, or edit visually in the diagram workbench (open mode workbench). kind selects the Mermaid family/profile; switch it to author a UML mode (e.g. sequence, class, state, er, requirement, architecture).
Common Mistakes
Empty or oversized Mermaid source.
When diagram.mermaid is set, the mermaid_length validation rule requires a non-empty string of at most 100000 characters. (null is allowed; an empty string or one over 100000 characters is rejected.)
Expecting non-Mermaid export.
export_format only accepts mermaid in v1 — Mermaid text is the sole portable export format.
Treating it as an executable element. Diagram has no operations and is not wirable. It stores planning state; it does not run on invoke or accept wired inputs.
Assuming a node is a real element.
Diagram nodes are plain Mermaid labels unless they carry an element_ref. A node with element_ref is a reference to an existing workspace element (rendered with its identity), not a newly created element — v1 does not materialize real elements from a diagram.
Relationships
- Attaches to: auth-policy, rate-limit, variable
Capabilities
- mermaid-source: Stores Mermaid text as the canonical import/export and agent-editable diagram source
- bpmn-profile: Maps BPMN-style process shapes onto Mermaid flowchart nodes and edges
- uml-profiles: Supports Mermaid-backed UML-oriented modes such as sequence, class, state, ER, and requirement diagrams
- planning-metadata: Stores Name, Intention, Readme, and structured verbal Requirements on visual nodes without creating real elements
Properties
| Property | Type | Default | Description |
|---|---|---|---|
diagram | object | {"kind":"bpmn","layout":{"edges":[{"bpmn_kind":"sequence_flow","id":"edge-start-task","label":"","source_node_id":"start","target_node_id":"task"},{"bpmn_kind":"sequence_flow","id":"edge-task-done","label":"","source_node_id":"task","target_node_id":"done"}],"nodes":[{"bpmn_kind":"start_event","id":"start","intention":"","name":"Start","position":{"x":140,"y":160},"readme":"","requirements":{},"size":{"h":64,"w":92}},{"bpmn_kind":"task","id":"task","intention":"","name":"New task","position":{"x":330,"y":140},"readme":"","requirements":{},"size":{"h":88,"w":160}},{"bpmn_kind":"end_event","id":"done","intention":"","name":"Done","position":{"x":590,"y":160},"readme":"","requirements":{},"size":{"h":64,"w":92}}]},"mermaid":"flowchart LR\n start((Start)) --> task[New task]\n task --> done((Done))","version":1} | Canonical diagram data. kind declares the Mermaid family/profile, mermaid is the portable text source, and layout stores Triform-only visual placement and node metadata that Mermaid does not preserve. |
export_format | string | "mermaid" | Preferred export format. v1 supports Mermaid text only. |
Operations
activity
Get /ops/activity | Auth: Read
Get activity events for this element
Scope depends on element capabilities: individual elements query by element_id, project-form elements with activity-scope-members include member activities, circle-level elements with activity-scope-all query the entire circle. Gracefully returns empty list if activities table is missing (old circles).
attachments
Get /ops/attachments | Auth: Read
List all modifiers and resources attached to this element
Returns both modifiers (policy enforcement) and resources (data injection) with is_modifier flag to distinguish. Items in the generated MODIFIER_TYPES list are modifiers; everything else is a resource. Includes cascade_policy and version pin info.
batch_stats
Get /ops/batch_stats | Auth: Read
Get per-element statistics for all children of this element
Returns per-child stats plus an aggregate. Most meaningful on compound or manifest form elements (repositories, circles, projects); atoms have no children so the result is an empty children array with a zeroed aggregate. Uses efficient GROUP BY SQL. Weighted averages for eval scores.
compose
Post /ops/compose | Auth: Execute
Batch add and remove modifiers on this element in a single call
Declarative composition: add modifiers by ref path (slug or path@version) and remove by attachment ID, all in one atomic call on the target element. Each ‘add’ entry resolves the source element, validates topology, attaches with optional priority and cascade policy. Each ‘remove’ entry deletes the attachment row. Returns a summary of what was added and removed. Example: compose({ add: [{ref: “my-prompt”}, {ref: “rate-limit/api@v2”, priority: 50}], remove: [{attachment_id: “uuid”}] })
context
Get /ops/context | Auth: Read
Get connected elements (graph traversal)
Graph traversal showing all connected elements with their relationship type (contains, contained_by, references, referenced_by, attaches, etc.). Use ?depth=N to control traversal depth (default 1) and ?types=actor,data to filter by element types.
create
Post /ops/create | Auth: Write
Create child element
POST to the parent path — element_type goes in the request body, NOT the URL. Both element_type and slug are required and must be non-empty. Name is derived from slug if omitted. Writes to both Git and PostgreSQL. All elements are stored flat under the circle — no intermediate library wrapper rows.
delete
Delete /ops/delete | Auth: Admin
Delete element (soft delete)
Soft delete — sets state to ‘deleted’ but retains the record. Cannot delete elements that have children (has_no_bond precondition) or active runs. Requires admin auth and confirmation.
disable
Post /ops/disable | Auth: Admin
Disable element (hides and prevents use)
Idempotent — safe to call on already-disabled elements. Optionally pass a reason string. Disabled elements cannot be invoked or executed. Inverse of enable.
enable
Post /ops/enable | Auth: Admin
Enable element (makes usable and visible)
Idempotent — safe to call on already-enabled elements. Transitions element to ready/enabled state. Cannot enable deleted elements. Inverse of disable.
export_bundle
Get /ops/export/bundle | Auth: Read
Export element as downloadable git bundle
On non-root-namespace elements, returns a binary git bundle. On root-namespace (circle) elements, dispatch hands off to the circle’s own export_bundle op, which returns a multi-element JSON envelope with one base64 bundle per child element — this is intentional, not an error.
get
Get /ops/get | Auth: Read
Get element details
Element is already resolved by the routing layer — this returns the cached element, not a fresh DB query. Use the path /api/{circle}/{slug} to address elements.
import_bundle
Post /ops/import/bundle | Auth: Write
Import git bundle into element
Accepts a base64-encoded git bundle in the JSON bundle_base64 field. Use overwrite=true to replace existing elements with same slug (default skips duplicates). Imported elements get new UUIDs. Returns counts of imported/skipped elements and any errors.
intention
Get /ops/intention | Auth: Read
Get element intention with full inheritance chain
Returns three levels: direct (this element’s intention), inherited (from category and root), and resolved (final merged intention). Useful for understanding an element’s purpose in context of its hierarchy.
promote
Post /ops/promote | Auth: Admin
Promote element configuration to a target environment
Only for manifest-form elements (projects). Environments advance: dev → demo → live. dev→demo requires member+ role, demo→live requires admin. Freezes member versions at promotion time (creates snapshot). Persists environment config to spec.environments.
readme
Get /ops/readme | Auth: Read
Get element README.md content
Reads README.md from the element’s git repository. Returns empty content (not an error) if no README exists. Always returns markdown format.
readme_update
Post /ops/readme_update | Auth: Write
Update element README.md content
Creates or overwrites README.md in the element’s git repo. Commits to the draft branch. Content must be provided as a markdown string.
remove-modifier
Post /ops/remove-modifier | Auth: Execute
Remove an attached modifier from this element by attachment ID
Removes a modifier/resource attachment by its row ID. The ID comes from the attachments or context API. This is the reverse of attach — called on the target element, not the source.
restore
Post /ops/restore | Auth: Admin
Restore element to a specific version
Automatically snapshots the current state before restoring (creates a ‘Before restore to vN’ version entry). Writes restored spec to git as .triform/spec.yaml. Git failures warn but don’t fail the operation — DB state is authoritative. Cannot restore deleted elements.
schema
Get /ops/schema | Auth: Read
Get element input/output schema (MCP tools/list compatible)
Returns type-level port schemas from the TypeRegistry — not instance-specific overrides. Includes direction (input/output), required flag, and JSON schema per port. Useful for understanding what data an element accepts and produces.
source
Get /ops/source | Auth: Read
Get any file’s content from the element’s git repository
Reads an arbitrary file from the element’s CAS-backed git tree by its relative path. Same store as
readme, just generalized. Path safety: rejects..traversal, leading/, and null bytes. Use this to viewmain.pyfor action elements, asset files for SPAs, etc. Returns empty content (not an error) if the file doesn’t exist.
source_branches
Get /ops/source/branches | Auth: Read
List Source branches for this element
Returns the standard draft/demo/live Source branches, their current commits, and promotion relationships. Use GET /api/{element_path}/ops/source/branches.
source_promote
Post /ops/source/promote | Auth: Write
Promote Source branch forward
Promotes draft to demo or demo to live through the generated element op path. Direct Git pushes to demo/live are blocked by Source policy.
source_repair
Post /ops/source/repair | Auth: Write
Inspect or repair the element Source index
Runs Source repair through the element operation path. Defaults to dry_run=true; set dry_run=false only after reviewing a dry-run report.
source_status
Get /ops/source/status | Auth: Read
Get Source control status for this element
Returns the branch-aware clone URL, checkout commands, current draft commit, child source-link count, portable export summary, Source health, warnings, and auth hints for the addressed element. Use the element-first path: GET /api/{element_path}/ops/source/status.
source_validate
Post /ops/source/validate | Auth: Read
Validate Source branch contents
Validates a Source branch before accepting local Git workflow changes or promotion. Defaults to branch=draft and rejects runtime data, generated output, secret material, and unreadable CAS refs.
stats
Get /ops/stats | Auth: Read
Get aggregate statistics for this element
Health status is computed: error if errors_per_day > 5 or success_rate < 0.8, warning if errors_per_day > 0 or success_rate < 0.95. Firing alerts escalate health to error/warning. Default period is ‘day’. Returns runs_per_day, success_rate, avg_duration_ms, and more.
tree
Get /ops/tree | Auth: Read
Get the element’s position in the graph — ancestors, children, references, and subtree statistics
Uses per-circle ElementGraph cache for O(1) lookups. Returns ancestors (containment chain), children (direct), members (references), referenced_by (reverse refs), attachments, and subtree stats. Default depth is 3, max is 10. Pass ?include_metadata=true for name/state on each node.
update
Patch /ops/update | Auth: Write
Update element
Partial update — send only the fields you want to change.
spec,name, andintentionare all independently optional.specMUST be a JSON object when present; deep-merged into the existing spec by default. Empty{"spec":{}}preserves existing spec content but still records a new version (no-op for content, not for version state). To clear/replace the entire spec wholesale send{"spec":{...},"deep":false}. List-typed spec fields use replace semantics (the patch list replaces the existing list, no array merging). Coordinates Git + DB writes. Slug cannot be changed after creation.
update_meta
Patch /ops/update_meta | Auth: Write
Update element metadata (lightweight merge — does NOT bump version or snapshot spec)
Shallow JSONB merge into element.meta. Top-level keys in the provided value replace existing meta values; other keys are preserved. Used for UI metadata like canvas positions, panel state, viewer preferences. Wire-shape op_name is
update_meta(distinct fromupdate) so SSE subscribers + the cache auto-invalidator can distinguish lightweight metadata changes from spec edits without inspecting the payload. The MutatingElementStore wrapper stamps this op_name on the lifecycle event emitted byupdate_element_metastorage calls.
version
Get /ops/version | Auth: Read
Get current version or full history
Returns current version by default. Pass ?history=true for full version history (up to ?limit=N, default 50). Versions are backed by the element_versions table. Every spec update creates a new version entry.
Observability
Defined for this element
Events
- diagram.updated
Pricing / cost
Platform default
Operation costs
- create: free
- update: free
- delete: free
- get: free
- list: free
- invoke: 10000 micro-AU
- tool_use: free