clawft

Block Descriptor Schema

JSON Schema reference for the WeftOS Block Descriptor format with field descriptions and examples

Block Descriptor Schema

A Block Descriptor is a self-contained JSON document defining a renderable UI assembly. One descriptor can render to React (Tauri desktop), Terminal (Ink/xterm.js), Mentra HUD (400x240 constraint), PDF, MCP, and Shell targets.

Schema version: 0.2.0 JSON Schema draft: 2020-12 Schema ID: https://weftos.weavelogic.dev/schemas/block-descriptor/0.2.0

Root Document

The top-level object has three required fields and one optional field.

FieldTypeRequiredDescription
versionstringYesSchema version for forward compatibility. Must be "0.2.0".
rootstringYesID of the root element in the elements map. Must be a key in elements.
elementsobjectYesFlat adjacency-list map of element ID to element definition. At least one entry required.
metaBlockMetaNoOptional metadata for catalog display, governance, and rendering hints.

Minimal Example

{
  "version": "0.2.0",
  "root": "cpu",
  "elements": {
    "cpu": {
      "type": "Metric",
      "props": { "label": "CPU", "value": 42, "unit": "%" }
    }
  }
}

BlockMeta

Optional metadata attached to the descriptor.

FieldTypeRequiredDescription
creatorstringNoWho created this descriptor. Convention: "user:<name>" or "agent:<agent_id>".
created_atstring (date-time)NoISO 8601 creation timestamp.
titlestringNoHuman-readable title for catalog display.
tagsstring[]NoTags for catalog search and filtering.
governance_seqinteger (>= 0)NoExoChain sequence number of the governance approval event for this descriptor.
target_hintenumNoPreferred render target. One of: "react", "terminal", "mentra-hud", "pdf", "mcp", "shell", "voice". Renderers may ignore this hint.
refresh_hznumber (0.1 -- 60)NoSuggested refresh rate for $state bindings, in Hertz.

Example with Meta

{
  "version": "0.2.0",
  "root": "status-card",
  "meta": {
    "creator": "agent:weaver-0",
    "created_at": "2026-03-27T10:00:00Z",
    "title": "System Status",
    "tags": ["status", "dashboard"],
    "target_hint": "mentra-hud",
    "refresh_hz": 2
  },
  "elements": {
    "status-card": {
      "type": "Metric",
      "props": { "label": "Health", "value": { "$state": "/kernel/health/overall" }, "unit": "%" }
    }
  }
}

BlockElement

Each entry in the elements map defines one block.

FieldTypeRequiredDescription
typestring (enum)YesBlock type name. Must exist in the Block Catalog.
childrenstring[]NoOrdered list of child element IDs. Only layout blocks (Column, Row, Grid, Tabs) may have children.
propsobjectNoProps specific to this block type. Values may be literals or $state references.
onobjectNoEvent handlers. Keys are event names (e.g., "press", "voice_select", "change"). Values are actions.
portsobjectNoData port bindings for inter-block communication.
layoutLayoutHintsNoLayout hints for the block engine.

Valid Block Types

Layout: Column, Row, Grid, Tabs

Data Display: Metric, DataTable, ChainViewer, CausalGraph, DiffViewer, CodeEditor

Interactive: Button, ConsolePan, ApprovalGate, TextInput, Markdown

OS Capability: WebBrowser, ResourceTree, ServiceMap

HUD-specific: StatusBar, RadialTopology, HintBar, ProgressBar


State References

State references bind block props to live kernel state. They are resolved at render time via the StateStore.

StateRef

A simple reference to a kernel state path.

FieldTypeRequiredDescription
$statestringYesJSON Pointer path into the StateStore (e.g., "/kernel/metrics/cpu_percent"). Must start with /.
$defaultPropValueNoFallback value if the path is not yet available in the StateStore.
$transformstringNoTransform function name applied to the resolved value (e.g., "percent", "humanBytes", "truncate").
{
  "value": {
    "$state": "/kernel/metrics/cpu_percent",
    "$default": 0,
    "$transform": "percent"
  }
}

FormatStateRef

A state reference with a format template string. The resolved value is interpolated into the template at {v}.

FieldTypeRequiredDescription
$statestringYesJSON Pointer path into the StateStore.
formatstringYesTemplate string where {v} is replaced by the resolved value.
{
  "left": {
    "$state": "/kernel/processes/active_count",
    "format": "AGENTS: {v} total"
  }
}

