# Liveboards

A liveboard is a board defined entirely as data: a set of named, parameterised DSL queries, plus a list of sections that bind those query results to a view. A built-in time-window selector feeds the queries, so one spec answers "last week", "last 3 months" or "this month against last year" without any extra work. This page covers the liveboard file format, every section type of the general-purpose `report` genre, parameters and windows, validation, and the CLI workflow.

Where a dashboard is a grid of independently configured charts and a report is a narrative document, a liveboard sits in between: one spec, one set of inputs, many renderings.

## The file

A liveboard file is a thin wrapper around a `spec`. It can be JSON or YAML:

```json
{
  "name": "Minimal Demo Liveboard",
  "description": "One query, one KPI section.",
  "slug": "minimal-demo-liveboard",
  "spec": {
    "genre": "report",
    "defaults": { "start": "2026-04-01", "end": "2026-06-30" },
    "queries": {
      "commit_count": "source(\"scout.commits\", time: committed_at).since(@time, \"[%start%]\").filter(committed_at < \"[%end%]\").agg([count() as n])"
    },
    "sections": [
      {
        "id": "overview",
        "data": { "commits": { "query": "commit_count" } },
        "view": {
          "kind": "kpis",
          "title": "Overview",
          "items": [{ "from": "commits", "col": "n", "label": "Commits" }]
        }
      }
    ],
    "config": {}
  }
}
```

The outer fields are metadata:

| Field | Meaning |
| --- | --- |
| `id` | Leave it out on the first push. The CLI writes the new id back into the file, and later pushes update that liveboard. |
| `name` | Display name. Required. |
| `description` | Optional one-liner. |
| `slug` | Optional URL-friendly name: lower-case letters, digits and hyphens, up to 100 characters. |

Inside `spec`:

