Architecture
KaimonSlate is layered. The source of truth is a plain .jl file; everything else is built around keeping a reactive in-memory model, a browser view, and an evaluation kernel in sync with it.
Source of truth: the .jl file
A notebook is a .jl file with #%% cell headers, in five kinds: #%% code, #%% md, #%% web (a three-pane HTML/CSS/JS cell that evaluates like code, see Front-end Extensions), #%% tool (an agent tool call, which evaluates and joins the DAG like code) and #%% job (work that lands over time, such as a sweep; see Clusters). The server parses it into a Report of Cells. Every in-app mutation persists back to the file, and a file-watcher pulls in external edits (VS Code, the agent writing directly, git). Because the file is canonical, the browser, your editor, and the agent never drift.
ReportEngine — reactivity
ReportEngine parses cells, analyzes each cell's reads and writes, and builds a dependency DAG. eval_stale! recomputes only the cells marked stale, in topological order. Editing a cell marks it and its transitive dependents stale; changing a bound widget restales the readers of that variable. Async cells can call slate_refresh(:x) to restale readers of x and push a live update. See Reactive Cells.
Kernels — where cells evaluate
| Kernel | When | Notes |
|---|---|---|
InProcessKernel | Kaimon's gate is not available (for example slate --own) | Cells eval in the server process. No separate log; no package management. |
GateKernel | Kaimon's gate is available | Each notebook gets its own worker process: clean namespace, tailable log, package management, isolation. |
The discriminator is the gate, not the project. A notebook with no enclosing project still gets a worker; it just gets its own environment along with it.
@bind and the other cell helpers behave the same on both kernels.
A notebook is not limited to one worker. Cells tagged region= run on their own worker, one per region, which may be on another machine over SSH. See Regions and Remotes.
NotebookServer — the hub
One HTTP server hosts many notebooks. Routes are notebook-scoped (/n/<id> for the SPA, /api/<id>/… for JSON, /api/<id>/events for the SSE stream). The browser holds a long-lived EventSource; structural changes bump a version and trigger a full re-render, while value-only updates patch outputs in place (preserving editor state and scroll).
Each page also keeps one WebSocket, /api/<id>/ws. It carries calls from the page's JavaScript into Julia (slateCall) and every slate_emit value back, in order and none dropped, which SSE does not promise. A hub-wide stream, /api/facts/events, keeps every page's view of workers, regions and allocations current.
Each notebook's code runs in a worker process of its own, and each region it uses has another. The hub reaches a worker over three channels: requests, a stream of output and events, and a data channel for large values. Requests and the data channel are encrypted with CURVE, on this machine as well as remote ones.
ReportRender — output
output_html renders a code cell's captured value, stdout, errors, and rich display chunks (images as base64, HTML, LaTeX). markdown_html renders markdown cells with GFM tables, KaTeX math, and double-brace interpolation. Interactive ECharts and tables are hydrated client-side from per-cell specs. The same rendering powers HTML/PDF export.
The AI agent
When running under Kaimon, the agent is a consumer of the same surface: it drives the notebook through the slate.* tools (which call the agent cell ops), and its event stream is relayed onto the notebook's SSE so the chat pane updates live. A build-floor + version-CAS layer lets several agents drive one notebook safely. See The AI Agent.