Skip to content

Architecture Overview

Maelstrom turns a user's intent into a UI update. The client sends the current Chart state and update reasons to an Engine host. A configured Planner proposes changes, the Engine validates them, and the client applies the accepted response. Play the diagram to follow a request, or select a package to inspect its role.

A user intent starts a Chart update

A reason to update

Something changes on the browser side. The client batches update reasons before it asks the engine for anything.

  • user_intent
  • chart_resize
  • vessel_mutation
  1. A user intent starts a Chart update
  2. The client sends the Chart state in a ChartRequestMessage
  3. The Planner proposes changes; the Engine validates them
  4. The engine returns a MaelstromResponse
  5. The client applies the new layout (set_layout)
  6. The client runs the executionPlan (execute_actions)
  7. A ResizeObserver measures the Chart container
  8. Changed cell dimensions start a new chart_resize request

The round-trip, in words

It starts with a reason

Every update begins with an UpdateReason, and there are three: a user_intent (someone asks for something), a chart_resize (the available grid changed), or a vessel_mutation (an Instance changed its active Variant). @maelstrom-co/client batches the pending reasons and builds a ChartRequest. This snapshot contains Instance identities and Variants, the current layout, Chart dimensions in grid cells, registered Vessels, and the layout mode. A ChartRequestMessage carries it with a session ID, message ID, and timestamp.

The Planner proposes and the Engine validates

@maelstrom-co/engine holds no client layout state. It loads prior turns when history is configured and passes the request to a Planner. The reference LLM Planner builds prompts and calls a provider adapter; another Planner can use a different decision process. The Engine validates the candidate and repairs recoverable layout and Action problems.

The accepted MaelstromResponse contains a userMessage for the user, a rationale for diagnostics, an executionPlan, and a layout. Its requestId identifies the originating message.

The client applies it

The client queues set_layout and execute_actions as one ordered batch, with layout first. Other queued commands cannot interleave with that batch. Action failures or skips do not roll back the layout or completed Action effects. Retrying the whole batch can repeat effects from Actions that already ran.

A tiling response can introduce an Instance and request an Action on it in the same response. Applying the layout first establishes that Instance before the client waits for its Action runner. The runner must register before the readiness timeout; otherwise, the client skips the Action.

The loop closes

Applying the response updates the UI. The Chart's ResizeObserver watches its container. When the container's pixel size changes enough to change its whole-cell dimensions, the client sends a new chart_resize request. That starts a separate Engine turn. The client performs no inline size-reconciliation pass after Actions; the Chart clips visual overflow with CSS.

The vocabulary

Vessel
A registered UI definition with an ID, a description, and a set of Variants. The Planner uses these definitions to choose layouts and Actions. See the vessel state machine.
Variant
One discrete state of a Vessel, carrying its props, the Actions available in that Variant, and a minSize. The Engine checks this minimum against the request's Variant snapshot when validating grid positions. A local Action can switch to a larger Variant without resizing its allocation; the client schedules replanning.
Action
An operation the client runs on an Instance. It may move the Instance to another Variant via transitionsTo.
Chart
The container that displays Instances. Grid layouts use integer cells ( rows × columns). Tiling, the default, uses a tree of H/V splits. The client converts either layout to pixel bounds using the container dimensions.

protocol defines the shared contracts. client manages requests and applies responses; react binds it to React. engine coordinates planning and validation on the server, and planner-llm provides the reference LLM Planner.

Observe the workflow with DevTools

DevTools observes the existing workflow. Its core package owns the bounded collector, explicit content capture, and shared browser panel. The React adapter owns attachment and mounting. Engine evidence crosses through the protocol only when the server host authorizes forwarding for that connection. Select an evidence path below to see who owns each step.

Follow an evidence path

DevTools evidence paths

The collector observes the existing client workflow. Optional voice integrations contribute projected metadata through the same channel.

  1. Browser · applicationClient and optional voice

    Requests, layout application, Action outcomes, and connection changes produce observations.

  2. Browser · clientDiagnosticChannel

    The Orchestrator exposes metadata to attached observers. Supported content stays lazy.

  3. Browser · devtoolsBounded collector

    The core retains redacted evidence, grouped by app lifetime and request ID.

  4. Browser · shared panelInspect the workflow

    Requests, Inspector, and Connections show observed outcomes beside the JSON.

@maelstrom-co/react-devtools owns React lifecycle wiring: attach before Provider connection, then mount m.Devtools. @maelstrom-co/devtools owns the framework-independent collector, capture store, and shared panel.

Read all three evidence paths

Browser metadata

The collector observes the existing client workflow. Optional voice integrations contribute projected metadata through the same channel.

  1. Client and optional voice — Requests, layout application, Action outcomes, and connection changes produce observations.
  2. DiagnosticChannel — The Orchestrator exposes metadata to attached observers. Supported content stays lazy.
  3. Bounded collector — The core retains redacted evidence, grouped by app lifetime and request ID.
  4. Inspect the workflow — Requests, Inspector, and Connections show observed outcomes beside the JSON.

Engine evidence

Server stages appear only when the host authorizes forwarding for the connection. Production Engine forwarding stays disabled, including with browser tools enabled.

  1. createDiagnosticConnection — The host opts in and binds the authenticated session to this connection.
  2. Diagnostic frames — A compatible connector carries subscribed evidence for requests owned by this connection.
  3. Bounded collector — The core retains forwarded stages alongside local evidence. Missing stages remain unknown.
  4. Inspect server stages — Read planner and validation evidence when available. The Engine imports no browser DevTools package.

Recorded content

Start recording before reproduction to retain supported content. Inspection filters do not change the selected recording scope. Nothing uploads automatically.

  1. Choose scope and start — Choose an app lifetime or all app instances, then reproduce the problem.
  2. Supported content — The active capture requests lazy content. Earlier prompts and arguments cannot be recovered.
  3. Bounded capture store — Projection and redaction run before retention. Stop recording to inspect the evidence and add notes.
  4. Export and reopen — Inspect and redact before sharing. Imported evidence is read-only and never replays Actions.

The default production entrypoints are inert. Explicit /production imports enable browser tools in every build; production Engine forwarding stays disabled. Follow the DevTools guide for installation and recording.

Where to go next