This page describes Calíope 1.8, the version I am building right now. 1.7 is on the App Store for the Mac, iPad, iPhone, Apple Watch, Apple TV and Apple Vision Pro. The changelog says which version each feature landed in.

Adds an “Open in Calíope” button to every topic. It only works with the app installed.

Notebooks

What a notebook is

A Markdown file that explains a procedure and carries the steps that run it against a server.

Where it is: Workspace › Tools › Notebooks

A notebook is a Markdown file that explains a procedure in text and carries the steps that carry it out. Each step is a block of SQL, a MongoDB command, a Redis line, CQL or a search, and Calíope runs it against a server and says what it returned. It is not an analysis notebook: it doesn’t load large files, keep results of hundreds of thousands of rows or pass data from one step to the next. The data lives on the server; the notebook keeps the text and the queries.

Opening one

  • Open Notebook… opens a .md file and New Notebook starts an empty one. Recent keeps the last ten, only on this device.
  • A .md that reaches Calíope from outside — the Finder, Files, a share — goes to Notebooks only if its first line is a notebook header; any other Markdown opens in the File Preview.
  • The “Open in Calíope” button of a blog post or a class on caliope.org downloads its notebook only from https://caliope.org/, up to 1 MB, and opens it unsaved in Notebooks — in the session you are looking at, or offline if there is none. A line at the top says where it came from until you keep it with Save As…. A notebook from another site opens as a file: download it and open it with Open Notebook…. When the link is refused, the Error Log says why.
  • Opening a notebook, from a file or from the site, runs nothing.

Running it
Nothing in a notebook runs by itself. A step runs when you press Run step; Run from here runs it and the ones after it, and Run All goes through all of them in order and stops at the first one that fails or is refused. Before you press anything, the card of each step says whether it Reads or Writes, and what writes goes through the same guard as the rest of the session: a connection whose environment label is read-only refuses it. Stop appears only while a step runs on a connection that can really stop it. New Run clears the results to start over.

A step shows up to 1,000 rows; with more it says so, and the rest is in the SQL Editor. If the notebook declares an expected result, the step says whether it matches and, if not, where it differs. A step that is a blank waits for your text in Your answer: write it and press Use this answer before running it.

While you run it you can add what the notebook didn’t bring: Chart… on a step without a chart, and Add a query after a step that already ran. Both belong to this run, marked “Added by whoever runs it”, and are not saved in the file.

On the iPhone the notebook shows one step at a time, with the text that comes before it; the counter between the arrows opens the list of steps. VoiceOver reads each card as “Step N of M”, with its language, whether it reads or writes, its session and its state, and announces when each step finishes.

Where each step runs is in “Sessions and the local practice database”, what it runs on each engine in “What a step runs on each engine”, and how to write one in “Writing a notebook”. To keep proof of what was run, Generate Record…: see “The record of a run”.

Keywords: notebook, procedure, step, run, markdown, runbook

Sessions and the local practice database

Where each step runs: the session in front of you, another open one, or SQLite and DuckDB with no server.

Where it is: Workspace › Tools › Notebooks

A notebook declares one or more named sessions in its header; without any, it has one called main. Each step says which one it runs in, and without saying, it runs in the first. The header of the notebook has a menu for each session, with three kinds of destination:

  • This session, the one of the workspace where Notebooks is open.
  • Another session you have open, under Open sessions: a notebook can read from a primary and from its replica in the same run.
  • Under Local practice database, SQLite or DuckDB, in memory or in a file you choose. They need no server.

One connection for the whole run
Every step of a session goes through the same connection, from the first to the last, so what a step leaves in that connection — a variable, a temporary table, an open transaction, the database chosen with USE — is there for the next one. The tools of the session go on with their own connections and don’t see it. It is closed when you press New Run, close the tab or close the session. Not every engine can keep a connection like this; what that means in each one is in “What a step runs on each engine”.

If a session closes while you run — you disconnect it, or the server drops it — its steps say so and don’t run; the others go on.

The local practice database

  • In memory, the database is born empty when the session opens and dies when it closes: nothing stays.
  • In a file, the steps change only what they write in it; Calíope doesn’t touch the rest. The file is released when the session closes.
  • DuckDB opens closed and without extensions, as in the DuckDB Editor.
  • A local step is SQL, and whether it reads or writes is decided as in the SQL Editor.

