Developer Guide
Schemas & Validation

Schemas & Validation

JSON Schema is the contract layer between agents, tools, and the orchestrator agent. Every artifact crossing an agent boundary must validate.

Validation tool

python3 tool_scripts/common.py \
  --schema schemas/<name>.schema.json \
  --data <path/to/artifact.json>

Implementation: jsonschema library. Prints OK (exit 0) or error list (exit 1).

Writing a new schema

Template

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "<name>",
  "description": "What this artifact represents and who consumes it.",
  "type": "object",
  "additionalProperties": false,
  "required": ["field1", "field2"],
  "properties": {
    "field1": {
      "type": "string",
      "description": "What this field means in the pipeline."
    }
  }
}

Conventions

RuleWhy
additionalProperties: false on every objectCatch typos and hallucinated fields
Explicit required arraysFail fast on missing data
Rich description on every fieldAgents read schema descriptions for semantics
Embed formulas in descriptionsassembly.schema.json includes the transform chain
Use enum for fixed setsjoint_type
minItems/maxItems: 3 for vectorsEnforce [x,y,z] arrays

Array of objects pattern

"parts": {
  "type": "array",
  "minItems": 1,
  "items": {
    "type": "object",
    "additionalProperties": false,
    "required": ["name", "description"],
    "properties": { ... }
  }
}

Recursive definitions

Use $defs for nested structures (see parts.schema.json):

"$defs": {
  "part_hint": {
    "type": "object",
    "properties": {
      "children": {
        "type": "array",
        "items": { "$ref": "#/$defs/part_hint" }
      }
    }
  }
}

Integrating validation into subagents

Every subagent prompt ends with:

## After writing
Validate:
python3 tool_scripts/common.py --schema schemas/<name>.schema.json --data <path>
Fix any errors before finishing.

The orchestrator agent also validates after subagent writes and re-invokes on failure.

Integrating validation into the orchestrator agent

In orchestrator.md, after each subagent step:

Validate: python3 tool_scripts/common.py --schema schemas/<name>.schema.json --data <path>
Re-invoke with errors appended, up to loop.max_validation_retries times.

For orchestrator agent-written artifacts (render_views.json):

Validate render_views.json before rendering.

Testing schemas

Valid fixture

Create a minimal valid example and validate:

python3 tool_scripts/common.py \
  --schema schemas/parts.schema.json \
  --data test_fixtures/valid_parts.json

Invalid fixture

Test that missing required fields are caught:

# Should exit 1 with error messages
python3 tool_scripts/common.py \
  --schema schemas/parts.schema.json \
  --data test_fixtures/invalid_parts_missing_world_center.json

Against real run artifacts

python3 tool_scripts/common.py \
  --schema schemas/assembly.schema.json \
  --data .intermediate/dishwasher/001/iterations/006/assembly.json

Modifying an existing schema

Breaking changes (adding required fields, removing fields, changing types) require:

  1. Update the schema
  2. Update the agent prompt that produces the artifact
  3. Update any agent/script that consumes the artifact
  4. Update orchestrator agent skip logic if needed
  5. Re-run or migrate existing .intermediate/ artifacts

Non-breaking changes (adding optional fields, improving descriptions) are safe.

Schema ↔ IR mapping

SchemaIR nameProducer
parts.schema.jsonParts IRanalyze subagent
assembly.schema.jsonLayout IRinitialize_placement.py / update_placement.py
critic.schema.jsonCritique IRcritic subagent
render_views.schema.jsonRender planorchestrator agent
component_dims.schema.jsonComponent dimsblender_measure_glbs.py

Common validation errors

ErrorCauseFix
'field' is a required propertyAgent omitted a fieldRe-invoke agent or add field manually
Additional properties are not allowedExtra/hallucinated fieldRemove the unknown field
is not of type 'number'String where number expectedFix type in JSON
is too short[x, y] instead of [x, y, z]Add missing axis