Trait Machines of Loving Grace
Autonomous systems are getting more capable and less legible. Machine learning models can perceive, classify, and optimize, but as capability grows, interpretability shrinks. In safety-critical environments, systems act faster than humans can understand why. Trait Machines address this by making autonomous behavior explicitly readable, auditable, and constrainable without discarding machine learning.
The Core Idea
A Trait Machine is a constrained state machine with five elements: states (situations the system can be in), events (things that happen), transitions (how state changes), guards (conditions that must be true), and effects (what the system does). State machines are decades old. The difference is how .orb composes and exposes them for autonomous systems.
Safety as a Trait
Safety is not a separate layer bolted onto the system. It is expressed in the same language as capability. Here is an obstacle detection trait for a patrol robot:
{
"name": "ObstacleStop",
"linkedEntity": "Robot",
"stateMachine": {
"states": [
{ "name": "patrolling", "isInitial": true },
{ "name": "stopped" }
],
"transitions": [
{
"from": "patrolling", "to": "stopped",
"event": "OBSTACLE_DETECTED",
"guard": ["<", "@payload.distance", 0.5],
"effects": [
["set", "@entity.motors", "off"],
["emit", "STOPPED", { "reason": "obstacle too close" }]
]
},
{
"from": "stopped", "to": "patrolling",
"event": "CLEAR",
"effects": [["set", "@entity.motors", "on"]]
}
]
}
}
Two states, two transitions, one guard. If an obstacle is closer than 0.5 meters, motors turn off. The trait is intentionally small. Small systems are readable. Readable systems are debuggable. Debuggable systems are trustworthy.
Flat Composition
An inspection robot composes multiple traits at the entity level:
{
"entity": {
"name": "InspectionRobot",
"persistence": "runtime",
"fields": [
{ "name": "position", "type": "object" },
{ "name": "motors", "type": "string", "default": "on" },
{ "name": "scanResult", "type": "string" },
{ "name": "zone", "type": "string" }
]
},
"traits": [
{ "name": "Movement", "linkedEntity": "InspectionRobot" },
{ "name": "ObstacleStop", "linkedEntity": "InspectionRobot" },
{ "name": "Scanning", "linkedEntity": "InspectionRobot" },
{ "name": "ZoneEnforcement", "linkedEntity": "InspectionRobot" }
]
}
Composition is flat. You can inspect the robot's full behavioral surface by reading the trait list. No execution trees to trace.
Constraining Machine Learning
Trait Machines do not replace ML. They constrain it. A learned navigation model proposes paths, but the trait guard validates them before execution:
{
"from": "idle", "to": "navigating",
"event": "NAVIGATE_TO",
"guard": ["and",
["=", "@payload.isCollisionFree", true],
["=", "@payload.speedWithinLimit", true],
["=", "@payload.avoidsRestricted", true]
],
"effects": [
["set", "@entity.currentPath", "@payload.proposedPath"]
]
}
If the guard fails, the system stays in idle and emits PATH_REJECTED. The model learns. The boundaries remain explicit. Guard rejections become structured training data: PATH_REJECTED: restricted zone violation. Learning becomes search inside safety, not across it.
Runtime Legibility
Every decision produces a structured trace:
14:03:22 State: patrolling
14:03:22 Event: OBSTACLE_DETECTED { distance: 0.3m, type: "person" }
14:03:22 Guard: (< @payload.distance 0.5) -> TRUE
14:03:22 Transition: patrolling --> stopped
14:03:22 Effect: (set motors "off")
14:03:22 Effect: (emit STOPPED { reason: "person detected at 0.3m" })
Every decision is reconstructable as logic, not inference. Safety reviewers, domain experts, and regulators can read exactly why a system acted the way it did, while it runs, not after forensic analysis.
Compile-Time Validation
orbital validate detects unreachable states, unhandled events, invalid bindings, deadlocks, and cross-trait communication gaps at compile time, shifting failures from runtime to build time. Guards are deterministic, bounded-cost, and independent of global system size, enabling static worst-case timing certification.
The Practical Claim
Trait Machines do not solve alignment, replace ML, or remove human specification risk. They provide a behavioral specification and constraint layer where the specification is the system: the same artifact defines behavior, validates composition, and generates runtime execution logic.
Systems that act in human environments should be understandable by humans while they act. Not eventually. Not after analysis. While they run.