Understand
Concepts
Hierarchical State Machines, scoped prompt slices, typed signals, ancestor bubbling, deterministic guards, append-only event sourcing, and AXI integration.
From passive prompts to reactive state machines
Traditional passive skills dump monolithic instructions into context. Agents attempt to remember prior turns and self-police progress without execution boundaries or verifiable checkpoints.
Reactive Skills structures execution as a formal Hierarchical State Machine (HSM). The agent receives an isolated prompt slice for the active state, evaluates deterministic guard expressions before transitions, and records all transitions to an append-only event ledger.
States & prompt isolation
Skills advance through named states such as PLAN, EXECUTE, and composite REFACTOR. Instead of loading the entire skill manual, agents receive only the prompt slice for the active state (states/*.md). This context isolation prevents attention drift and cuts token waste.
Signals and ancestor bubbling
Signals are typed payloads dispatched from the agent harness, AXI CLI, or MCP. If a leaf substate has no handler for an incoming signal, the event bubbles up the hierarchy to ancestor states. This eliminates boilerplate across substates for global policies like rollbacks, aborts, and timeouts.
Why bubbling matters
Cross-cutting policies — like rollbacks or global aborts — live on composite parent states instead of being duplicated into every child substate.
Deterministic guard gates
Guards evaluate context facts (e.g. exit_code == 0, schema checks, artifact existence) deterministically. The runtime prevents transitions on subjective model claims, ensuring reproducible execution and verifiable progress.
PLAN --[ guard: plan.approved ]--> EXECUTEDecoupled Judgment Engine & Snap-On Adapters
When deterministic boolean assertions are not enough (e.g. assessing semantic criteria like "Did the security scan identify zero critical CVEs?"), RSA provides a decoupled Judgment Engine adhering to SASH / Hexagonal Ports-and-Adapters principles.
The core runtime includes the TypeSafe SDK needed for semantic judgments, but only makes network calls when TYPESAFE_API_KEY is configured. Transitions declare domain-level semantic contracts (predicate, categorical, or evaluation) which the runtime delegates to registered Judgment Adapters:
- ScriptJudgmentAdapter: Built-in default (<1ms) providing deterministic sandboxed heuristic evaluation with zero configuration.
- JevJudgmentAdapter: Direct integration with TypeSafe AI's System One decision model through @typesafe-ai/sdk. It requires TYPESAFE_API_KEY, does not invoke jev-axi, and preserves Script fallback behavior when unavailable.
- Circuit Breaker & Outages: Resilient evaluation wraps external calls in a circuit breaker. When a configured model adapter times out, fails, or trips, a criterion written as a JavaScript expression is still evaluated by the built-in script adapter. A natural-language criterion cannot be judged that way, so the signal is refused with a refusal_reason and the run stays in its current state. A judgment that rejects a result routes to its declared fallback_target (e.g. BLOCKED or MANUAL_REVIEW) and audits GUARD_FALLBACK_TRIGGERED into the event ledger.
# skill.yaml transition contract
transitions:
SECURITY_CLEAN:
target: "SPEC_ALIGNMENT"
judgment:
type: "predicate"
criterion: "Did the security scan confirm zero leaked API keys and no high-severity vulnerabilities?"
min_probability: 0.85
escalate:
min_probability: 0.3
target: "MANUAL_REVIEW"
fallback_target: "BLOCKED"min_probability is compared directly with P(yes) for predicates and with the picked label's probability for categorical judgments. The older min_confidence field is unchanged: for predicates it measures distance from 0.5 as |P(yes) - 0.5| * 2, so min_confidence: m requires P(yes) >= 0.5 + m / 2. Skills that use min_probability or escalate should require the judgment.probability_thresholds runtime capability.
Semantic Model Capability Tiers
Not every state requires a flagship frontier model. RSA enables per-state cognitive tier declarations in skill.yaml so orchestrators and agents can dynamically allocate model budgets:
- fast: Low latency, low cost for structured triage, lint parsing, and state setup (e.g. Claude Haiku, Gemini Flash).
- balanced: Standard coding, refactoring, and deterministic implementations (e.g. Claude Sonnet, GPT-4o).
- reasoning: Deep architectural decisions, invariant proofs, and root-cause analysis (e.g. Claude Opus, OpenAI o3, Gemini Pro).
- decision: Specialized micro-decision models trained for sub-second classification (e.g. TypeSafe Jev).
When an agent enters a state, the runtime injects a structured <model_contract> tag into the prompt slice, declaring the required tier, suggested models, and cost bounds.
Event sourcing and projections
Every signal dispatch, guard evaluation, and state transition appends to an immutable ledger (.reactive/skills/<skill>/events.jsonl + SQLite). Current state, history, and workspace deliverables are computed read-model projections folded from the event ledger.
| eventType | state | source | traceId | timestamp |
|---|---|---|---|---|
| SkillStarted | EXPLORE | runtime | trc_7f3a9c | 09:14:02.113 |
| SignalReceived | EXPLORE | mcp | trc_7f3a9c | 09:14:02.480 |
| GuardEvaluated | PLAN | runtime | trc_7f3a9c | 09:14:03.902 |
| StateEntered | EXECUTE | runtime | trc_7f3a9c | 09:14:05.219 |
| DeliverableWritten | VERIFY | runtime | trc_7f3a9c | 09:14:08.744 |
| SkillCompleted | DONE | runtime | trc_7f3a9c | 09:14:09.101 |
Isolated skill storage
Each skill maintains dedicated state and event storage. Skill executions never cross-contaminate. SQLite provides ACID durability and indexed replay, while JSONL logs ensure human-readable auditability.
Parent runs summarize child failures
Skills can invoke child skills hierarchically. When a child skill encounters a guard rejection or unhandled signal, the parent run folds the child’s events into a structured summary and surfaces the exact recovery action inline.
Agent interfaces: AXI & MCP
Reactive skills expose two host interfaces. During INIT, the runtime checks local capabilities and versions, selects a compatible AXI or MCP transport, and persists that choice for the run.
Local-first interface selection
Use the selected transport for the full run. AXI provides direct shell execution and compact, line-oriented TOON output, while MCP provides host-integrated tools. npx launches AXI without changing the selected runtime interface.
Mods
Skills define the workflow. Mods are separate: small Claude Code plugins that change what you can see and do while a skill runs, such as a status line or a live state-machine pane. They read the same event ledger and statechart the runtime writes, and they never change a run. See the Mods page.
Interactive State Machine Simulator
Simulate state transitions, ancestor signal bubbling, guard evaluations, and event stream persistence directly in the browser.