flowrs-engine/spec/flowrs-document-1.schema.json
flowRS fd958c0547 flowRS engine, cut from flowRS 3451b065
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 19:04:39 -05:00

424 lines
12 KiB
JSON

{
"$comment": "flowRS document specification 1.0.0: https://flowrs.openie.dev/docs/document-format/",
"$defs": {
"app": {
"additionalProperties": false,
"description": "The app laid over the graph: OpenUI Lang source bound to the graph's ports by reference (`n7.mean`), and how it is drawn.",
"properties": {
"description": {
"type": "string"
},
"library": {
"description": "The component library it was written against (`\"flowrs-app@1\"`).",
"type": "string"
},
"panel": {
"$ref": "#/$defs/panel"
},
"prefer": {
"description": "The layouts a person picked, as `<rule>=<component>` (`R06=Scope`), in the order picked. One that names no rule, or a component its rule does not offer, is ignored.",
"items": {
"type": "string"
},
"type": "array"
},
"skin": {
"description": "Absent: instrument.",
"enum": [
"instrument",
"paper"
]
},
"source": {
"description": "The program; empty for the graph's inferred app.",
"type": "string"
},
"steps": {
"description": "Passes of the step loop when the app's program runs outside the editor; absent: the default.",
"maximum": 4294967295,
"minimum": 0,
"type": "integer"
},
"title": {
"type": "string"
},
"turns": {
"description": "The acceptance checks each accepted turn of the app's making left, in turn order. Each is run again after every later edit.",
"items": {
"$ref": "#/$defs/app_turn"
},
"type": "array"
},
"version": {
"description": "The OpenUI Lang version of `source` (`\"1.0\"`).",
"type": "string"
}
},
"required": [
"version"
],
"type": "object"
},
"app_turn": {
"additionalProperties": false,
"description": "One accepted turn of an app's making: what was asked, and the checks it left.",
"properties": {
"checks": {
"description": "Its checks in flowrs-app's check language (`shows n4.magnitude as spectrum`).",
"items": {
"type": "string"
},
"type": "array"
},
"request": {
"description": "The request, in the words it came in; absent for a person's own edit.",
"type": "string"
}
},
"type": "object"
},
"author": {
"description": "Who last wrote a handle: unknown, a person, an agent (its model and the conversation it came from), an import (the dialect that read it), or mixed.",
"oneOf": [
{
"additionalProperties": false,
"properties": {
"by": {
"const": "unknown"
}
},
"required": [
"by"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"by": {
"const": "human"
}
},
"required": [
"by"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"by": {
"const": "agent"
},
"conversation": {
"type": "string"
},
"model": {
"type": "string"
}
},
"required": [
"by",
"model",
"conversation"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"by": {
"const": "imported"
},
"dialect": {
"type": "string"
}
},
"required": [
"by",
"dialect"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"by": {
"const": "mixed"
}
},
"required": [
"by"
],
"type": "object"
}
]
},
"card": {
"additionalProperties": false,
"description": "Where one Front Panel card sits, in grid cells.",
"properties": {
"card": {
"description": "`ctl:<node id>` (a control), `ind:<node id>` (an Indicator) or `out:<node id>.<port>` (an output).",
"type": "string"
},
"col": {
"description": "The column of its top-left corner, from 0.",
"maximum": 4294967295,
"minimum": 0,
"type": "integer"
},
"row": {
"description": "The row of its top-left corner, from 0.",
"maximum": 4294967295,
"minimum": 0,
"type": "integer"
},
"tab": {
"description": "The tab it is on, as an index into `tabs`; absent: every tab.",
"maximum": 4294967295,
"minimum": 0,
"type": "integer"
}
},
"required": [
"card",
"col",
"row"
],
"type": "object"
},
"group": {
"additionalProperties": false,
"description": "A group: a collapsed subgraph. Nodes name it; it never changes what the graph computes.",
"properties": {
"id": {
"$ref": "#/$defs/id"
},
"name": {
"type": "string"
},
"parent": {
"description": "The enclosing group, by id; null at the top level.",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/id"
}
]
},
"position": {
"$ref": "#/$defs/position"
}
},
"required": [
"id",
"name"
],
"type": "object"
},
"id": {
"description": "An identifier, unique among the document's items of its kind: a u64, written as a JSON integer. Writers keep it at or below 2^53 - 1, which JavaScript reads exactly.",
"maximum": 18446744073709551615,
"minimum": 0,
"type": "integer"
},
"node": {
"additionalProperties": false,
"description": "A node: one instance of a node type, with its parameter values.",
"properties": {
"group": {
"description": "The group (collapsed subgraph) the node belongs to, by id; null at the top level. Organisational only.",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/id"
}
]
},
"id": {
"$ref": "#/$defs/id"
},
"origin": {
"$ref": "#/$defs/node_origin"
},
"position": {
"$ref": "#/$defs/position"
},
"properties": {
"additionalProperties": {
"type": "string"
},
"description": "Parameter and literal values by name, every value a string (`\"2\"` and `\"2.0\"` are different values). Keys in sorted order.",
"type": "object"
},
"type_id": {
"description": "The node type, by its id in flowRS's node library (`math.add`, `dsp.filter.iir`, `FloatLiteral`).",
"type": "string"
}
},
"required": [
"id",
"type_id",
"properties"
],
"type": "object"
},
"node_origin": {
"additionalProperties": false,
"description": "Who wrote the node, each of its parameters and each of its inputs. Not part of what the graph computes; written only when something is known.",
"properties": {
"inputs": {
"additionalProperties": {
"$ref": "#/$defs/author"
},
"type": "object"
},
"node": {
"$ref": "#/$defs/author"
},
"params": {
"additionalProperties": {
"$ref": "#/$defs/author"
},
"type": "object"
}
},
"type": "object"
},
"panel": {
"additionalProperties": false,
"description": "The Front Panel's layout: its tabs and its cards.",
"properties": {
"cards": {
"items": {
"$ref": "#/$defs/card"
},
"type": "array"
},
"tabs": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"position": {
"description": "Where the item sits on the canvas, (x, y). Layout only: what a graph computes never depends on it.",
"items": false,
"maxItems": 2,
"minItems": 2,
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
],
"type": "array"
},
"wire": {
"additionalProperties": false,
"description": "A wire from one node's output port to another's input port.",
"properties": {
"feedback": {
"description": "Held: the wire delivers what its source produced on the previous step (the zero of its type on the first). Written only when true.",
"type": "boolean"
},
"from_node": {
"$ref": "#/$defs/id"
},
"from_port": {
"type": "string"
},
"id": {
"$ref": "#/$defs/id"
},
"mode": {
"description": "How the value crosses the wire (ownership).",
"enum": [
"Move",
"Borrow",
"BorrowMut",
"Clone",
"Copy"
]
},
"origin": {
"$ref": "#/$defs/author"
},
"to_node": {
"$ref": "#/$defs/id"
},
"to_port": {
"type": "string"
}
},
"required": [
"id",
"from_node",
"from_port",
"to_node",
"to_port"
],
"type": "object"
}
},
"$id": "https://flowrs.openie.dev/schemas/flowrs-document-1.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"description": "A saved flowRS graph (a `.flowrs` file): its nodes, wires and groups, the interface fingerprints of the node types it uses, and the app laid over it. Arrays are sorted by id and object keys by name, so the same graph is always the same bytes.",
"properties": {
"app": {
"$ref": "#/$defs/app"
},
"format": {
"const": 1,
"description": "The document format. A reader refuses a format it does not know."
},
"generator": {
"description": "What wrote the file. Informational.",
"type": "string"
},
"groups": {
"items": {
"$ref": "#/$defs/group"
},
"type": "array"
},
"nodes": {
"items": {
"$ref": "#/$defs/node"
},
"type": "array"
},
"widgets": {
"additionalProperties": {
"pattern": "^[0-9a-f]{16}$",
"type": "string"
},
"description": "The interface fingerprint of each node type the graph uses, by type id: 16 lowercase hex digits (FNV-1a 64 over the type's ports and parameters). Lets a later reader say which node types changed.",
"type": "object"
},
"wires": {
"items": {
"$ref": "#/$defs/wire"
},
"type": "array"
}
},
"required": [
"format",
"nodes",
"wires"
],
"title": "flowRS document, format 1",
"type": "object"
}