The shared IR
IR stands for intermediate representation: the dashboard spec the model writes and everything else reads. It sits between the natural-language prompt and the rendered dashboard, the way a compiler’s IR sits between source and machine code, and it is the one format every layer agrees on.
A panel is one object in the shared Zod IR (src/lib/ir.ts). Its entire
contract:
Panel = { id: string, // unique within the dashboard title: string, description?: string, // intent only, populated for ad-hoc exploration viz: VizType, // see Reference → Visualization types query?: // absent exactly for a kind that runs none (text) | { sourceId: string, // opaque reference into the source registry sql: string, // UNTRUSTED SELECT — validated before it ever runs timeField?: string, // the column the SERVER filters time on } | { sourceId: string, promql: string, // UNTRUSTED PromQL, for a Prometheus source instant?: boolean, // one sample per series instead of a range minStep?: Duration, // a floor on the step the SERVER picks ("15s") } | { sourceId: string, logql: string, // UNTRUSTED LogQL, for a Loki source instant?: boolean, // one answer at the window's end instead of a range minStep?: Duration, // a floor on a metric query's step }, options?: object, // the kind's own; see Reference → Panel options format?: "number" | "bytes" | "percent" | "ms", timeRange?: { from, to }, // the panel's own window, in place of the dashboard's refreshIntervalMs?: number, // the panel's own cadence, same bounds as the dashboard's links?: PanelLink[], // up to 5, where a click leads; see Links below layout: { x, y, w, h }, // position on a 12-column grid}A Dashboard wraps its specVersion, a title, a timeRange, a
refreshIntervalMs, 1–50 panels, up to 10 optional variables
(Dashboard variables) and an optional annotations
setting (Annotations), with a refinement rejecting
duplicate panel ids and variable names. A panel may carry a
timeRange and a refreshIntervalMs of its own
(#114): a “today so far”
stat over 24 hours next to a five-minute error chart. Its window wins over both
the dashboard’s and the one a viewer picks, and the viewer shows a badge on it.
The server resolves either window the same way and holds either cadence to
MIN_REFRESH_INTERVAL_MS. A text panel takes neither. The full list of
viz and format values is in
Visualization types, generated from the enum
itself.
Three properties carry the whole security model
Section titled “Three properties carry the whole security model”sourceId is opaque. No host, port, database, or credential ever lives in a
panel. The source registry (src/lib/registry.ts) owns the safe connection
config, the table and column allowlist (the catalog), and a secret_ref that
resolves credentials from the environment at execution time.
sql is untrusted even though the model wrote it. It is re-validated on
every save and on every execution — never trusted because “we generated it.”
There is no time filter in the query. The model is explicitly forbidden from
filtering time. timeField merely names the column; the server injects
the from/to bounds. Time authority never leaves the server.
A query’s language follows its source
Section titled “A query’s language follows its source”A panel’s query is SQL, PromQL or LogQL, decided by which of sql, promql
and logql it carries (#383,
#560). Every shape is strict
and has a field the others lack, so every spec saved before PromQL or LogQL
existed parses exactly as it did, with no specVersion bump, and a query
carrying two is refused.
Which language a panel may use is not the panel’s choice. It is a property of its source’s kind (Source kinds): a TimescaleDB or DuckDB source answers SQL, a Prometheus source answers PromQL, a Loki source answers LogQL, and a query in another language is refused on save and at execution like a table the source does not have.
A PromQL query carries no time either. The server picks start, end and
step for the window it resolved, and minStep can only raise the step. A
range query’s rows always carry their time in a column called time. An
instant query has one sample per series and no time column, so a kind that
needs time, such as a state timeline, needs a range query.
A LogQL query is the same shape under its own field, and carries no time and no
limit: the server picks start, end, step, limit and direction. A range
query’s rows carry time whether they are log lines or metric samples, which
is what lets a log query feed the logs panel; how many lines that panel asks
for is its options.limit, never the query’s.
Code never reads a query’s fields to decide what it is. It asks the helpers
beside hasQuery in src/lib/ir.ts: isSqlQuery, queryLanguage,
queryTimeField (the declared column for SQL, time for a PromQL or LogQL
range query, nothing for an instant one) and queryText (the statement, for
display, digests and diffs). A query variable has two shapes: a SELECT, or
{ sourceId, label, match? }, the values of a label, which a Prometheus source
answers and a Loki source does too.
One definition, no drift
Section titled “One definition, no drift”The same Panel schema is the model’s output type, the API’s validation type,
the persisted type, and the client’s render type:
export const DashboardGenerationSchema = z .object({ ...DashboardFields, // the Dashboard's own fields, minus specVersion panels: z.array(GeneratedPanel).min(1).max(50), }) .strict() .superRefine(dashboardRules); // unique ids, self links set declared variablesThere are two differences. The first is specVersion: which shape a spec is in
is a fact about the build, so fromGenerated stamps it rather than letting the
model assert it.
The second is how a panel is spelled for the model
(#335). Panel keeps
query optional because a text panel has none, and says which kinds need one
in a refinement. JSON Schema cannot carry a refinement, so a model reading the
schema it was bound to saw query as optional, and one model left it off every
panel. GeneratedPanel says the same thing in its shape instead: a union on
viz, in which a kind that runs a query requires query and a query-less kind
has none. ExplorePanel (the MCP generate_panel tool) and Explore’s ChatPanel offer only the first, without links. Both shapes are
Panels, held to the same refinement, so everything after generation is
unchanged. Because generation is bound to the same fields the client renders, a spec that
would not render is a spec the model could not have emitted. This is why
changing dashboard structure means changing the Zod schema first and updating
every producer and consumer together — parallel ad-hoc types would reintroduce
exactly the drift this design removes.
The viz values follow the same rule from the other end. They are not written
out in ir.ts: VizType is built from the panel registry
(src/lib/panels/registry.ts), which also builds the prompt’s list of kinds and
is the key to the client’s renderers. See
Panel kinds.
A panel may declare links
(#371): where it leads when
a viewer investigates further. A link targets another dashboard in the same
workspace by its id, or, with no id, the dashboard it is on. It is never a
URL, so there is nothing in a spec a model could point outside the app.
"links": [ { "title": "Host detail", "dashboard": "9b2c41d0", "carry": { "timeRange": true, "variables": true }, "set": { "host": { "column": "host" } } }]carrysays whether the viewer’s window and variable picks go along. Each istruewhen absent.setmakes picks on arrival, by variable name. A value is a literal ({ "value": "api" }), the clicked row’s value in a result column ({ "column": "host" }), the clicked series’ name ({ "series": true }), or one label of the clicked series or log line ({ "label": "instance" }).- A panel takes at most 5 links, a link sets at most 10 variables, and a text panel takes none.
- A link to the same dashboard must set at least one variable, and only ones the dashboard declares. A link to another dashboard is not checked against that dashboard’s variables: the target ignores a name it does not declare.
A link carries time expressions and picks, never SQL. The target page
resolves the window on the server and checks every pick against its own
variable, exactly as it does for a hand-typed var-* URL. isDatumLink and
isSelfLink in src/lib/ir.ts are the two derived facts every consumer
reads, so none re-derives them.
Time expressions
Section titled “Time expressions”TimeExpr accepts a relative form (now, now-15m, now-1h, now-24h,
now-7d) or an ISO-8601 absolute timestamp. The IR only ever carries the
expression; resolveTimeRange (src/lib/time.ts) turns it into concrete
Date bounds server-side, and rejects a range whose from is not before its
to.
Strictness
Section titled “Strictness”Every object in the IR is .strict(), so an unknown key is a validation error
rather than a silently ignored field. That is what makes a stored spec safe to
parse years later, and it is also why the IR carries an explicit
specVersion and an upgrader chain (src/lib/ir/upgrade.ts,
#58): a breaking change bumps
SPEC_VERSION and appends an upgrader, and anything that reads a stored spec
reads it through StoredDashboard. See
invariant 3.
Leaving and entering the app
Section titled “Leaving and entering the app”A spec is a self-contained document, so getting one out of the app is an
envelope around it rather than a serializer
(src/lib/dashboard-export.ts):
{ "format": "holotable.dashboard", "formatVersion": 1, "exportedAt": "2026-09-22T12:00:00.000Z", "manifest": { "title": "…", "panelCount": 7, "dashboardVersion": 3, "sourceIds": ["…"] }, "spec": { "…": "the Dashboard IR, verbatim" }}formatVersion versions the envelope, not the IR — it is the reader’s signal
to refuse a file it would otherwise misread. The spec inside carries its own
specVersion and is read through StoredDashboard, so a file exported by an
older build is upgraded on import like any stored spec.
The manifest is informational: an import makes every decision from spec, so a
doctored manifest changes nothing. What an import cannot decide for itself is
what the source ids mean. They are opaque registry references, which is what
keeps the file free of hosts and credentials in the first place, and it is also
why the same file means different things in different deployments — so
POST /api/dashboards/import re-points them through an explicit mapping
supplied by the importer and refuses the whole import, naming the ids, when any
of them is still not a live source in the target workspace. Guessing by name or
by catalog shape would point a panel at the wrong database and report
plausible-looking numbers instead of an error.
Keeping one, and applying it again
Section titled “Keeping one, and applying it again”A template is the same document kept for reuse (src/lib/templates.ts). Its
body is a Panel or a Dashboard out of this IR, tagged with which, and
nothing else — so “IR-validated on write and on instantiation” is a property of
the schema rather than a habit, and a template is exactly as safe to keep and
hand around as the spec it was taken from.
Applying one re-points every panel at a source the reader picks, for the reason an import does: the ids a template carries meant something in one registry, and a template’s whole purpose is to be used somewhere else. The SQL itself is never rewritten to fit a different schema — the picker runs the guard over each statement against the chosen source’s catalog and shows what fails, and fixing it is the author’s job in the editor.
The starter templates that ship with the app are not stored at all. They are built from a source’s own catalog on request, the way the starter prompts are, and offered only where the columns support them. That also means they cannot drift — a built-in exists for as long as the catalog supports it, and stops being offered when it does not. There are two families:
- Golden signals (
src/lib/builtin-templates.ts): rate, errors, duration and saturation, parameterized by a table and its time column, for monitoring-shaped tables; on a Prometheus source, the same four from its metrics (src/lib/builtin-templates-promql.ts). - Starters for files (
src/lib/builtin-templates-files.ts, #606): a whole dashboard for the kinds of file people upload, chosen by the shape of one table’s columns, with no model call.
Starters for files
Section titled “Starters for files”Each SQL table with a time column (its declared time column, else the first
date or timestamp column) is read for one of three shapes. The column
roles come from the names, since a catalog records a name and a type and
nothing about the values; a name that is not a plain identifier is skipped.
| Starter | What it looks for | What it builds |
|---|---|---|
| Activity log | a number named as a distance (distance, _km, _mi, meters) and one named as a duration (duration, minutes, seconds, or a unit such as _min or _s after a time word); optionally a type or sport text column and a heart-rate column |
distance and time per week, average speed per week (derived from the two, in km/h or mi/h when the names say the units), heart rate per week, activities by type, the latest activities |
| Spending | a number named as money (amount, total, cost, price, value, debit, credit, _usd…) and a text column to break it down by (category, type, account, method…, else a merchant, payee or vendor) |
spent per week, the latest month’s total, spent by category, the top merchants, month by month by category |
| Daily measurements | two or more other numbers (ids, keys and calendar parts such as year are not measures), and no distance or duration without its other half |
the latest value of each, with the days behind it, a daily series for each, and the latest rows; up to four measures |
A table gets at most one: an activity log first, then spending, then daily
measurements. Money with nothing to break it down by is a measurement, which
is why a utility bill’s cost_usd beside kwh reads as daily measurements
rather than spending.
The SQL is one statement for both dialects (TimescaleDB’s PostgreSQL and
DuckDB), checked by the same guard as any other. A time series buckets the
time column and declares the bucket as its timeField, so the dashboard’s
window narrows it; a breakdown (a pie, a top-ten table) has no time column
for the window to narrow and reads the whole table, as its description says.
The window is the last 365 days (now-365d), a relative expression the
server resolves: a file is history, and the picker changes it in one click.
Where they appear: they lead the template listing, ahead of the workspace’s own templates; New dashboard shows a source’s starters above the prompt, applied in one click as the first version, unsaved, with no model; and the Data sources page, after a source is created, offers each of its starters as a link to New dashboard with it applied.