| Field | Meaning |
| --- | --- |
| `genre` | Which renderer draws the board. `report` is the general-purpose genre this page documents. `universe` and `pulse` are navigable organisation boards, normally produced from a template (see [Boards from templates](#boards-from-templates)). |
| `defaults` | A flat map of parameter name to string value. It declares every `[%name%]` the queries may use and supplies its fallback value. |
| `queries` | A flat map of query id to DSL string. Ids are letters, digits and underscores; each query can be up to 20,000 characters. |
| `sections` | The ordered body, 1 to 200 sections. |
| `config` | Board-level settings such as tabs and the time-window selector. Use `{}` if you need none. |

## Sections

Each section binds one or more query results to a view:

```json
{
  "id": "hero",
  "data": {
    "cur": { "query": "revenue_current" },
    "prev": { "query": "revenue_previous" }
  },
  "view": {
    "kind": "hero",
    "title": "Revenue",
    "value": { "from": "cur", "col": "revenue" },
    "compare": { "from": "prev", "col": "revenue", "label": "vs prior quarter" }
  }
}
```

- `id` must be unique within the spec.
- `data` maps an **alias** (a name you pick, letters, digits and underscores) to a query: `{ "query": "<query id>" }`. Add `"params": { ... }` to override parameter values for that one binding, for example to pin a drill to `"severity": "critical"`.
- `view` says how to draw the results. Inside it, every `from`, `alias`, `prevAlias` and `prevFrom` must name an alias from the same section's `data`. `col` values are column names from that alias's query result.

### Section kinds in the report genre

| `kind` | Draws | Fields |
| --- | --- | --- |
| `hero` | One big headline number | `title`, `value: { from, col, fmt? }`, `compare?: { from, col, label? }`, `sub?` |
| `kpis` | A row of KPI cards | `title?`, `items: [{ from, col, label, fmt?, goodUp?, prev?: { from, col }, describe?, spark?: { section, col }, sub? }]` |
| `grid` | Before and after comparison rows | `title?`, `rows: [{ label, before: { from, col }, after: { from, col }, fmt?, goodUp?, unit? }]`, `sub?` |
| `cards` | One card per row of a grouped query | `title?`, `from`, `key`, `fields: [{ col, label, alias?, prevAlias?, fmt?, goodUp? }]` |
| `table` | A sortable table with change indicators per cell | `title?`, `from`, `key`, `keyLabel`, `columns: [{ col, label, alias?, prevAlias?, fmt?, goodUp? }]`, `orderBy?: { col, dir }`, `describe?`, `sub?` |
| `bars` | A bar chart over time, optionally stacked | `title`, `from`, `series: { col, label }`, `stack?: { col }`, `stackOptions?: [{ from, col, label }]`, `shareCol?`, `style?: "bars" \| "line"`, `overlay?: { col, label, fmt?, from?, scale?: "own" \| "shared" }`, `fmt?`, `describe?`, `sub?` |
| `rank` | Horizontal ranking bars, one row per category | `title?`, `from`, `label`, `value`, `dir?: "desc" \| "asc"`, `prevAlias?`, `fmt?`, `goodUp?`, `unit?`, `describe?` |
| `scatter` | One dot per row for two numbers | `title?`, `from`, `x: { col, label, fmt? }`, `y: { col, label, fmt? }`, `colorCol?`, `labelCol?`, `quadrants?: { x?, y?, labels?: { tl?, tr?, bl?, br? } }`, `describe?` |
| `histogram` | A distribution from pre-binned rows | `title?`, `from`, `bucket`, `count`, `orderCol?`, `markBucket?`, `fmt?`, `describe?` |
| `prose` | A sentence with live figures | `text`, where `{alias.col}` is replaced with the first row's value |

Notes on the fields:

- **`fmt`** is one of `int`, `pct` (appends `%`), `float` (one decimal) or `dur` (the value is hours, shown as minutes, hours, days or months as appropriate).
- **`goodUp`** says which direction is good, so change indicators are coloured correctly. `true` means up is good, `false` means down is good.
- **`prev` and `prevAlias`** point at the comparison window's result, so a card or cell shows its change.
- **`describe`** is a short Markdown explanation shown behind an info icon. Liveboard push warns about tables, charts and KPI items that have none.
- **`bars`** detects the time bucket column on its own (it is the column that parses as a date). With `stack`, the query returns one row per bucket and category. `style` sets whether it opens as bars or a line; viewers can switch it. `stackOptions` adds a switcher above the chart so viewers can break the bars down by a different category: each option names the alias (`from`) and category column (`col`) to stack by, and the first option is the one shown first. `shareCol` names a column from the same query, such as a share you worked out in the query, and shows its value as a percentage above each bar (unstacked bars only).
- **`scatter` quadrants** split at a number, or at `"avg"` or `"median"` of the plotted data.
- **`histogram`** draws rows you have already bucketed in the query. `orderCol` is a numeric column that gives the bucket order, because grouping does not preserve it.

## Parameters

Queries use `[%name%]` placeholders, the same syntax dashboard filters use:

```dsl
source("scout.revenue", time: recorded_at)
  .since(@time, "[%start%]")
  .filter(recorded_at < "[%end%]")
  .agg([sum(amount) as revenue])
```

Every placeholder used in any query must be declared in `spec.defaults`. This is checked on every push, so a new `[%team%]` without a `team` default is rejected before it is saved.

When a section runs, the values come from three layers, later ones winning:

1. `spec.defaults`
2. The time-window selector (see below)
3. That binding's own `params`

An empty or unset value removes its own condition. In `.filter(is_open == 1 and provider == "[%provider%]")` with no provider, only the provider condition goes and `is_open == 1` stays. A filter with nothing left is removed entirely, which is how `.filter(team == "[%team%]")` disappears for an organisation-wide view. A placeholder inside an `or` group drops that group.

## The time-window selector

Every liveboard shows a window selector, and its choice reaches the queries as parameters:

| Parameter | Value |
| --- | --- |
| `start`, `end` | The selected window as ISO dates. `end` is exclusive. |
| `pstart`, `pend` | The comparison window, the same length as the selected one. |
| `grain` | The chart bucket size: `day`, `week` or `month`. |

Declare in `defaults` the ones your queries use. Use `config.windows` to narrow what the selector offers:

```json
"config": {
  "windows": {
    "spans": ["mtd", "w1", "m1", "m3"],
    "compares": ["prev", "yoy"],
    "grains": ["day", "week", "month"],
    "rolling": true,
    "default": { "span": "mtd", "compare": "prev", "grain": "week" }
  }
}
```

- **`spans`**: any of `mtd` (This month so far), `w1` (Last week, the last completed Monday-to-Monday week), `m1` (Last month), `m3`, `m6` and `m12` (Last 3, 6 and 12 months). Leave it out to offer all six.
- **`compares`**: any of `prev` (vs previous period), `yoy` (vs same period last year) and `preai` (vs pre-AI baseline, anchored at 1 November 2025). An empty list hides the compare selector and the board compares against the previous period. Liveboard push warns if you list exactly one, since that also hides the selector.
- **`grains`**: the bucket sizes your chart queries support. A chart opts in by grouping on `truncate([%grain%])` of its time column, and `grain` must then be in `defaults` (usually `"month"`). With two or more grains the viewer gets a grain selector.
- **`rolling`**: by default, month spans are whole completed months, so "Last 3 months" stops at the last month boundary. On a young dataset that can exclude everything. `rolling: true` makes month spans end tomorrow instead. `w1` and `mtd` are not affected.
- **`default`**: the first selection a new viewer sees. Each value must be inside your narrowed lists, or it is ignored.

Unknown ids are dropped quietly. A `spans` list that ends up empty falls back to all spans.

## Tabs

Group sections into tabs with `config.tabs`:

```json
"config": {
  "tabs": [
    { "id": "overview", "label": "Overview", "sections": ["hero", "funnel", "narrative"] },
    { "id": "detail", "label": "Detail", "sections": ["daily_commits", "leaderboard"] }
  ]
}
```

Every id in a tab's `sections` must exist in `spec.sections`. A section in no tab is not reachable from tab navigation. Leave `config.tabs` out for a single-page board. Sections on a tab are fetched the first time the tab is opened.

## Validation

`solidafy liveboard push` validates the file on your machine before anything is sent, and the API checks it again on every write. First the shape is checked (types, required fields, limits). Then references between parts of the spec are checked. These are the errors you will meet most:

| Error | Cause |
| --- | --- |
| `query "X" uses placeholder [%Y%] not declared in defaults` | Add `Y` to `spec.defaults`. |
| `section "X" alias "Y" binds unknown query "Z"` | `data.Y.query` names a query id that is not in `spec.queries`. |
| `section "X" view references undeclared alias "Y"` | The view's `from`, `alias`, `prevAlias` or `prevFrom` names an alias that is not in that section's `data`. Usually a section copied from another one without renaming its aliases. |
| `tab "X" lists unknown section "Y"` | A tab names a section id that does not exist. |
| `config.tabs must be an array` | `config.tabs` is present but is not a list. |

Push also prints non-blocking warnings for things that make a board explain itself less well: KPI items, tables and charts without a `describe`, and a `compares` list with a single entry.

## CLI workflow

| Command | What it does |
| --- | --- |
| `solidafy liveboard list` | Lists liveboards in the active environment with id, genre and current version. |
| `solidafy liveboard push <file>` | Validates, then creates (no `id`) or updates (with `id`) the liveboard. |
| `solidafy liveboard pull [name] [--all]` | Writes liveboards as push-ready YAML to `environments/<env>/liveboards/<slug>.yaml`. |
| `solidafy liveboard pull-binding [name] [--all]` | Writes the binding a board was compiled from to `<slug>.binding.yaml` (see below). |

A typical loop is to copy the closest example from `examples/` in your project (`liveboard-minimal.json` or `liveboard-full.json`), edit it, and push until it looks right.

## Versions

Every push that changes the `spec` saves the previous spec as a version and bumps the version number. Changing only the name, description or slug does not create a version. In the portal, the **Version** picker on a liveboard shows any earlier version, and **Refresh** re-runs the board's queries.

## Boards from templates

Larger navigable boards (the `universe` genre: an organisation overview you can drill from teams into people and down to individual items) are usually not written by hand. Instead you write a short **binding** file that says which platform **template** to use and how your data maps into it. `solidafy liveboard push` recognises a binding by its content, compiles it into a full spec, and pushes that.

```yaml
template: engineering

board:
  name: Engineering
  description: Delivery, review and AI adoption across the engineering org.

levels:
  - { key: team, one: team, many: teams }
  - { key: author, one: engineer, many: engineers, col: dev }

sources:
  commits:
    product: github
    base: >-
      source("vcs.commits").join("people.directory", left_on: [author],
      right_on: [handle], type: inner)
    time: committed_at
    measures:
      commits: count() as commits
      engineers: count_distinct(dev) as engineers
```

- `template` names the platform template: `engineering`, `dora`, `claude`, `workflow` or `review-agents`.
- `board` holds the name and description. Leave out `id` on the first push; it is written back into the file.
- `levels` defines the drill path, with singular and plural nouns used in the board's wording. `col` lets the level key on a different column, for example a masked person id.
- `sources` holds your DSL for each data domain the template knows about: a `base` query up to (not including) the time filter, the `time` column, and named `measures`. A domain you leave out is treated as a capability you do not have, and every metric that depends on it is removed from the board.

Because the compiler cannot see your warehouse, push runs every compiled query against your live data before saving. If any fail, nothing is pushed and the failing queries are listed. Set `SOLIDAFY_SKIP_VERIFY=1` to skip that check while iterating.

The binding is stored alongside the board, so `solidafy liveboard pull-binding` can fetch it again later, for example to compare the same board across environments. Boards that declare editable rules also get a **Configure** button in the portal.

> **Tip:** DSL contains `: ` (as in `left_on: [x]`), which YAML reads as a nested key. Use a `>-` block for multi-line queries, or single-quote one-liners.
