{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "BehaviorConfig",
"description": "Root configuration for a behavior composition.\n\nThis is the top-level structure for defining behavior trees in JSON.\n\n# Example JSON\n\n```json { \"$schema\": \"https://mecha10.dev/schemas/behavior-composition-v1.json\", \"name\": \"patrol_mission\", \"description\": \"Patrol behavior with safety layer\", \"root\": { \"type\": \"sequence\", \"children\": [ { \"type\": \"node\", \"node\": \"safety_check\", \"config_ref\": \"safety\" }, { \"type\": \"selector\", \"children\": [ { \"type\": \"node\", \"node\": \"detect_obstacles\", \"config_ref\": \"detector\" }, { \"type\": \"node\", \"node\": \"wander\", \"config_ref\": \"wander\" } ] } ] }, \"configs\": { \"safety\": { \"max_speed\": 1.0 }, \"detector\": { \"confidence\": 0.7 }, \"wander\": { \"speed\": 0.5 } } } ```",
"type": "object",
"required": ["name", "root"],
"properties": {
"$schema": {
"description": "Schema reference for validation and IntelliSense",
"type": ["string", "null"]
},
"configs": {
"description": "Configuration values referenced by nodes",
"type": "object",
"additionalProperties": true
},
"description": {
"description": "Optional description",
"type": ["string", "null"]
},
"name": {
"description": "Name of this behavior composition",
"type": "string"
},
"root": {
"description": "Root composition node",
"allOf": [
{
"$ref": "#/definitions/CompositionConfig"
}
]
}
},
"definitions": {
"CompositionConfig": {
"description": "Configuration for a composition node (sequence, selector, parallel, or leaf).",
"oneOf": [
{
"description": "A sequence node - executes children in order",
"type": "object",
"required": ["children", "type"],
"properties": {
"children": {
"description": "Child nodes to execute in sequence",
"type": "array",
"items": {
"$ref": "#/definitions/CompositionConfig"
}
},
"name": {
"description": "Optional name for this sequence",
"type": ["string", "null"]
},
"type": {
"type": "string",
"enum": ["sequence"]
}
}
},
{
"description": "A selector node - tries children until one succeeds",
"type": "object",
"required": ["children", "type"],
"properties": {
"children": {
"description": "Child nodes to try in order",
"type": "array",
"items": {
"$ref": "#/definitions/CompositionConfig"
}
},
"name": {
"description": "Optional name for this selector",
"type": ["string", "null"]
},
"type": {
"type": "string",
"enum": ["selector"]
}
}
},
{
"description": "A parallel node - executes all children concurrently",
"type": "object",
"required": ["children", "type"],
"properties": {
"children": {
"description": "Child nodes to execute in parallel",
"type": "array",
"items": {
"$ref": "#/definitions/CompositionConfig"
}
},
"name": {
"description": "Optional name for this parallel node",
"type": ["string", "null"]
},
"policy": {
"description": "Policy for success/failure",
"default": "require_all",
"allOf": [
{
"$ref": "#/definitions/ParallelPolicyConfig"
}
]
},
"type": {
"type": "string",
"enum": ["parallel"]
}
}
},
{
"description": "A reference to a Rust behavior node",
"type": "object",
"required": ["node", "type"],
"properties": {
"config": {
"description": "Inline configuration (alternative to config_ref)"
},
"config_ref": {
"description": "Reference to configuration in the configs map",
"type": ["string", "null"]
},
"name": {
"description": "Optional name for this node",
"type": ["string", "null"]
},
"node": {
"description": "Name of the behavior node type",
"type": "string"
},
"type": {
"type": "string",
"enum": ["node"]
}
}
}
]
},
"ParallelPolicyConfig": {
"description": "Policy configuration for parallel nodes.",
"oneOf": [
{
"description": "All children must succeed",
"type": "string",
"enum": ["require_all"]
},
{
"description": "At least one child must succeed",
"type": "string",
"enum": ["require_one"]
},
{
"description": "At least N children must succeed",
"type": "object",
"required": ["require_n"],
"properties": {
"require_n": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
},
"additionalProperties": false
}
]
}
}
}