Stopping a run
A run appears among the tasks of Activity, with “Go to” back to Notebooks. Stop is offered only where it really stops: in the relational engines and in DuckDB. SQLite, MongoDB, Redis, Cassandra and the search engines don’t cancel a step halfway, so with any of them in the run there is no button that pretends to.

Keywords: session, connection, sqlite, duckdb, practice, in memory

What a step runs on each engine

Each family runs its steps through the gate of its own tool; Elasticsearch and OpenSearch only read.

Where it is: Workspace › Tools › Notebooks

A step runs what the tool of its family runs, through the same gate: SQL as in the SQL Editor, a MongoDB command as in its command console, a Redis line as in Console, CQL as in the CQL Query and a search as in the Query of Elasticsearch and OpenSearch. Whether it reads or writes is decided by that gate before the step runs, and what writes goes through the session’s guard. The steps are recorded in the same log as the tool. Which steps keep their connection from one to the next is explained in “Sessions and the local practice database”; here is what that and Stop mean in each engine.

What a console confirms by typing, a step refuses
In every family, a command that its console only runs after you type its name is refused in a step, because a step has nowhere to type it; the notice says so and takes you to that console with the command already written. Today only the Redis and Valkey console asks for that, for FLUSHDB, FLUSHALL, REPLICAOF, SLAVEOF, CLUSTER RESET and CLUSTER FAILOVER. The CQL Query, the search Query, the MongoDB console and the SQL Editor don’t ask anyone to type anything, so in their steps nothing is refused for this reason.

MySQLMariaDBAuroraTiDB

The session keeps its connection: a variable set with SET @x, a temporary table and an open transaction are still there in the next step. Stop cuts the running statement, as the SQL Editor does.

PostgreSQL

The session keeps its connection: a SET, a temporary table and an open transaction last from step to step. Stop cuts the running statement, as the SQL Editor does.

SQL Server

The session keeps its connection, and each step is its own batch: a temporary table #t lasts into the next step, but a variable from DECLARE @x dies with the step that declared it. To carry a value forward, use a temporary table or sp_set_session_context. Stop cuts the running statement, as the SQL Editor does.

Oracle

The session keeps its connection: a private temporary table created with ON COMMIT PRESERVE DEFINITION is still there in the next step. Stop cuts the running statement, as the SQL Editor does.

ClickHouse

HTTP has no session, so the notebook session carries its own session identifier: temporary tables and settings made with SET last from step to step. If the server closes it for inactivity, the step says the session expired, and running it again opens a new one. Stop cuts the running statement, as the SQL Editor does.

SQLite

SQLite and DuckDB run in the local practice database, with no server: a step is SQL, and the connection is the whole session. DuckDB can be stopped; SQLite can’t, so with SQLite there is no Stop.

MongoDB

A step is a command in JSON — Extended JSON v2 —, the same one you type in the command console: the command is the first key ({"find": "orders", "filter": {}}). It reads or writes according to the console’s list of what reads; an aggregate with $out or $merge writes. A MongoDB session keeps no connection: a command leaves nothing behind in the connection it went through, and the only thing the session fixes is the database. The db= attribute of a step runs it against another one. The result is a table when the reply brings a batch of documents, and otherwise the reply as JSON with its keys sorted. There is no Stop.

RedisValkey

A step is one command per line, through the gate of Console and its environment label, and each line goes to the command log. On a standalone server the session keeps a connection, so MULTI, EXEC, DISCARD, WATCH, UNWATCH, SELECT and HIMPORT do run in a step — the console refuses them because it has no connection of its own. In a cluster there is no kept connection, and they are refused with the console’s reason. The result is text, with the redis-cli labels in English in every language ((integer) 1, (nil)), never a table. There is no Stop.

CassandraScyllaDB

A step is CQL, the CQL Query’s, split at its ; (a BEGIN … APPLY BATCH goes whole). It goes through the Query’s gate, the list of what reads — SELECT, LIST, DESCRIBE, USE —, and what writes goes through the label’s guard. The consistency is the one chosen in the Query, and it is recorded with each command. The session keeps a connection of its own, apart from the tools’: a USE in one step holds in the next ones, while the tools stay in their keyspace. CQL doesn’t count written rows, so the result never says “0 rows”. There is no Stop: the protocol doesn’t cancel on the server.