PropValue

A prop value can be any of the following:

  • Literal: string, number, boolean, null
  • Array: an array of PropValues
  • StateRef: a { "$state": "/path" } object
  • FormatStateRef: a { "$state": "/path", "format": "..." } object
  • Plain object: any object that does not contain $state at the top level, with nested PropValues

BlockAction

Actions are triggered by block events and routed through the Action Catalog.

FieldTypeRequiredDescription
actionstring (enum)YesAction type. One of: "kernel_exec", "governance_check", "chain_query", "ecc_search", "agent_chat", "navigate", "open_block", "close_block".
paramsobjectNoStatic parameters merged with event data at dispatch time. Values can be PropValues.
governedbooleanNoWhether to require a governance check before executing. Default: true.

Example

{
  "on": {
    "press": {
      "action": "kernel_exec",
      "params": { "command": "process.spawn coder" },
      "governed": true
    }
  }
}

PortBinding

Ports enable inter-block communication via the PortBus.

FieldTypeRequiredDescription
direction"in" or "out"Yes"in" receives data from another block's output port. "out" emits data for other blocks to consume.
data_typestringYesData type hint for validation (e.g., "number", "string", "ProcessEntry", "ChainEvent").
sourceobjectNoFor "in" ports: identifies the source element and port name. Contains element (string) and port (string).
publishstringNoFor "out" ports: $state path where data is published to the StateStore.

Example: Wiring Two Blocks

{
  "elements": {
    "table": {
      "type": "DataTable",
      "props": { "columns": [{"key": "pid", "label": "PID"}], "rows": { "$state": "/kernel/processes" } },
      "ports": {
        "selectedRow": { "direction": "out", "data_type": "ProcessEntry", "publish": "/ui/selected_process" }
      }
    },
    "detail": {
      "type": "Markdown",
      "props": { "content": { "$state": "/ui/selected_process" } },
      "ports": {
        "input": { "direction": "in", "data_type": "ProcessEntry", "source": { "element": "table", "port": "selectedRow" } }
      }
    }
  }
}

LayoutHints

Layout hints tell the block engine how to size and position a block. Interpreted differently by each renderer.

FieldTypeRequiredDescription
widthinteger (1--12)NoWidth in grid units (12-column grid system).
heightinteger (>= 1)NoHeight in grid units.
xnumberNoAbsolute X position in canvas mode (pixels).
ynumberNoAbsolute Y position in canvas mode (pixels).
minWidthinteger (>= 1)NoMinimum width in grid units.
minHeightinteger (>= 1)NoMinimum height in grid units.
resizablebooleanNoWhether the user can resize this block. Default: true.

Complete Example

A dashboard with metrics and a chain viewer:

{
  "version": "0.2.0",
  "root": "dashboard",
  "meta": {
    "title": "Kernel Dashboard",
    "creator": "agent:weaver-0",
    "tags": ["dashboard", "monitoring"],
    "refresh_hz": 2
  },
  "elements": {
    "dashboard": {
      "type": "Column",
      "props": { "gap": 12 },
      "children": ["metrics-row", "chain-view"]
    },
    "metrics-row": {
      "type": "Row",
      "props": { "gap": 16 },
      "children": ["cpu", "mem", "chain-height"]
    },
    "cpu": {
      "type": "Metric",
      "props": {
        "label": "CPU",
        "value": { "$state": "/kernel/metrics/cpu_percent" },
        "unit": "%",
        "threshold": { "warn": 70, "crit": 90 }
      },
      "layout": { "width": 4 }
    },
    "mem": {
      "type": "Metric",
      "props": {
        "label": "Memory",
        "value": { "$state": "/kernel/metrics/mem_percent" },
        "unit": "%",
        "threshold": { "warn": 80, "crit": 95 }
      },
      "layout": { "width": 4 }
    },
    "chain-height": {
      "type": "Metric",
      "props": {
        "label": "Chain",
        "value": { "$state": "/kernel/chain/height" },
        "unit": "events"
      },
      "layout": { "width": 4 }
    },
    "chain-view": {
      "type": "ChainViewer",
      "props": { "limit": 20 },
      "layout": { "width": 12, "height": 6 }
    }
  }
}

On this page