Skip to content

Command Layer

The command layer is a table of typed commands with undo, a journal, approvals and previews, served to programs through Caliper API.

Field Value
ID SPC-05
Status Shipped
Scope Core
Pillar Builder and Specs
Sprint None
Depends On None
Unblocks Caliper API v0 (AGT-01)
Builder Sessions (SPC-06)
Spec Version 1 with Scenes (SPC-11)
Rename Command (SPC-40)
Undo Across Restarts (SPC-41)
Docs HTTP API, GET /v0/commands
Branches None
Design Command layer

Coverage Ledger

  • Branch sprint3-commands, 0 commits that main lacks (34 ahead of the merge base). Work on the command layer and its worked test, which reached main through a pull request (patch ids and subjects match).
  • Branch sprint3-int-api, 0 commits that main lacks (96 ahead of the merge base). Work on the command endpoints of Caliper API, which reached main through a pull request (patch ids and subjects match).
  • Branch sprint3-int-review, 0 commits that main lacks (94 ahead of the merge base). Work on the review of spec edits, which reached main through a pull request (patch ids and subjects match).
  • Branch sprint3-session, 0 commits that main lacks (59 ahead of the merge base). Work on builder sessions and dry runs of spec edits, which reached main through a pull request (patch ids and subjects match).
  • Branch sprint3-int-fix-app, 0 commits that main lacks. Work on treating an approval reissued for changed content as no outcome, which reached main through a pull request (patch ids and subjects match).
  • Branch sprint3-int-fix-approvals, 2 commits, dbd859dd 6dee779a. An approval card for an undo or redo from an origin under review, added in dbd859dd and reverted in 6dee779a because history.undo and history.redo are refused to agents instead.
  • design/acp-integration.md, under Approvals and diffs for every agent. Approval of destructive commands from the agent, mcp and api origins, held for up to 120 seconds, with no self-approval.
  • design/acp-integration.md, under Approvals and diffs for every agent. Diff previews and review of spec edits in the command layer, with conflict handling, on by default for agent and mcp.
  • design/applet-builder.md, under Applet builder. Earlier proposal: an agent builds applets as data, a declarative panel spec drawn by one host runtime, edited through a command layer; compiled applets remain for panels that outgrow the spec.
  • design/applet-builder.md, under What stands in the way. Applets are compiled C++ and never unload; in-process code is trusted code; no command layer, catalog, capture; layout only by role.
  • design/applet-builder.md, under Proposed design. Architecture diagram: builder pane, agent loop, command layer, MCP, spec files, spec runtime and data services.
  • design/applet-builder.md, under Proposed design. The command layer, the spec, the spec runtime, the saved applet as manifest plus spec, and the browser.
  • design/applet-builder.md, under What would need to change. 1. A command layer in the host.
  • design/applet-builder.md, under What would need to change. 8. Limits: read-only SQL with row and time limits, the frame watchdog, scripts sandboxed, native generation outside the process.
  • design/applet-builder.md, under A first slice. Command layer and catalog, a spec runtime with four primitives (series, heatmap, scatter, table), bindings to data.v1 and live views, the capture service, all over MCP.
  • design/builder-overview.md, under The parts. Parts diagram and table: spec format, loaders, catalog, command layer, session, caliper-mcp, side chat, widget agent, caliper-agent.
  • design/builder-overview.md, under What is built. Command layer with registry, validator, undo groups, journal replay, approvals, queue and 40 commands.
  • design/builder-overview.md, under What is built. Review of spec edits for every agent: with review on, agent and mcp edits wait for approval with a diff and warnings.
  • design/builder-overview.md, under What is built. Stacked previews, applied to a copy of the spec and committed as one undo step.
  • design/builder-overview.md, under What is built. The API server serves the command endpoints through a CommandGateway with approvals held.
  • design/builder-overview.md, under The integration order after sprint 2. Item 1: the command endpoints of Caliper API, built.
  • design/builder-overview.md, under Decisions. Cross-cutting decisions: everything built is data; text is the source of truth; one command table; two roles; Claude native API and others through OpenAI-compatible API; local models; keys; nothing bundled; loopback only.
  • design/builder-pane.md, under Gestures and commands. Every gesture is a command from the builder origin, one group per gesture, one undo step, checked on a copy before sending.
  • design/builder-pane.md, under Gestures and commands. Renames, left placements and a new panel at an edge reuse spec.set_text and layout.set instead of new commands.
  • design/builder-session.md, under What is built and what is planned. Planned: the approval cards, so the person sees and decides what an agent's command waits for.
  • design/builder-session.md, under The commands it binds. The table of command groups the session binds: catalog, data, loader, spec, source, panel, layout, preview, applet, review and history.
  • design/builder-session.md, under Editing the open spec. Every spec edit goes through apply_spec_edit(), validated with a catalog-backed resolver, with dry_run, diff and no_effect handling.
  • design/builder-session.md, under Undo. Every edit returns a closure pair that checks the document and fails with history.conflict.
  • design/builder-session.md, under Stacked previews. The session keeps each preview as a refreshed copy of the open spec, with limits, expiry and preview.commit returning follow-ups.
  • design/builder-session.md, under Review of spec edits. The session's policy holds an edit of the open spec from a reviewed origin (agent and mcp by default) with a diff card and runs it only as it was shown.
  • design/builder-session.md, under Loaders, paths and approval. Loader commands record their undo, accept outside paths only from ui and builder or earlier grants, and ask before an agent runs a Python loader.
  • design/builder-session.md, under Applets. applet.save writes the spec and manifest atomically, applet.open and spec.open check paths, and applet.list lists spec applets.
  • design/builder-session.md, under The command table and the spec format. The command table's schemas accept exactly what the spec format accepts, and a conformance test keeps them in line.
  • design/builder-session.md, under Long commands and the registry's lock. While a loader runs on the worker the frame thread leaves the queue, registry and store alone, so later commands wait in order.
  • design/builder-session.md, under The acceptance tests. Two headless acceptance tests: an in-process build of the dashboard with undo, redo, save, reopen and replay, and a run over HTTP against the stand-in with approvals.
  • design/builder-session.md, under Limits. Preview edits are in memory only, so a restart drops them as it drops the undo history.
  • design/builder-session.md, under Limits. Undo and replay stop at the session: saved applets and loader tables stay, and replay rebuilds the open spec but not the loaders.
  • design/builder-session.md, under Limits. Every command waits while a loader runs on the worker, reads included, and history.redo of an import runs its loaders on the frame thread.
  • design/byok-agent.md, under Tools. Tools generated from the command descriptor table with reversible names, stripped schemas, up to 20 strict tools, and agent-disallowed commands left out.
  • design/catalog.md, under What is built and what is planned. LoaderCatalogProvider and the handlers of catalog.list, catalog.describe and catalog.sample in the session library.
  • design/catalog.md, under The commands. catalog.list, catalog.describe and catalog.sample, with their arguments, results and one sample shape for every kind.
  • design/command-layer.md, under What is built and what is planned. The library caliper_builder_commands: descriptors, invocations, results, the registry, the schema validator, undo history, journal, approval policy, follow-ups, queue and the descriptor table of every v0 command.
  • design/command-layer.md, under What is built and what is planned. The command endpoints of Caliper API served by the app through CommandGateway and the session gateway.
  • design/command-layer.md, under What is built and what is planned. Planned: handlers bound by the builder session, the app binding app.info, app.applets, app.launch, capture.frame and panel.render, the live catalog providers and setting the command gateway on the API server.
  • design/command-layer.md, under The command model. Every action on a workspace is a typed command with argument and result schemas.
  • design/command-layer.md, under Descriptors. A descriptor has name, summary, args and result schemas, examples and flags mutates, destructive, frame_thread, agents and effect.
  • design/command-layer.md, under The schema subset. The registry validates arguments with a small built-in JSON Schema subset, drops null optional arguments, and bounds its own work; table schemas are strict, closed and non-recursive.
  • design/command-layer.md, under Invocations. An invocation has id, name, args, origin (ui, builder, agent, mcp, api), group, merge_key, client and preview.
  • design/command-layer.md, under Results. A result is an ok envelope or an error with code, message and where; no handler throws across the registry.
  • design/command-layer.md, under Errors common to every command. The command.* codes the registry answers in a fixed order, such as invalid_args, not_allowed, needs_approval, denied and shutdown.
  • design/command-layer.md, under The commands of v0. The table of 40 commands with their mutates, destructive, frame-thread flags and undo behaviour.
  • design/command-layer.md, under app. app.info, app.applets and app.launch, bound by the running app.
  • design/command-layer.md, under catalog. catalog.list, catalog.describe and catalog.sample.
  • design/command-layer.md, under data. data.query runs one read-only SELECT and data.import imports files into loaders; outside paths only from ui and builder.
  • design/command-layer.md, under loader. loader.list, loader.describe, loader.create, loader.update, loader.run and loader.delete; running a Python script always asks every origin except ui and builder.
  • design/command-layer.md, under spec, source, panel and layout. Commands that edit the open spec (spec.*, source.*, panel.*, layout.*) with dry_run, a unified diff and validation after every edit, and a flat layout form for layout.set.
  • design/command-layer.md, under preview. Stacked previews: preview.begin, preview.diff, preview.commit and preview.discard, with bounds of 16 previews, 64 edits and a 30 minute idle drop; only ui and builder may commit.
  • design/command-layer.md, under review. review.status tells a caller which of its commands wait for the person.
  • design/command-layer.md, under applet, capture and history. applet.save, applet.open, applet.list, capture.frame, history.undo, history.redo and history.list.
  • design/command-layer.md, under Undo. One undo and one redo stack per workspace, held by the registry.
  • design/command-layer.md, under Steps and records. A step is one or more records (a closure pair, an inverse invocation or none); a handler can report no_effect so a dry run costs no redo.
  • design/command-layer.md, under Groups. Invocations with one group join the step on top of the undo stack, so an agent's proposal of several edits is one step.
  • design/command-layer.md, under Follow-ups. A handler may return follow-up invocations that run as one undo step; preview.commit uses them.
  • design/command-layer.md, under Merging. Consecutive invocations with the same merge key merge into one step, so a slider drag is one undo.
  • design/command-layer.md, under Redo. Redo moves a step back; any successful mutating command clears the redo stack except one that reports no effect.
  • design/command-layer.md, under Commands that cannot be undone. loader.run and applet.save record no step and are passed by, not barriers.
  • design/command-layer.md, under When the workspace changed underneath. Undo records check the state they replace and fail with history.conflict, history.undo_failed or history.inconsistent rather than overwrite a change they never saw.
  • design/command-layer.md, under Undo, redo and approval. Undo and redo are the person's tools: agents and mcp may not run them, and the history asks the approval policy about destructive commands in the step it would undo.
  • design/command-layer.md, under Bounds. Undo bounds of 200 steps, 64 MiB, 4096 merged commands and a 1000 ms merge window.
  • design/command-layer.md, under The journal. The journal is the append-only record of every mutating command.
  • design/command-layer.md, under Format. Journal lines in JSON Lines with seq, ts, origin, name, args, ok, group, event and allowed_by, with undo and redo events that name the seqs they reverse.
  • design/command-layer.md, under What is redacted. Strings over 64 KiB are replaced by a digest and secret-like keys are replaced, so no secret or large value reaches the journal.
  • design/command-layer.md, under Rotation and sequence numbers. The journal rotates at 16 MiB into commands.1.jsonl to commands.4.jsonl and continues its sequence numbers across reopening.
  • design/command-layer.md, under Reading and replay. The reader reports bad lines and gaps, and replay rebuilds the open spec from the events in effect without running undo records.
  • design/command-layer.md, under Approval. The approval policy allows, denies or asks; destructive commands from agent, mcp and api ask, and the session adds rules for Python runs, applet overwrites, replacing an unsaved spec and review of spec edits, with approvals bound to content.
  • design/command-layer.md, under Approval. Only the app's own UI calls approve and deny: no command or endpoint approves, sets a mode or adds a rule.
  • design/command-layer.md, under What each command does. The effect of every command, read, edit or change, is data in the table and decides what each mode allows.
  • design/command-layer.md, under Threads and the queue. CommandQueue accepts invocations from any thread, drains on one thread in order, holds approval waits and runs long commands on a worker while the frame thread leaves the queue alone.
  • design/command-layer.md, under Caliper API. GET /v0/commands, POST /v0/commands/{name} with origin, group and preview headers, approval holds of 120 seconds and GET /v0/approvals/{id}, plus how the server holds a request without a thread.
  • design/command-layer.md, under Changes to the contracts. Additions to the sprint 3 contracts: merge_key, error.approval, seqs on journal events, examples, minItems and maxItems, the flat layout and preview.
  • design/command-layer.md, under Decisions. Recorded decisions of the command layer: destructive means saved data, groups join only the top step, undo is the person's, approvals bound to content and origin by token.
  • design/command-layer.md, under Open items. An expectation on preview.commit, with the edit count and a digest, so the app refuses a preview that changed after its card was drawn.
  • design/command-layer.md, under Open items. A group should join only the open top step of the same origin, and the step of a commit should close after its follow-ups.
  • design/command-layer.md, under Open questions. Whether a later phase splits the registry's lock so short commands run on the frame thread while a loader runs.
  • design/gpu-programs.md, under Commands. Program and intervention commands use the command layer and the MCP tool table.
  • design/gpu-programs.md, under Program Commands. The commands program.create, program.patch and program.remove edit programs, and program.status reads their state.
  • design/gpu-programs.md, under Command Errors. Program commands answer with fixed error codes.
  • design/gpu-programs.md, under Edit Rules. Program edits support dry runs, review, undo, and journal entries.
  • design/hosted-runs.md, under Commands. Five run commands join the command layer and the MCP tool table.
  • design/hosted-runs.md, under Errors. The runner commands answer with fixed error codes.
  • design/instrument-interface.md, under Cursor Commands. The commands cursor.get, cursor.set and cursor.step read and move the cursor.
  • design/instrument-interface.md, under Commands. Eighteen commands for state, controls, selections, entities, annotations, the cursor and the camera join the command layer.
  • design/instrument-interface.md, under Command Errors. The new commands answer with fixed error codes.
  • design/instruments.md, under Commands. Eight new commands join the command layer and the MCP tool table.
  • design/instruments.md, under Control Commands. The commands control.create, control.patch and control.remove edit the controls of a spec.
  • design/instruments.md, under Run Commands. The run commands set parameters and drive the run of a script that streams to the app.
  • design/instruments.md, under Run Command Errors. The run commands answer with fixed error codes, such as command.not_implemented.
  • design/loaders.md, under Approval. LoaderStore::run refuses a Python loader without RunOptions::allow_python and the command layer sets it only after the person approved, so an agent's run of a script asks.
  • design/loaders.md, under The query helper. LoaderStore::query runs exactly one SELECT in a transaction that is always rolled back, with a row limit and a timeout; it backs data.query and catalog.sample.
  • design/loaders.md, under What is built and what is planned. Planned: the command handlers for the loader commands.
  • design/mcp-server.md, under From the command table to tools. One tool per agent-allowed command, derived at run time, with a reversible name, schemas, and read-only and destructive hints; history.undo and history.redo are left out.
  • design/roadmap.md, under Phase 3: agent-built panels. The parts: command layer, loaders, catalog, spec format with seven primitives, spec applet kind, caliper-mcp, side chat, widget agent.
  • design/roadmap.md, under Phase 3: agent-built panels. Status paragraph says the libraries are not yet wired into the app: command endpoints, spec runtime and applet kind, drag and drop, builder pane, side chat and widget inline surface.
  • design/roadmap.md, under API. The full API comes later with the command layer, so a program can drive the app's state from outside.
  • design/spec-format.md, under What is built and what is planned. The command handlers that edit a spec (spec.*, source.*, panel.*, layout.*) live in the builder session.
  • design/spec-format.md, under What is built of the browser viewer. The app resolves and the browser draws: the read-only panel.data command sends each panel's data compact and within the runtime's bounds, as JSON with base64 arrays.
  • design/spec-format.md, under The manifest of a spec applet. applet.save maps the workspace id to a manifest id local.<id> with _ replaced by -, writes name and summary from the spec and version 0.1.0.
  • design/widget-agent.md, under The tool scope. The tool scope is the subset of the command table, reads and previewable edits only, that the widget agent may use for one target, enforced by the sidecar and kept as data in widget_scopes.json.
  • design/widget-agent.md, under Preview and apply on the command layer. Stacked previews in the session: preview.begin, diff, commit and discard, edits that name a preview, and Accept, Reject and Refine mapped onto them.
  • HTTP API, GET /v0/commands. GET /v0/commands lists the command layer table.
  • HTTP API, POST /v0/commands/{name}. POST /v0/commands/{name} runs a command.
  • HTTP API, GET /v0/approvals/{id}. GET /v0/approvals/{id} reads an approval.
  • Builder Pane, Undo and Journal. Each gesture is one undo step and is journaled by the command layer.
  • Pieces, Piece Commands. The piece commands and the program commands as MCP tools.
  • Pieces, Piece Commands. Seven commands list, show, check, save, copy, update and remove pieces.
  • Pieces, Piece Commands. program.create and program.patch take instances, and program.read reads resources.
  • Pieces, Program Status and Events. Program status and events gain the draw half, the pass and the pick fields.
  • Pull request #17. Pull request 17 (merged) delivers sprint 3: the builder libraries, spec format, loaders, catalog, command layer and session, caliper-mcp, the side chat, the widget agent, command endpoints of Caliper API, the spec runtime and applets, the builder pane, drag and drop, approval cards and the first slice of the browser spec page.
  • Pull request #17. Review findings deferred in pull request 17: how Accept treats preview.commit, edge cases in the life cycle of the API the chat starts, approvals from the API that never expire, and a command joining another origin's undo step through its group.
  • Orchestrators' notes, sprint3-integration/PR.md. Libraries under src/builder: the spec format, validator and schema, loaders, the catalog, the command layer and the session.

Roadmap Graph Feature in Graph