ElasticsearchOpenSearch

A notebook only reads here: a step runs what the Query runs, and the Query doesn’t write. With lang=sql the step is the product’s SQL; with lang=dsl it is a Query DSL body against the indices of index= (comma-separated, with wildcards). Without lang=, a body that starts with { is Query DSL and anything else is SQL; another value (esql, ppl) doesn’t run, and the step says so. What the server’s SQL could write, like a DELETE, is refused without reaching the server. Writing — creating indices, editing documents, managing users — goes through its own tool, with its sheet and its guard. HTTP keeps nothing between steps, and there is no Stop.

Keywords: engine, sql, mongodb, redis, cql, search, read only, transaction

Writing a notebook

Text, steps, variants for each engine, expected results, blanks, charts and the step that opens a tool.

Where it is: Workspace › Tools › Notebooks

The mode is chosen in the bar: Run through runs the notebook and Write edits it. In Write every segment — a text, a step, an expected result, a tool — is a card, and they are edited one at a time: press Edit on one, change it, and the notebook changes only when you press Done. A text is edited as Markdown, and a step in the editor of its family, with the same configuration as that family’s console.

Adding, moving and removing
More actions on each card brings Move up and Move down — to move it without dragging —, Insert below with Text, Step for each language, or Step that opens a tool, then Add a variant for another engine and Remove. The step that opens a tool runs nothing for anyone: it opens that tool in the session, with your note.

A step’s properties
Properties… opens the step’s sheet: the engines it runs on, each with an optional minimum version after a colon (mysql:8.0,postgresql), its name, its session, and It’s a blank the person running it fills in. In MongoDB it adds the database (db); in a search, the index and the language. Several steps with the same name and different engines are variants of one step: each session runs the variant of its engine, and the others say they don’t apply. In Chart you declare its chart, with the same control as the output of a report, choosing among the columns of its last result — run it once first.

Sessions
In the sessions header, Add session…, Rename… and Remove session. Renaming reaches the steps that used it; the last session can’t be removed; a name has only letters, digits, _ and -.

The expected result
After a step runs, Use this result as expected turns what it returned into its expected result, with the mode chosen in Comparison mode: table in order, table in any order, number of rows, or text. A step without a name gets step-N when it takes one. A blank is a step whose body the person who runs it fills in; the seal doesn’t cover what they write.

Saving
Unsaved changes shows in the bar while something isn’t saved, and opening another notebook or closing the tab asks first. Save As… keeps the same notebook under another file; Duplicate as new notebook gives it a new identifier: it becomes another notebook. To write one by hand, see “The notebook file format”.

Keywords: write, edit, variant, expected, blank, chart, session, save

The record of a run

A sealed PDF of what was run, by whom and against what, that another copy of Calíope can validate.

Where it is: Workspace › Tools › Notebooks

Generate Record… turns a run into a PDF: who ran it, when, with which Calíope, against which server and account, and for each step its text, whether it read or wrote, when it started and finished, how many rows it returned or changed, its error and whether it matched the expected result. Each step carries a sample of at most 20 rows, with each cell cut to 200 characters, and says so when it cut. Steps that didn’t run, didn’t apply or were refused appear as such; what the person who ran it added goes apart, marked as theirs.

The sheet asks for Run by — your name as it will appear; it is remembered on this device — and Include the server address, the host and port of each session: it is evidence of what it ran against, and you can leave it out if the record will leave your organisation. Save Record… chooses where to keep it.

What the seal is, said truthfully
Inside the PDF goes a copy of that data with a seal, and its code is printed at the foot of every page. The seal detects that someone edited the copy; only Calíope validates it, and another PDF viewer doesn’t see it. It doesn’t stop someone who takes the app apart.

Validating a record
Validate Record… is in the bar and in the empty view of Notebooks, and opens a PDF. It says one of four things:

  • Intact — The seal is valid: the copy of the data it carries is the one Calíope generated.
  • Modified — It carries a copy and a seal, and they do not match: the contents of this record cannot be trusted.
  • Not a Calíope record — This PDF does not carry the sealed copy of a record, so there is nothing to validate.
  • Sealed by a newer Calíope — the record uses a key this version doesn’t have; updating Calíope validates it.

A file that couldn’t be read isn’t a result of the record: the Error Log says why. What is shown is the sealed copy, not the pages: What follows is the sealed copy the record carries, drawn by Calíope. This is what counts, not the pages of the PDF, which anyone can retouch. Its seal code is the one at the foot of each page, so you can match them. A modified record is shown too, under Unverified contents, so you can see what it says.

Keywords: record, evidence, pdf, seal, validate, audit

Sealing a notebook

The author seals it; whoever runs it can change it freely, and Calíope says what changed.

Where it is: Workspace › Tools › Notebooks

Seal… is in Write, in the sessions header, and asks for Author and Version. The sheet says what it covers: “The seal covers the text and the fixed steps. It doesn’t cover what’s written in the blanks: whoever runs the notebook fills them in without breaking it. If someone changes anything else, Calíope says the notebook was modified and which steps changed.”

Editing a sealed notebook doesn’t ask for permission. The header of the notebook says its state, with a glyph and a name:

  • Unsealed, if its author didn’t seal it.
  • Sealed by its author, with the version, and intact if nothing covered changed.
  • Modified since the author’s seal, with the steps that change and the ones added; if only the text, the header or an expected result changed, it says “No step changed.”.
  • Sealed by a newer Calíope, if the key is one this version doesn’t have.

Each changed or added step carries its mark on its card — Changed since the seal or Added since the seal — and the record of a run says which version it ran on and what changed.

Your own version
On a modified notebook the button becomes Seal as Your Own Version…: the new seal is yours and keeps which seal it derives from, named by the original seal’s code, because the file doesn’t keep its author. Duplicate as new notebook keeps the seal, so the copy comes out modified without any changed step.

The seal detects editing; it doesn’t stop someone who takes the app apart.

Keywords: seal, author, version, modified, derive, integrity

The notebook file format

For writing one by hand: a header comment, fenced steps, expected results and the seal.

Where it is: Workspace › Tools › Notebooks

A notebook is plain Markdown that any viewer reads: what only Calíope needs goes in HTML comments, which no viewer draws, and the steps are fenced code blocks, which every viewer shows as code. A minimal one:

<!-- caliope-notebook
version: 1
id: 6F1C2A4E-9B7D-4C1E-8F3A-2D5B7E9A0C14
lang: en
sessions: main
-->
# Count orders by category

Counts the orders of each category.

```sql engines=mysql:8.0,postgresql step=contar
SELECT categoria, COUNT(*) AS total FROM pedidos GROUP BY categoria ORDER BY categoria;
```

```expected step=contar mode=table
categoria,total
hogar,12
```

Run it and compare it with the expected result.

The header is the first line: <!-- caliope-notebook, then key: value lines and -->. version is 1, id identifies the notebook across its edits, lang is the language of its text and sessions lists the named sessions, separated by commas (without it there is one, main). The title is the first # heading. A .md without a header opens too, and gets one only when it is edited.

A step is a fenced block whose language is sql, mongo, redis, cql or search. Its attributes go on the opening line:

  • engines= — where it runs as written, each with an optional minimum version after a colon. Required in sql; the other four have their family by default.
  • step= — its name. Steps with the same name and different engines are variants of one step.
  • session= — which session it runs in; without it, the first.
  • db= in mongo, and lang=sql|dsl and index= in search.
  • answer — the step is a blank that the person who runs it fills in.
  • chart=bar|line|pie, label= and values= — its chart.

A block in any other language, or a sql block without engines=, is code that is shown, not a step.

An expected result is an expected block with step= and mode=: table (CSV with its header row, in order), unordered, rows (a number) or text. Each cell is compared as text: NULL is NULL, and a result cut at the step’s row ceiling doesn’t compare.

A tool block with name= opens that tool in the session; its body is a note.

The seal, if any, is the last comment of the file, <!-- caliope-seal, and covers the canonical form of each segment: line endings, trailing spaces and Unicode normalisation don’t break it, and the body of a blank doesn’t count. What a version of Calíope doesn’t understand — an attribute, a key — is kept as it is and ignored, and a notebook with a higher version opens without running its steps. Saving without editing leaves the file byte for byte as it was.

Keywords: format, markdown, header, fence, engines, expected