oficina / slides Public

Spec: presenter, steps, layouts, rehearsal, check (draft 1)

Design for #34: how Slides gains the HalfStack deck layer's presenter
view and sync, builds and steps as data, a layout library agents can
fill, rehearsal editing on the CRDT, check mode, and layout MCP verbs
over #25's edit transaction. Unreviewed; Paul approves before any plan.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c803cd8767a7fe1d26dcf3b9733e003f80418dfe parent af4f47e
1 file changed, +896 −0
  • docs/superpowers/specs/2026-11-11-presenter-and-rehearsal-design.md +896 −0

CI passed — run details

diff --git a/docs/superpowers/specs/2026-11-11-presenter-and-rehearsal-design.md b/docs/superpowers/specs/2026-11-11-presenter-and-rehearsal-design.md
new file mode 100644
index 0000000..5bed8ad
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-11-presenter-and-rehearsal-design.md
@@ -0,0 +1,896 @@
+# ๐Ÿค– Slides: presenter, steps, layouts, rehearsal, check โ€” design
+
+Design, 2026-11-11. **Draft for Paul's approval; nothing here is
+approved yet.** Written by Claude Opus 5.5 on branch
+`design/presenter-and-rehearsal` for
+[#34](https://amadan.net/oficina/slides/-/discussion/34), which records
+the presentation layer Paul built for his HalfStack Vienna talk and his
+view that it is what Slides wants to be.
+
+Reference code, read and never modified:
+`~/github.com/carlosframework/halfstack-vienna-build`, branch
+`build-deck` (called **the deck** below): `engine/deck.js`,
+`rehearse/server.py`, `rehearse/requests.py`, `acts/`, `build.py`,
+`tests/`, and its spec
+`docs/superpowers/specs/2026-11-07-halfstack-vienna-talk-design.md`.
+
+This spec builds on, and does not restate:
+
+- the Slides design, `2026-09-07-slides-design.md` (cited as **ยงn**),
+ in particular ยง0.1 (one tree), ยง2 (the model), ยง3.4 (presenting) and
+ ยง7 (the drive surface);
+- the delegated access contract, `2026-10-25-agent-access.md`, and
+ delegated editing, `2026-11-01-agent-deck-editing.md` (together
+ **#25**);
+- `AGENTS.md`, especially the seams, the fixtures rule and the font
+ rule ("no flashing, ever").
+
+---
+
+## 0. Intent
+
+Paul built a deck layer in a week that did six things Slides does not:
+it presented with a presenter view that stayed in step across windows
+without a network, it revealed slides a press at a time, it built
+slides from a small set of layouts, it let him reword a slide and its
+notes while rehearsing, it checked itself for overflow and small type,
+and it took per-slide requests that an agent then acted on. Paul's
+judgement in #34 is that this is what Slides is for. The deck did it
+single-writer, as code, rebuilt on every change. Slides should do it
+on its one block tree (ยง0.1), collaboratively, through the operations
+a person and an agent already share (ยง7).
+
+**Success** is that the next talk Paul gives could be made and
+rehearsed in Slides instead of in a repo of Python act modules: built
+from layouts by him and by agents, rehearsed with edits landing live,
+checked before he leaves for the venue, and presented from his laptop
+over HDMI with the venue wifi off.
+
+### 0.1 Goals
+
+1. A presenter view: current slide and step, next slide or step,
+ rich notes, a talk timer and a wall clock, in step with the
+ projector and a phone, driven by keyboard and clicker, with a black
+ screen; and presenting that survives losing the network.
+2. Builds and steps as data in the tree.
+3. A layout library as data, whose slots an agent can fill.
+4. Rehearsal: edit a slide and its notes in place from the presenter
+ view, with the notes WYSIWYG, on the CRDT document, plus requests to
+ an agent per slide.
+5. Check mode: overflow and minimum text size, at projector sizes.
+6. MCP verbs built around layouts, and the request and reply loop,
+ extending #25.
+
+### 0.2 Non-goals
+
+- The deck's bespoke effects: the FLIP screenshot grid, letter-morph
+ reveals, colour-flush reveals, the diagrams in `acts/act1.py`. Tier 3
+ in #34's sorting: "ask a coding agent". Slides gets the general
+ mechanism (steps, a fixed set of effects) and nothing shaped for one
+ talk.
+- Video sequences (ยง9 still holds: video is not built).
+- An offline zip of a deck as a download (ยง3.6 says why not now).
+- Copy review of agent-written words. That stays an agent-side process
+ (the deck ran it through a skill); Slides records who wrote what
+ (ยง6.2) and does not grow a review gate.
+- Anything that changes the HalfStack deck. It is Paul's talk on
+ 16 November and stays as it is.
+
+### 0.3 Anti-goals (failure even if it works)
+
+- **A second representation of a deck.** Layouts that the renderer
+ consults at render time, a rehearsal copy of the strings, a "steps
+ file" beside the tree: each is the drift ยง0.1 exists to prevent. A
+ layout produces ordinary blocks and is then forgotten by every
+ renderer.
+- **A projector that changes under the audience without the presenter
+ doing anything.** Someone else's edit, a reconnect, a late server
+ answer or a font arriving must not repaint the slide on the screen in
+ a talk (ยง3.5).
+- **A press that does nothing visible.** Step numbers that leave gaps,
+ steps on blocks that were deleted, or a clicker press swallowed
+ while the presenter view has focus in a field.
+- **A lost word.** The rehearsal surface types into the same document
+ as the editor and inherits every guarantee `AGENTS.md` lists for it;
+ it must not add a path around the save queue.
+- **A verb that only an agent can use.** Every new MCP verb is an
+ operation the inspector also performs (ยง3.1: "a person and an agent
+ can never do different things").
+
+---
+
+## 1. Rulings this spec asks for
+
+The ones Paul has to make are ยง11. These are the session's calls,
+listed so they can be reversed in one place.
+
+| # | Call | Rejected alternative |
+|---|---|---|
+| P1 | A presentation's position is **(slide id, step)**, not an index. | Keep `Presentation.Slide` as an index (a move or a cut during a rehearsal shows a different slide; the deck addressed slides by key for exactly this reason). |
+| P2 | Steps are a **`step` number on a block** (and on a list's items, ยง4.2); the effective sequence is the **rank** of the distinct numbers in use, so gaps never cost a press. | A step count stored on the slide (drifts from the blocks); dense numbers maintained on every edit (a concurrent delete leaves a gap anyway). |
+| P3 | A block waiting for its step **keeps its space**. Revealing it never moves anything else. | Collapsing unrevealed blocks (every press would reflow the slide; breaks the font rule's "first reveal is the final layout"). |
+| P4 | Core and full mode is an **`optional` flag on a slide**; the session carries the mode. | Two decks, or a slide list per mode. |
+| P5 | A layout is **a recipe that produces ordinary blocks**, each tagged with the slot it filled. Nothing renders from the library. | Layouts as render-time templates (a second representation; a library change would silently restyle old decks). |
+| P6 | The built-in library is **one committed JSON file** embedded by the Rust core and the editor bundle alike; the new ops that read it live on both sides under the fixtures rule. | Expanding layouts in Go (a second op writer beside the core, which #25 rules out) or in JS only (the API could not use them). |
+| P7 | Presenting windows on one machine stay in step **over BroadcastChannel with the deck's Lamport ordering**, and the server session orders commands by the same stamp. | Server only (no network, no talk); local only (no phone). |
+| P8 | Rehearsal is **the editor in the presenter's arrangement**, at `/d/{sqid}/rehearse`, not a mode of the remote-capability presenter view. | Making the anonymous `/p/{session}/notes` page editable (it holds only a projector capability; edits must name a person, ยง6.2). |
+| P9 | Rehearsal requests are **app rows** keyed by slide id, not document state. | Requests in the Y.Doc (they are about the deck, not part of it; a share-link reader would receive them in every update). |
+| P10 | Check mode is **computed from the layout engine's paint list** on the server. A browser measurement is a later addition. | Headless Chromium (no such platform capability, ยง1 ruling 4). |
+| P11 | The new MCP verbs are **descriptors over #25's one edit transaction**, and the new ops they compile to are also accepted by `slides_update_deck` and the drive API. | A second retry, receipt or authority path per verb. |
+
+---
+
+## 2. The model additions
+
+Five new keys, all optional, all absent on every existing deck. A deck
+that carries none of them renders, exports and presents exactly as
+today. Each lands in `core/src/schema.rs`, `core/src/view.rs`,
+`core/src/ops.rs`, `fixtures/ydoc.mjs`, `fixtures/view.mjs`,
+`fixtures/ops*.mjs`, `internal/slides/deck/` and the vectors, in one
+commit per key (the fixtures rule).
+
+| Key | On | Type | Meaning |
+|---|---|---|---|
+| `optional` | slide map | bool | Shown in full mode only (ยง3.3). |
+| `step` | block map | integer โ‰ฅ 1 | The press that reveals this block (ยง4). |
+| `build` | block map | Y.Map `{effect, items}` | How it arrives: `effect` โˆˆ `appear` (default), `fade`, `rise`; `items` โˆˆ `together` (default), `each` for `list` blocks (ยง4.2). |
+| `slot` | block map | string | The library slot this block was made for (ยง5). |
+| `from` | slide map | Y.Map `{layout, v}` | The library layout and its version the slide was made from (ยง5). |
+
+None of these is text, so none is inside a text fragment and none
+needs `slides_core_check` (ABI 2) to change: the shape gate covers text
+fragments, and `deck.Parse` covers the projection. The view exposes all
+five; `deck.Deck` gains the fields; `render`, `layout` and the
+presenter read `step`, `build` and `optional`; nothing renders from
+`slot` or `from` except a `slides-slot` attribute in the editor's
+stage (for the inspector, ยง5.4).
+
+`set_slide` gains `optional`; `set_block` gains `step`, `build` and
+`slot`. Absent means unchanged and `null` means remove, as the
+vocabulary already does for `phone`. The view sorts nothing by these
+keys; `order` is untouched and stays invisible to readers.
+
+**Why per-key last-writer-wins is fine here.** Two people setting a
+block's step at once leaves one of the two numbers, which is a visible,
+fixable placement choice and never content. The rule `AGENTS.md` keeps
+("placement may be lossy, content may not") holds.
+
+---
+
+## 3. The presenter
+
+### 3.1 What carries over from the deck
+
+- **The presenter view's contents**: current slide at its current
+ step, the next thing a press will show (the next step of this slide,
+ or the next slide, or "End"), the notes, the talk timer, the wall
+ clock, the position (`7 / 31 ยท core`) and a black-screen indicator.
+- **The timer starts at the first move**, not when a window opens and
+ not on `b` or `o`; `r` sets it back to 0:00 and it starts again at the
+ next move. It is shared state (ยง3.2), so the phone and the laptop
+ show the same elapsed time.
+- **Every move lifts the black screen**, so nothing moves unseen under
+ it.
+- **The keys** (one table, in the projector, the presenter view and
+ rehearsal):
+
+ | Key | Does |
+ |---|---|
+ | `โ†’` `Space` `PageDown` | next step, else next slide |
+ | `โ†` `PageUp` | previous step, else previous slide at its last step |
+ | `Home` / `End` | first / last slide, at step 0 |
+ | `b` `B` `.` | black screen on/off |
+ | `o` `O` | core / full mode |
+ | `r` `R` | reset the timer |
+ | `n` `N` | notes on the projector page (not in a talk; rehearsal and solo only) |
+ | `p` `P` | open the presenter view in a second window |
+ | `Esc` | leave a text field, giving the clicker back |
+
+ Clickers send `PageDown`/`PageUp`, and the common ones send `b` or
+ `.` for blank; nothing else is needed. A key with Alt, Ctrl or Meta
+ is never ours. **A key whose target is a field types; it never
+ moves the deck** (the deck's rule, kept); `Esc` leaves the field.
+- **Click and swipe**: a click on the left third goes back, elsewhere
+ forward; a horizontal swipe over 40 px moves. Never on a link, a
+ button, a field or the notes.
+- **Returning lands at the end.** Going back into a slide shows it
+ fully built, as the deck does.
+- **Addressing by slide id** (P1), so a slide moved or cut mid-rehearsal
+ does not change what the room sees; a cut slide lands on the nearest
+ surviving slide after it in the order last seen (the deck's `land`).
+
+### 3.2 Sync across windows and devices
+
+Today (ยง3.4) a presentation is a server row moved by `POST
+/p/{session}/command`, fanned out over `/p/{session}/stream`, and every
+surface fetches the slide it is told to show. It needs the server for
+every press. The deck needed nothing but the two windows.
+
+Slides gets both, layered:
+
+**Locally**, every presenting window of one browser profile โ€” the
+projector page, the presenter view, a rehearsal window โ€” joins a
+`BroadcastChannel` named for the session (`slides-present:<session
+sqid>`), with the `storage` event as the fallback, exactly as
+`engine/deck.js` does. A message is the whole position:
+
+```json
+{"slide":"ab12cd34ef56","step":2,"mode":"core","black":false,
+ "clock":1731760000000,"t":41,"id":"k3j9โ€ฆ","nav":true}
+```
+
+- `t` and `id` are the deck's **Lamport stamp**: a sender stamps one
+ past the highest `t` it has seen, with its own random id; `(t, id)`
+ pairs are totally ordered; a window applies a message only if its
+ pair beats the last one applied; applying never sends; only a local
+ action sends. Two windows pressing at once agree on the winner and
+ never ping-pong.
+- `hello` on open, answered once with the current state, so a window
+ opened late catches up.
+- `nav` marks a message caused by a move, the only kind that starts
+ another window's timer.
+- `clock` is the timer's start (epoch ms) or `null`.
+
+**Through the server**, every local action is also `POST
+/p/{session}/command` with the stamp, and every window also listens to
+the session stream. The server keeps the newest stamp on the row and
+**refuses (204, no change) a command whose stamp does not beat it**, so
+a phone and a laptop that both pressed converge on the same total
+order the local windows use. The server stamps a command that arrives
+without one (the scriptless remote's forms) as `max(t)+1` with its own
+id, so old remotes keep working.
+
+**When the server is unreachable**, the local windows keep presenting
+on their own; the phone remote cannot (it has no other path to the
+laptop, and a peer-to-peer link is out of scope). When the stream
+reconnects, the windows post their newest state and the stamp decides:
+a laptop that kept presenting offline wins over the stale row, which is
+right, because the laptop is what the room is looking at.
+
+The row gains `slide_id`, `step`, `mode`, `clock_started_at`, `stamp_t`,
+`stamp_id` (one migration, `rastrillo migration generate`, SQL read).
+`Slide` (the index) stays, written alongside for one release so a page
+loaded before the deploy keeps working, and is then dropped in a later
+migration. `present.Event` gains the same fields; the three existing
+JSON names keep their meaning. `commandChanges` gains `step`, `mode`,
+`clock` and the stamp; `goto` takes a slide id (an index is still
+accepted and resolved against the current view).
+
+The remote stays the anonymous `remote:<session>` actor (ยง1 ruling 17).
+Team mode is unchanged: every `/p/โ€ฆ` request and delivery re-decides on
+the presenter's reach (`team_present.go`), and a command is a guarded
+write like today. `TestTeamEveryWriteRouteRefusesALapseBeforeCommit`
+gains nothing new here because the route is the same.
+
+### 3.3 Core and full mode
+
+A slide with `optional: true` is skipped in core mode by every
+presenting surface: projector, presenter view, remote, follow view and
+rehearsal. The session's `mode` decides, `core` by default; `o` toggles
+it and syncs like a move. When a mode change hides the current slide,
+the position moves to the next shown slide (the deck's `setMode`).
+
+The viewer, the editor strip, the PDF and the API show every slide.
+The strip and the viewer mark an optional slide with a text badge
+("Full mode only"; never colour alone). The PDF export gains a
+`mode` option, default `full`; the status page says which.
+
+### 3.4 Showing steps
+
+`render.SlideWith` gains `Options.Step` (`-1` = fully built, the
+default for every existing caller, so the viewer, the editor stage, the
+API's `.html` twin and the thumbnails are unchanged):
+
+- Each block with a `step` is written with `slides-step="<rank>"`,
+ where rank is its position among the slide's distinct step numbers
+ (P2), and `slides-build="<effect>"`.
+- A `list` with `build.items = each` writes `slides-step` on each item:
+ the first item at the block's rank, the rest one press each after it.
+ This is the deck's "accumulating list", and the only per-paragraph
+ step. The slide's press count accounts for it.
+- The section carries `slides-steps="<n>"` and `slides-at="<k>"`.
+ `slides.css` hides (visibility, not display: P3) every element whose
+ step exceeds `slides-at`, marks it `aria-hidden` through the renderer,
+ and runs the effect on the transition. Under
+ `prefers-reduced-motion: reduce` every effect is `appear`.
+- With scripts off, the projector and `?present=1` page through steps
+ as `?slide=N&step=k` links, so the scriptless floor (ยง8) keeps steps.
+ The viewer and the phone reading view always show the slide fully
+ built.
+
+Steps change **in place**: moving between steps of one slide toggles
+`slides-at` on the slide already on screen; it fetches nothing and
+cannot flash, because every block was laid out and its families loaded
+when the slide was installed (the font gate already holds the whole
+slide). Moving to another slide is today's swap in one task.
+
+The announce region says "Slide 7 of 31, step 2 of 4: <title>"
+(catalog keys).
+
+The layout engine gains `LayoutAt(d, index, step)`: blocks past the
+step are measured (they keep their space, P3) but not painted.
+Thumbnails take `?step=k` on all four surfaces, so the presenter view
+and the remote can show "next step" as a picture without a font, as
+they do today. PDF stays one page per slide, fully built; a page per
+step is out of scope (ยง3.7).
+
+### 3.5 Edits during a presentation
+
+The deck rebuilt and reloaded every window after an edit. Slides
+does not rebuild; but a live deck can change under a talk, by the
+presenter in rehearsal or by a collaborator at any time. The rule:
+
+- **The slide on the projector never changes under the audience**
+ except by the presenter's own action. Projector and follow pages pick
+ up the deck's newest state **when they next change slide**, not
+ while a slide is showing.
+- **In rehearsal**, the presenter's own edits are visible at once on
+ their own screen (they are typing into the stage), and the projector
+ refreshes the current slide **on the next press**. A session started
+ from the rehearsal surface carries `rehearsal: true`, and its
+ projector re-renders the current slide when the deck's seq moves (the
+ rehearsal room has no audience to protect). This is the one place the
+ projector watches the deck stream.
+- Steps clamp: if the current slide lost blocks and has fewer steps,
+ the position clamps to its new last step.
+- A removed current slide lands as in ยง3.1.
+
+### 3.6 Offline
+
+The deck runs "from Paul's laptop over HDMI without wifi". Slides is a
+server app, so presenting offline needs the talk's pages in the browser
+before the network goes:
+
+- **Starting a talk prefetches it.** The projector page, on start and
+ on reconnect, fetches every slide's projector fragment for the
+ current seq (`/p/{session}?slide=N&fragment=1`, through the existing
+ fragment route), their pictures and the font families the deck uses,
+ and holds them in memory. Moves are then local: the projector
+ installs from memory and posts the command (ยง3.2). The presenter view
+ does the same for its thumbnails and notes.
+- **A service worker scoped to `/p/{session}/`** keeps the same set in
+ Cache Storage, so a reload or a closed laptop lid with no network
+ still opens the talk. It caches only that session's GETs, is
+ versioned by the deck seq, and is removed when the session ends. It
+ never caches a signed-in page, an editor page or a share link.
+- The presenter view shows **"Ready offline"** (a text state, catalog
+ key) once everything is held, and "Not ready offline: N slides
+ missing" otherwise, so Paul can check before he unplugs.
+- When the network comes back, the session reconciles by stamp (ยง3.2)
+ and, if the deck seq moved, refreshes the held set โ€” between slides,
+ per ยง3.5.
+
+An **offline pack** (a downloadable self-contained HTML of the deck,
+like the deck's zip) is the stronger guarantee and is not designed
+here: it is a second build output of the renderer plus a copy of the
+presenter engine, worth its own spec once the in-browser path has been
+used at a real venue (ยง11 Q2).
+
+### 3.7 Out of scope
+
+A peer-to-peer phone remote with no server; native remote (ยง9); a PDF
+page per step; per-step speaker notes; timing targets per section;
+presenter view drawing live HTML clones of the slides (it keeps its
+SVG pictures, and so keeps fetching no fonts).
+
+---
+
+## 4. Builds and steps as data
+
+### 4.1 What carries over from the deck
+
+The press model: a slide has `n` steps; forward reveals the next,
+back undoes it; arriving forward starts at 0, arriving backward starts
+at `n`. `data-step` on an element and a count on the slide. Elements
+stay laid out while hidden. Accumulating lists. Fades.
+
+### 4.2 What changes on a CRDT
+
+- **The count is derived, never stored** (P2). The deck stored
+ `data-steps` on the slide, which was fine for one writer. Two
+ writers would make it disagree with the blocks; deriving it from the
+ ranks of the block `step` values cannot.
+- **Ranks, not numbers.** Steps `{1, 3, 7}` play as three presses. A
+ concurrent delete or an agent picking a large number never makes a
+ press that shows nothing. The inspector shows ranks ("Appears on
+ press 2 of 3") and writes numbers; "Add a step" writes `max + 1`.
+- **Same number, same press.** Two blocks with one number arrive
+ together, which is how a heading and its line come in at once.
+- **Items.** `build.items = each` on a list is the only sub-block
+ step; per-paragraph keys inside the text fragment would put
+ attributes into text, which the write gate refuses (ruling 19) and
+ y-prosemirror deletes.
+- **Canvas and flow alike.** Steps are independent of placement and of
+ the phone layer; the phone reading view shows the slide fully built.
+
+### 4.3 The editor
+
+The inspector's block panel gains "Appears" (with the slide / on press
+N / new press) and "Arrives" (appear, fade, rise), and for a list
+"Items: together / one at a time". The stage shows every block, with
+unrevealed-at-the-current-preview blocks dimmed and a step badge, and a
+step scrubber under the stage to preview presses. Each control is one
+op (`set_block`), so undo and collaboration are the existing ones.
+
+### 4.4 Out of scope
+
+Exit steps (a block that leaves), motion paths, per-block timing,
+auto-advance, the deck's FLIP grid, letter morphs and colour flushes.
+Effects other than `appear`, `fade` and `rise`. The data leaves room:
+`build` is a map, so `exit` can be added as a key without a migration.
+
+---
+
+## 5. The layout library
+
+### 5.1 What carries over from the deck
+
+The deck had a handful of layouts in Python (`statement`, `quote`,
+`items`, `media`, a grid, diagrams, terminal panels), each a function
+from strings to markup, and strings with ids, a label and a `context`
+line telling the writer what the string is for. That `context` line is
+what let an agent write the right thing in the right place. Slides
+keeps the idea, as data.
+
+### 5.2 What a layout is
+
+```json
+{
+ "id": "items",
+ "v": 1,
+ "name": "layouts.items.name",
+ "summary": "layouts.items.summary",
+ "slide": {"layout": "flow", "template": "title-body"},
+ "slots": [
+ {"slot": "heading", "type": "heading", "region": "heading",
+ "props": {"level": 2},
+ "hint": "layouts.items.heading.hint", "max_chars": 60, "required": true},
+ {"slot": "items", "type": "list", "region": "body",
+ "props": {"style": "bullet", "size": "l"},
+ "build": {"items": "each"},
+ "hint": "layouts.items.items.hint", "max_items": 5, "max_chars": 70}
+ ],
+ "notes_hint": "layouts.items.notes.hint"
+}
+```
+
+- A layout is a **slide recipe**: the slide's placement (`layout`
+ flow/canvas, and a template or boxes), and an ordered list of
+ **slots**, each one block to make: type, region or box, props, an
+ optional step and build, a hint, and advisory limits.
+- `name`, `summary` and `hint` are catalog keys (the hardcoded-English
+ rule), resolved in the locale of whoever reads them: the editor's
+ picker, or the MCP descriptor's `slides_list_layouts` answer.
+- Limits (`max_chars`, `max_items`, `required`) are **advice that check
+ mode reports**, never refusals. A CRDT cannot enforce a length
+ across concurrent typists, and refusing a person's words at
+ rehearsal would be worse than a warning.
+- `v` is the layout's version. A slide records `from: {layout, v}`
+ only to say where it came from; changing the library never changes
+ an existing slide (P5).
+
+### 5.3 The built-in set (v1)
+
+Drawn from the deck's and from Slides' existing templates, each
+expressible with today's block types:
+
+| Layout | Made of |
+|---|---|
+| `title` | heading 1, optional subtitle, optional kicker |
+| `section` | heading 1 on the `section` template |
+| `statement` | one large text block, nothing else (the deck's most used) |
+| `quote` | quote with cite (`quote` template) |
+| `items` | heading and a list built one item per press |
+| `media` | full-bleed image with optional caption (`image-full`) |
+| `two-up` | heading and two columns |
+| `code` | heading and a code block (the deck's terminal panel, minus its chrome) |
+| `big-number` | a large figure and a line under it, the line on press 1 |
+
+Ten is the ceiling for v1. A layout is added when a real deck wanted it
+twice.
+
+### 5.4 Where it lives
+
+`layouts/library.json` at the repo root, one file. The Rust core embeds
+it (`include_str!`) and the editor bundle imports it, so the core's ops
+and the browser's ops read the same bytes; the Go side serves it from
+the core's view of it rather than parsing its own copy. Changing it
+means rebuilding the wasm and the bundle and regenerating vectors,
+which the gate already checks.
+
+Two new ops, on both sides, with fixture files and vectors:
+
+- `add_slide_from_layout {after?, layout, fills?, notes?, optional?,
+ id?}`: makes the slide and its blocks in one batch (block ids minted
+ like `add_block`'s), tags each block with `slot` and the slide with
+ `from`, writes `fills` (`{slot: markdown}`; Markdown subset as
+ `set_text`) and notes. Unknown layout or slot is a refusal of the
+ batch.
+- `set_slot {slide, slot, markdown}`: `set_text` on the block of that
+ slide whose `slot` matches. No match, or more than one, is a refusal
+ naming the slot. This is the verb a small model can use without
+ reading block ids.
+
+`ids` in the acknowledgement maps the op index to the new slide id, as
+now; the blocks are found by slot from then on.
+
+The editor's "New slide" menu becomes the layout picker (with "Blank"
+first, today's behaviour), and the inspector shows a block's slot hint
+under its fields.
+
+### 5.5 What changes on a CRDT
+
+- A slot is a **tag on a block**, so moving, restyling or deleting a
+ block is ordinary editing; a slide whose structure drifted from its
+ layout just has fewer tagged blocks. Nothing tries to restore the
+ recipe.
+- Two people making a slide from a layout at once make two slides,
+ as two `add_slide` calls do today.
+- `set_slot` on a slide where a peer duplicated a slotted block finds
+ two and refuses, rather than guessing which.
+
+### 5.6 Out of scope
+
+Team- or deck-level custom layouts and "Save slide as layout" (the
+data leaves room: a deck-level `layouts` root map later, carrying the
+same JSON, and the ops taking an inline definition). Layouts with
+bespoke code. Restyling existing slides when a layout changes.
+
+---
+
+## 6. Rehearsal
+
+### 6.1 What carries over from the deck
+
+- Click any text on the current slide, or the notes, and type; it
+ saves as you go; the header says Savingโ€ฆ, Saved, or what failed.
+- Typing never moves the deck; `Esc` returns the clicker.
+- The phone as notes plus remote, with notes read-only until "Edit
+ notes" is tapped, so a pocketed phone does not edit.
+- A per-slide request panel whose answers show under it.
+- A history of every edit and request.
+
+### 6.2 What changes because Slides is collaborative
+
+Most of the deck's rehearsal machinery exists to work around being a
+static build: debounced saves to a strings file, a rebuild, a version
+counter, reload-on-the-same-slide, a landing record in
+`sessionStorage`, drafts held back from the reload. **Slides has none
+of those problems**: the document is live, edits are Yjs updates
+through the existing save queue, and other windows receive them over
+the deck stream. So rehearsal is mostly arrangement, not machinery:
+
+- **`GET /d/{sqid}/rehearse`** is the editor bundle in the presenter's
+ arrangement: the editable stage at the current slide and step
+ (future-step blocks dimmed and editable, ยง4.3), the next step or
+ slide as a picture, the notes as the editor's ProseMirror notes view,
+ the timer and clock, the position, and the request panel. Signed in,
+ `deckFor` (404 to a stranger), and the scriptless exception the
+ editor already has, with a `<noscript>` linking the presenter view.
+- It **starts or joins a presentation session** with `rehearsal: true`
+ (ยง3.5), so a projector window or a laptop on HDMI follows it, and the
+ keys of ยง3.1 drive both. `p` opens the projector.
+- **Notes are WYSIWYG** because they already are: `notes` is an
+ XmlFragment with the ยง2.6 schema, and the editor already binds a
+ ProseMirror view to it. Italic survives, which is the specific thing
+ the deck could not do.
+- **Saving** is the save queue's, with every guarantee `AGENTS.md`
+ lists (keepalive, gzip, refusal carry, the font wait, undo per
+ person). The deck's "draft that blocks reload" has no equivalent
+ because nothing reloads.
+- **History** is the update log: every rehearsal edit is a
+ `deck_updates` row with the person's actor, like any edit. No second
+ log. Requests carry their own history (ยง6.3).
+- **Two people rehearsing one deck** see each other's presence and
+ edits as in the editor. Only one session per deck per presenter
+ (ยง3.4), so two presenters drive two projectors.
+- **The phone layout** (under the existing phone breakpoint) shows the
+ position, timer, notes (read-only until "Edit notes"), Prev and Next
+ buttons, and the request panel; no previews and no editable stage.
+
+### 6.3 Requests to an agent
+
+The deck's panel offered **Cut**, **Moveโ€ฆ**, **Make optional** and free
+text, all as requests, because only an agent could change the deck's
+code. In Slides the first three are one op each and undoable. So the
+rehearsal panel offers them as **direct actions** (with the undo the
+editor already has) and keeps **requests** for what still needs
+someone else: free-text asks ("tighten this", "split this into two",
+"a slide comparing X and Y after this one"), plus a request form of
+cut, move and optional for when the presenter wants to flag rather
+than decide (ยง11 Q3).
+
+`slide_requests` (new table, one migration):
+
+| Column | |
+|---|---|
+| `id`, `sqid` | public id |
+| `deck_id` | the deck |
+| `slide_id` | the slide (string id; survives moves) |
+| `kind` | `note`, `cut`, `move`, `optional` |
+| `target_slide_id` | for `move`: put after this slide |
+| `text` | the person's words, โ‰ค 4000 chars |
+| `status` | `open`, `done`, `question`, `declined` |
+| `actor` | who asked, in `DeckUpdate.Actor` form |
+| `created_at`, `updated_at` | |
+
+`slide_request_replies (id, request_id, actor, status, text,
+created_at)`: one row per reply, status included, so the thread is the
+history.
+
+- Reached through `deckFor` for read and write (anyone who may edit the
+ deck may ask and answer); never on a share link, never on a
+ projector, never in the PDF. Writes go through `a.guarded` and join
+ the team-mode lapse test.
+- The deck stream gains `event: requests` with the deck's request seq
+ (advisory, like `update`), so open rehearsal windows refresh their
+ panel.
+- A request whose slide was removed stays listed, labelled "slide
+ removed".
+- **A request's text is the person's words and is data.** The MCP
+ descriptor says so; nothing in Slides acts on it.
+
+### 6.4 Out of scope
+
+Rehearsal from the anonymous remote or projector capabilities; voice
+notes; timing per slide; requests visible to share-link readers;
+notifying an agent (agents poll, ยง8.3); comments in general (ยง9's
+trigger still stands; ยง11 Q4).
+
+---
+
+## 7. Check mode
+
+### 7.1 What carries over from the deck
+
+The deck checked every slide in headless Chromium at 1920ร—1080,
+1280ร—720, 1024ร—768 and 1920ร—1200 for overflow, and for any text under
+30 px in stage pixels, plus external requests, step replay and video
+state. Its rule (from its spec): "Thirty-point type is the floor. If it
+doesn't fit at 30pt, it's something to say, not something to show."
+
+### 7.2 What changes in Slides
+
+- **No Chromium on the platform** (ยง1 ruling 4). The layout engine
+ already measures every slide with the browser's own faces and
+ reports `overflow`, `glyph`, `asset` and `unreached` warnings stamped
+ with slide and block. Check mode is that, plus two more findings from
+ the same paint list.
+- **Projector sizes collapse.** Slides draws every slide in a 1920ร—1080
+ frame and scales the whole frame (`cqw` units, `sizes.go`), so
+ overflow does not depend on the projector's resolution. What does is
+ aspect (16:10 and 4:3 letterbox the frame) and the physical size of
+ the type. So the check runs once, at the frame, and reports per
+ projector size what the smallest text becomes on that screen.
+- **Steps**: P3 means the fully built slide has the largest extent, so
+ checking fully built covers every step.
+- External requests are not a Slides concern (everything is
+ self-hosted), and video does not exist.
+
+### 7.3 What it reports
+
+`check(deck) โ†’ findings[]`, each `{slide, block?, kind, detail,
+values}`:
+
+| Kind | From |
+|---|---|
+| `overflow` | the existing layout warning |
+| `small_text` | any painted text run under the deck's floor, in frame px |
+| `slot_limit` | a slotted block over its layout's `max_chars`/`max_items`, or a `required` slot empty |
+| `unreached`, `asset`, `glyph` | the existing warnings |
+| `missing_alt` | an image with empty `alt` that is not `decorative` |
+
+The floor is `meta.min_text_px`, default **30** at the 1920 frame (the
+deck's rule). Today's smallest theme size is body `s` at about 37 px, so
+a default deck passes; the finding exists for phone-override sizes
+that leak, tables, captions and future sizes. A summary gives, for
+1920ร—1080, 1280ร—720, 1024ร—768 and 1920ร—1200, the smallest text in
+physical pixels.
+
+Results are computed from the view at a seq and cached by `(deck,
+seq)`; they are never written into the document.
+
+### 7.4 Where it shows
+
+- **The editor**: a "Check" button in the deck menu opens a findings
+ list, each linking to its slide and selecting its block. The strip
+ shows a text badge on a slide with findings.
+- **Rehearsal**: the same list, filtered to the current slide, under
+ the notes.
+- **The export status page** already lists layout warnings; it shows
+ check findings instead.
+- **API and MCP**: `slides_check_deck` (ยง8) and `GET
+ /api/v1/decks/{sqid}/check`.
+
+### 7.5 Out of scope
+
+A browser-measured check (DOM `scrollHeight` at the four sizes, run in
+the editor's own browser) to catch where the layout engine and the
+browser break lines differently: worth adding once a real deck shows a
+disagreement. Contrast checking. Checking the phone reading view.
+
+---
+
+## 8. MCP verbs
+
+### 8.1 How they fit #25
+
+#25 built one operations registry whose descriptors are the HTTP
+routes, the CLI commands and the MCP tools at once, with
+`slides_list_decks`, `slides_get_deck`, `slides_create_deck` and
+`slides_update_deck`, and one canonical edit transaction:
+revision-checked, idempotent by client UUID, receipts sealed, authority
+rechecked at the writer and per emitted chunk, team guard around it.
+**Everything here is new descriptors over that transaction and those
+reads.** No new authority, receipt, retry or emission code.
+
+- The new ops of ยง2 and ยง5 (`set_slide.optional`,
+ `set_block.step/build/slot`, `add_slide_from_layout`, `set_slot`)
+ join the canonical vocabulary, so `slides_update_deck` and the drive
+ API accept them with no change but the allowed-names list and the
+ machine schema.
+- Each write verb below is a descriptor whose handler builds a short op
+ batch and calls the same edit transaction function
+ `slides_update_deck` calls, with the same five envelope fields
+ (`team`, `sqid`, `expected_revision`, `client_id`, plus its own
+ arguments). The receipt coordinate already binds the operation name,
+ so a verb and `slides_update_deck` never share a retry.
+
+### 8.2 The verbs
+
+Reads (`slides:read`):
+
+| Verb | Returns |
+|---|---|
+| `slides_list_layouts` | the library: id, v, name, summary, slots with hints and limits, in the caller's locale |
+| `slides_check_deck {sqid}` | the ยง7 findings at the current revision |
+| `slides_list_requests {sqid, status?, since?}` | requests with replies, bounded and paged like `slides_list_decks` |
+
+Writes (`slides:write`, edit authority as `slides_update_deck`):
+
+| Verb | Compiles to |
+|---|---|
+| `slides_add_slide_from_layout {layout, after?, fills?, notes?, optional?}` | `add_slide_from_layout` |
+| `slides_set_text {slide, slot \| block, markdown}` | `set_slot` or `set_text` |
+| `slides_set_notes {slide, markdown}` | `set_notes` |
+| `slides_move_slide {slide, after}` | `move_slide` |
+| `slides_make_optional {slide, optional}` | `set_slide` |
+| `slides_add_step {slide, block, step? \| "new", effect?, items?}` | `set_block` with `step`/`build`; `"new"` is `max+1` computed by the op (not the caller), so two agents adding a step at once make two presses or one, never a refusal |
+| `slides_reply_request {request, status, text}` | a `slide_request_replies` row (not a document op; idempotent by client UUID through the same receipt table, its own operation name) |
+
+`slides_reply_request` is the one write that is not a deck op. It does
+not touch the document, so instead of `expected_revision` it takes the
+request's own `updated_at` as its precondition, and a stale one is
+`conflict`. (ยง11 Q5 asks whether the layout verbs should keep
+`expected_revision`.)
+
+Descriptions are written for a mid-size model: each says what it is
+for in one sentence, names the read that gives the ids it needs, and
+for `slides_list_requests` says that a request's text is a person's
+words to act on as a request and never to execute.
+
+### 8.3 The request and reply loop
+
+1. In rehearsal, Paul files "a slide after this one that says the
+ three costs, one per press".
+2. An agent, polling `slides_list_requests {status: open}`, reads it,
+ reads the deck (`slides_get_deck`), lists layouts, and calls
+ `slides_add_slide_from_layout {layout: "items", after: <slide>,
+ fills: {...}}`.
+3. It calls `slides_check_deck`, fixes a `slot_limit` with
+ `slides_set_text`, and replies `done` with one line.
+4. The rehearsal window has already shown the new slide (deck stream)
+ and now shows the reply (requests stream). Nothing reloads.
+
+How the agent learns there is something to do is out of scope: it
+polls. A push (a webhook, a Paseo message) is a later decision.
+
+### 8.4 Tiers, as #34 sorted them
+
+- Tier 1 (reword, reorder, cut, optional): `slides_set_text`,
+ `slides_move_slide`, `slides_make_optional`, and `remove_slide`
+ through `slides_update_deck`. A small local model can do these.
+- Tier 2 (new slides from layouts, step sequences):
+ `slides_add_slide_from_layout`, `slides_add_step`, with
+ `slides_check_deck` as its feedback.
+- Tier 3 (bespoke animation, diagrams, source-checked claims): no verb.
+
+### 8.5 Out of scope
+
+Push notification of requests to agents; asset upload through MCP
+(#25 left it out and so does this); presenting through MCP (an agent
+starting or driving a talk); layout authoring through MCP.
+
+---
+
+## 9. Order of work
+
+Each slice ships alone, through the gate, reviewed, and is useful
+without the next.
+
+1. **Steps and core/full in the model and on the projector**: the five
+ keys' worth of ยง2 that steps and optional need (`step`, `build`,
+ `optional`), rendering and `LayoutAt`, the projector and presenter
+ showing steps, position by slide id, the key table, the inspector
+ controls. Fixtures and vectors.
+2. **Presenter sync and offline**: BroadcastChannel and Lamport stamps,
+ the session row and event changes, shared timer, prefetch, the
+ service worker, "Ready offline".
+3. **Rehearsal**: `/d/{sqid}/rehearse`, rehearsal sessions, direct
+ actions, requests table and panel, the requests stream event.
+4. **Layout library**: `layouts/library.json`, `slot`/`from`, the two
+ ops on both sides, the picker.
+5. **Check mode**: findings, editor list, API.
+6. **MCP verbs** over slices 1, 3, 4 and 5.
+
+Slice 6 depends on #25 being merged; the others do not touch its code.
+
+---
+
+## 10. Testing
+
+The house patterns, applied:
+
+- **Fixtures**: one data file per new op and per new key
+ (`add_slide_from_layout`, `set_slot`, `set_block` with step/build/slot,
+ `set_slide` optional); vectors regenerated; `vectors_test.go`
+ compares. Library bytes identical in core and bundle (a test reads
+ both).
+- **Rust/JS**: ranks from step numbers with gaps and duplicates;
+ `set_slot` refusal on zero or two matches; `add_slide_from_layout`
+ with unknown slot.
+- **Go**: renderer golden HTML at each step and fully built; `LayoutAt`
+ keeps extents (P3); `commandChanges` with stamps (older refused,
+ unstamped stamped); event wire names; check findings per kind;
+ requests through `deckFor`, 404 to a stranger, never on a share link;
+ the requests write route in the team lapse test.
+- **Browser** (`-tags browser`, run when touching a slide surface):
+ two windows in one profile stay in step with the server stopped; a
+ phone and a laptop pressing at once converge; the projector does not
+ change while a collaborator edits the current slide in a talk, and
+ does in a rehearsal session; steps reveal with no layout change
+ (the existing DOM probe); offline reload of a prefetched talk;
+ clicker keys typed into a notes field type and do not move.
+- **Delegated**: each verb end to end through the real HTTPS CLI/MCP
+ fixture #25 built: create, add from layout, set text by slot, check,
+ reply; retries return the first acknowledgement.
+
+---
+
+## 11. Open questions for Paul
+
+Ranked by how much the answer changes what gets built.
+
+1. **Which part first?** ยง9 proposes steps, then presenter sync and
+ offline, then rehearsal. If the next talk is soon, rehearsal and
+ layouts might matter more than offline.
+2. **Offline: in-browser cache, or an offline pack?** ยง3.6 proposes
+ prefetch plus a service worker scoped to the talk, with "Ready
+ offline" to check before unplugging. The deck's zip is the stronger
+ guarantee and a second build output. Recommendation: browser first,
+ pack only if the browser path fails at a venue.
+3. **Rehearsal's Cut, Move and Make optional: do them, or file them?**
+ ยง6.3 proposes direct, undoable actions plus a request form for when
+ you want to flag rather than decide. The alternative is the deck's
+ behaviour (always a request).
+4. **Requests as their own table now, or wait for comments?** ยง9 of the
+ main spec defers comments until Docs' comment thread lands in
+ estilo. Requests are narrower (status, kind, an agent answers).
+ Recommendation: own table now, shaped to become a comment kind.
+5. **Should the layout verbs require `expected_revision`?** #25 made it
+ required for every edit, which keeps an agent from writing over a
+ change it did not see, at the cost of one more read for a small
+ model. Recommendation: keep it required; `slides_get_deck` already
+ returns it.
+6. **Mid-talk edits from collaborators.** ยง3.5 holds the projector's
+ current slide still and picks changes up at the next slide. The
+ alternative is freezing the whole deck at "start talk". Which do you
+ want in a real talk?
+
+---
+
+## 12. Review record
+
+Draft 1, 2026-11-11, unreviewed. To be reviewed by GPT-6 Astra (at
+most three rounds, stopping at the first with no P1), then approved by
+Paul before any plan or code.