RISE Framework Specification
Spec ID: 63
Version: 1.2
Document ID: caishen-rise-smvd-v1.2
Last Updated: 2026-02-24
Source: Replaces defunct StateForge.com online designer; informed by StateBuilderGui patterns
Implementation: smcraft/web/ — Next.js 16 + React 19 + Tailwind + Zustand | MCP Server: smcraft/mcp/
What the Visual Designer Enables Users to Create:
Desired Outcomes:
The smcraft-mcp server enables LLM agents to design state machines conversationally:
| Tool | Purpose |
|——|———|
| create_state_machine | Create a new definition with namespace/name |
| add_state | Add a state (with parent, kind, description) |
| add_event | Add an event to the definition |
| add_transition | Wire a transition between states |
| remove_state | Remove a state from the tree |
| validate_definition | Run all validation rules (V001–V008+) |
| generate_code | Generate Python or TypeScript code |
| get_definition | Export current definition as JSON |
| load_definition | Import a definition from JSON |
| list_states | Show state tree with transitions |
| list_events | Show all defined events |
smcraft://definition — Live state machine definition (JSON)design-state-machine — Guided step-by-step design conversation┌────────────────────────────────────────────────────────────┐
│ Visual Designer Application │
│ Stack: Next.js 16 + React 19 + Tailwind + Zustand │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Canvas Layer (SVG) │ │
│ │ ┌──────────┐ ┌──────────────┐ ┌───────────────┐ │ │
│ │ │ State │ │ Transition │ │ Draw Mode │ │ │
│ │ │ Nodes │ │ Arrows │ │ (click→pick) │ │ │
│ │ └──────────┘ └──────────────┘ └───────────────┘ │ │
│ │ Context Menu │ Event Labels │ Error Indicators │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ┌────────────────────────▼────────────────────────────┐ │
│ │ Zustand Store (useDesignerStore) │ │
│ │ StateMachineDefinition ←→ DesignerLayout │ │
│ │ Undo/Redo (snapshot stack, MAX_UNDO=50) │ │
│ │ Draw mode │ Selection │ Context menu │ Validation │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ┌────────────────────────▼────────────────────────────┐ │
│ │ Tabbed Right Sidebar │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐ │ │
│ │ │Properties│ │ Events │ │ Settings │ │Errors │ │ │
│ │ │+Actions │ │ Table │ │ Panel │ │(click) │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └────────┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ┌────────────────────────▼────────────────────────────┐ │
│ │ Toolbar │ │
│ │ Undo/Redo │ Draw Mode │ Open/Save │ Validate/Gen │ │
│ └──────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────┘
The primary workspace where users visually create and edit state machines.
| Layout: Full-height flex layout with Toolbar (top), Canvas (center-left), tabbed right sidebar (Properties | Events | Settings | Errors) |
Behavior:
.smdf.json fileCanvas.tsx)The main SVG workspace where states and transitions are rendered.
Behavior:
Styling:
#0f172a fill, #475569 stroke, blue on selection, amber on draw-source#94a3b8 stroke with arrow markers, blue when selected#1e293b background in bordered boxesPropertiesPanel.tsx)Behavior:
code (textarea for code), timerStart/timerStop (name input)EventsPanel.tsx)Behavior:
on_eventname(context, param: type)SettingsPanel.tsx)Behavior:
name: type, one per line)ValidationPanel.tsx)Behavior:
Validation Rules (Implemented): | Rule | Description | |——|————-| | V001 | No events defined | | V002 | Duplicate state name | | V003 | Transition references unknown event / Duplicate event ID | | V004 | Transition targets unknown state | | V005 | Root must have at least one child state | | V007 | Final state must not have outgoing transitions | | V008 | Final state must not have child states |
Toolbar.tsx)Behavior:
CodePreview.tsx)Behavior:
DesignerState:
definition: StateMachineDefinition (Spec 60 model)
layout: DesignerLayout
positions: Record<string, StatePosition>
StatePosition: { x, y, width, height }
fileName: string | null
dirty: boolean
selection: { kind: "state"|"transition"|"event"|null, id: string|null }
drawMode: "select" | "transition"
drawSource: string | null
contextMenu: { visible, x, y, target: {kind, id?} | null }
undoStack: HistoryEntry[] (max 50)
redoStack: HistoryEntry[]
errors: ValidationError[]
showCodePreview: boolean
generatedCode: string | null
Before every mutation, _pushHistory() deep-clones current {definition, layout} onto undoStack. Redo swaps current ↔ redoStack top. redoStack clears on any new mutation (standard behavior). Maximum 50 undo levels.
addState(parentPath, state) — Add child state to parent (auto-layout applied)updateState(name, patch) — Partial update (name, kind, description, onEntry, onExit)removeState(name) — Remove from tree + layout positionsnestState(childName, newParentName) — Move state into another as childaddEventSource(source) / updateEventSource(index, patch) / removeEventSource(index)addEvent(evt, sourceIndex?) / updateEvent(id, patch) / removeEvent(id)addParameter(eventId, param) / updateParameter(eventId, index, patch) / removeParameter(eventId, index)addAction(stateName, hook, action) — Add action to onEntry or onExitremoveAction(stateName, hook, index) — Remove action by indexupdateAction(stateName, hook, index, action) — Replace action at indexaddTransition(stateName, trans) / updateTransition(stateName, index, patch) / removeTransition(stateName, index)Desired Outcome: A trader designs a BDBO strategy state machine visually Current Reality: State machines are defined by editing raw JSON files Natural Progression:
strategy.CanRetry()Desired Outcome: Load an existing JSON definition and refine it visually Current Reality: Editing complex nested JSON is error-prone Natural Progression:
bdbo_strategy.smdf.jsonDesired Outcome: An AI agent creates a state machine through conversation Natural Progression:
create_state_machine with namespace and nameadd_event for each domain eventadd_state for each state in the workflowadd_transition to wire events to state transitionsvalidate_definition to check for structural errorsgenerate_code with target language
Resolution: Conversational state machine design without visual tool| Component | Technology |
|---|---|
| Framework | Next.js 16 + React 19 + TypeScript |
| Canvas | SVG-based with React components |
| State Management | Zustand (single store with undo/redo) |
| Layout | Auto-layout with hierarchical child positioning |
| Styling | Tailwind CSS, dark theme |
| File I/O | Browser FileReader API + Blob download |
| Export | Direct JSON serialization from model |
| MCP Server | @modelcontextprotocol/sdk + StdioServerTransport |
The designer saves definitions as .smdf.json files:
{
"stateMachine": {
"settings": { "namespace": "...", "name": "...", "asynchronous": false },
"events": [{ "name": "Internal", "events": [...] }],
"state": { "name": "Root", "states": [...] }
}
}
Visual layout data (positions) is managed in-memory by the Zustand store and regenerated via auto-layout on file load.