oficina / slides Public
AGENTS.md
Guidance for AI coding agents working in this repository. This is the canonical agent-instructions file; CLAUDE.md points here and duplicates nothing, because two copies drift and the drift is silent.
Slides is a presentation editor for the Oficina suite: a deck that looks like a Keynote deck on a desktop, reads like a document on a phone, presents from a laptop and is driven from a phone. One instance per team on the CARLOS platform, at slides.oficina.works for the first team. It is built beside Docs, Sheets and the suite doctrine; where a decision is already made over there, this repo consumes it rather than restating it.
Design: docs/superpowers/specs/2026-09-07-slides-design.md (revision 1, still unreviewed — §12 puts the review pass after slice 1 ships, so the reviewer gets a running instance instead of a document; ruling 12 was added during slice 2 and §2.6 rewritten with it). Plans: docs/superpowers/plans/2026-09-07-slice-1-live.md and 2026-09-07-slice-2-editor.md. Read the spec section behind whatever you touch. Read rastrillo's own SKILL.md (repo root, or in the module cache) before writing handlers or models — it is the whole app story in about 15KB, and you should assume none of it is in your training data.
The one rule
A slide is one block tree, rendered many ways (spec §0.1). The tree is the only truth. The viewer renders it, the phone reflows it, the presenter shows it, the drive API patches it, and the editor edits that same tree through the same operations — its stage is the server's own HTML for the slide, not a second rendering of it. There is never a desktop version and a mobile version of a deck, only one deck and a viewport.
Everything else follows. flow and canvas are two ways of placing the same blocks, not two kinds of slide (§2.3). The phone overrides are entries in the tree, not a second file (§2.5). The drive API is the inspector's operations with a JSON body (§7). If a change you are making needs a second representation of a deck, you have almost certainly taken a wrong turn.
What is actually built
Slices 1, 2 and 3. A deck is edited in the browser at /d/{sqid}/edit, driven through the API (docs/api.md), or arrives as the sample deck seeded on first sign-in — and comes back out as a PDF.
- Sign-in (
internal/slides/auth.go,signin.go,signin_return.go) is Keymail for an address whose domain runs Keymail and an emailed magic link for every other address — decided by the domain alone, never bySLIDES_ALLOWED_ADDRESSES, or the endpoint becomes a membership oracle. The door is the smart door (Home spec2026-11-19-smart-door.md, step 6; home/connectMIGRATING.md): rastrillo's sign-in screen (SigninScreen,SigninOneWay) drawn in estilo's door byestilo-signin-screen, one way in per page — the way this browser used last, else Continue with Oficina ID with Home configured — and "Other ways to sign in". Every state (door, chooser, Sent, the Keymail continuation, a problem, the confirm step) is that one template, in rastrillo's approved words; the tab title is rastrillo's for the state. A Keymail address, permitted or not, continues on the door (/signin?continue=, whose meta refresh leaves for Keymail; never a 303 out of the form POST: Safari appliesform-actionto it); any other gets303 ?sent=1, and only a permitted one is mailed, by a worker after the response (mailQueue), so not even the response time differs. Admission is rastrillo/auth'sAuthorize, after verification, and its refusal is the door with the refusal in the screen's app-problem slot, in the refusal's own 403, by auth'sRefusedhook (refused; never a query anyone could type). An emailed link opens on a confirm step (auth'sRenderConfirm): the door with one Sign in button, which POSTs the token back to/auth/verify— the GET spends nothing, so a mail scanner fetching the link cannot burn it. Both methods of/auth/verifyare mounted in both modes. The list is also rechecked on every request that resolves a principal, so taking an address off it signs that person out of every device and refuses their agents' tokens rather than leaving them everything they already held (spec §6.1, ruling 16, codex 6), and lands them on/signin?err=removed, which says so. On a team instance Home's roster replaces that recheck (spec §6.4, "Team mode" below). - With Home,/signinis connect'sSigninDoor,/signin/localitsSigninLocal(email only, where connect sends people Oficina ID cannot help, and every step-up),/signin/oficinaitsSigninOficina; all three behindadmittedOnly, which runs the signed-in routes' own gate on a probe (admission). A session that gate refuses gets the refusal on the plain door (never the chooser or a way's page, so Other ways still works), its cookie cleared on that response, and a remembered Oficina ID forgotten; a gate that cannot decide (a 5xx) is not a refusal. Standalone,/signindoes the same and offers email only. -MintHomeSessionremembers Oficina ID (rememberOficina), with the address connect resolved for this sign-in, only for a session the gate admits, and never carries an address over. - The page a sign-in began from is kept in Slides' sealed return memory:beginSignintakesreturn_tooff Begin's form (even when the body fails to parse), remembers it (/when absent, unsafe or/signed-out) and puts it back on Begin's redirect to the door;/auth/landed(standalone) andhomeLocalComplete(Home, in place of connect's landing/) land there once. Forget and Sign out forget it. -/signed-outoffers Forget me on this device (/signin/forget, auth'sForget); with Home the form chains on to{issuer}/forget?return=<origin>/signed-out. - Begin's own problems (?err=rate,?err=address) are answered as they are, the same for an address on the list and off it; the oldsameAnswerrewrite to Sent is gone (it told a mistyped address "We sent a link" and droppedforce=1). A step-up'sreauth=1and thereturn_tosurvive every answer. - Decks: list, create, settings, delete, three rungs (private, granted, team) per suite ruling 15. A deck opens in the editor, as a document does in Docs: the list links
/d/{sqid}/edit, and the bare/d/{sqid}is a 303 there (afterdeckFor, so a stranger still gets the 404). Who can open a deck is chosen on its share page (POST /d/{sqid}/share/access,mayChangeRung), as general access is under Share in Docs; the settings page is the scriptless title and theme form, linked only from the editor's<noscript>. - The viewer (
internal/slides/viewer.go):/d/{sqid}?slide=N, one slide per page, previous and next as ordinary links (changed in place with a script,fixtures/viewer-nav.mjs), notes in a<details>, the slides as a rail at its side from 1100px. Shaped as Docs shapes a document: the deck's title is the bar's context and Share… the bar's action; the page's own row is Edit, Present and an overflow. The owner, a team member and a stranger holding a share link all get the same page from the same template withmodeas a field, because the day those three drift is the day one of them leaks the speaker notes. - Share links (
share.go): a read-only capability, SHA-256 stored, URL shown once, revocable. A missing token and a revoked one 404 alike. - Follow-along codes (block type
qr,qrlink.go,qr/): a QR code on a slide for the audience to follow the talk on their own phones. Itsprops.urlis the follow address of an audience share link (http(s)://<host>/s/<token>?follow=1, the one shape core, fixtures anddeck.FollowAddressaccept); the box stores the address because only the token's hash is kept.POST /d/{sqid}/qr-link(mayShareDeck, as the share page) mints the link, markedAudienceonShareLinkand named so on the share page, and answers the address; the editor writes it into the box throughcommit(). render and layout draw the same modules (qr.Modules; layout's are crisp rects), with the short address under the code, but only whatfollowCodesvouches for (render.Options.QR,layout.Options.QR, nil draws none): this origin's address whose token is a live share link of this deck. On/s/surfaces the code is the reader's own link, never the stored one. Anything else is an empty frame on the editor's stage and nothing for readers. Slide caches carrylinksStamp, so a revoke changes their tags. Insert's row and the card's button are for sharers only (InsertTypes). - Presenting (
presentation.go,present/hub.go): a server-side session with a pairing code, the fullscreen surface, the presenter view with notes and a clock, the phone remote, and audience follow from a share link — which stays on/s/{token}routes, stream included, so revoking the link ends the follow. The session sqid is a projector address and is never rendered onto a follow page (spec §3.4, codex 5). - The editor (
editor.go,templates/editor.html,static/editor.css, and the committed bundle built fromfixtures/): the strip of server-rendered thumbnails, the stage, the inspector for the slide and the selected block, the deck's settings in a dialog under File, text edited in place through ProseMirror bound to the server's own HTML, canvas drag and resize with snapping, the desktop/phone switcher whose phone-view edits becomeset_phoneoverrides, undo scoped to the person who made the change, presence, and image upload when a store is bound. - Live sync (
live.go,live/hub.go,snapshot.go): the update log served by cursor, an SSE stream of advisory seqs and whole presence sets, and a snapshot every 200 updates so opening a long-lived deck is not a full replay. - Assets (
assets.go,svg.go): presigned PUT browser-to-bucket into a staging key this app mints (never an address the client named), registration that resolves the upload receipt for it, re-reads and sniffs what actually landed, sanitises an SVG, and promotes the bytes to a final object keyed by their own hash — then three capability-checked routes serving them back. The receipt is theasset_uploadsrow (models.go, migration0008_create_asset_uploads.sql): one deck, one actor, single use, two hours. A ref alone registers nothing, and no PUT is ever signed for an address something is already served from (spec §2.7, codex 1 and 2). An agent uploads with the bearer instead (agent_assets.go,POST /api/v1/decks/{sqid}/assets): the bytes are the body, at most 20 MiB, a PNG, JPEG or WebP by its magic thatimage.DecodeConfigreads withinmaxAssetDimensionandsvg.MaxDecodePixels(no SVG; the header only, not a full decode), stored under their hash, thedeck_assetsrow written, thenregister_asset(with width, height and?alt=) applied as the agent throughapplyAgentOpsFrom, which builds the batch from the document it lands on. The same bytes twice are one asset: 200 with the existing id, nothing written. - The font library (
library.go,fonts.html, estilo'stypefacepackage):/fontsis a person's own set of fonts, uploaded through the app (TTF, OTF, WOFF, WOFF2;typeface.Inspectreads the family, weight, italic and whether a face may go in a picture or PDF, asPictures()). Limits: 10 MiB a file, 16 faces to a family, 32 families.typeface.Inspectalso refuses tables that overlap or sum past the file, and checks outline structure (loca against glyf and maxp, CFF/CFF2 INDEXes; not a WOFF2's transformed glyf). A name is made bydeck.FontCSSName's one pattern, the one the document and layout take; a catalog family's or a CSS generic keyword's gets a number. Uploads and deletes takefontMu, so the limits hold under two at once. A file lives in the object store under its own hash, andtypeface.Headersserves it with private caching; the page shows each family's name set in it, from/fonts/files/{ref}(its owner only), and answers its families as JSON for Deck settings, which asks again when the editor's window has focus. Deck settings picks a library family (POST /d/{sqid}/fonts:DeckFontrows and themeta.fontFilessetmeta). The deck names the family, not the library: a listed family sharing a file with it keeps its name, any other gets a number while a listed family has the name in any case, so two people's Brands are Brand and Brand 2. Agents can writemeta.fontFilesbut cannot upload bytes: a ref is served only through a deck that recorded it and lists it (/d,/s,/p.../fonts/{ref};/dalso serves a recorded ref to its library owner, so a pick loads before its setmeta lands). The TrueType parser infonts/reads untrusted bytes, so every offset and count is bounds-checked. - The layout engine and thumbnails (
layout/,svg/,fonts/,thumbs.go): every slide measured into a paint list with the same embedded Liberation faces the browser sets it in, written as an SVG, and served as{surface}/slides/{id}.svgfrom all four capabilities. A deck stack that names an uploaded family first is set in its static TrueType faces (meta.fontFilesfaces markedpictures: static TrueType whose flags allow subsetting), read from the object store (fontstore.go) and parsed once per render throughlayout.New, a face chosen for 400 and 700 as CSS font matching chooses (a bold with no bold face is the face CSS picks, unthickened); anything else (variable, CFF, no subsetting) falls back down the stack. A thumbnail carries each uploaded face it draws in as an@font-faceof a web subset (fonts.WebSubset,svg.Options.EmbedFonts), since an SVG in an<img>sees no page font; the export hands the PDF module those faces renamed to the deck's CSS name (fonts.Renamed, never more than twice the file), because the module matches the name inside a font. The editor strip and the remote are that picture. The presenter window is not: it draws live slides (see the last section); only sessions begun before positions keep the pictures. - PDF export (
export.go,exports.go,pdfcore/,core/pdf/):POST /d/{sqid}/exportstarts a rastrillo job, the status page polls itself (and works with scripts off), and the file comes back fromGET /d/{sqid}/export/{job}.pdf. One page per slide, optionally the speaker notes as pages of their own, text as embedded glyphs, images inlined. The API twins arePOST /api/v1/decks/{sqid}/exportand its two GETs. The file is answerable for an hour and the status page says so for the whole hour: rastrillo/jobs forgets a finished job after ten minutes, so the page, its fragment and the API's status all fall back to this app's own held record (exportFallback) rather than 404ing while.pdfat the same address still works.
- The assistant (
assist.go,assist_ops.go,assist_prompt.go,config_ai.go,assist/,fixtures/assist.mjs,fixtures/assist-panel.mjs): an Assistant button in the editor's header, present only withSLIDES_AI=on. The model proposes, the editor applies.POST /d/{sqid}/assistsends the request and a compact view of the deck (its slides, its assets each with a kind — image, video, poster or still — and its scenes, bounded: ids, names, states, words, code ref and data size, the data itself only up to 4 KiB) to TensorX (OpenAI-compatible, host pinned, memoria's provider posture), rebuilds what comes back op by op (only the drive vocabulary less the asset ops, only each op's keys, every new id minted here from the model's placeholders, the chosen scope enforced), applies it to a scratch copy through the core (Ops,Check,deck.Parse; never the log), refuses an answer that would empty the deck, gives the model one repair round with the reason, and answers the checked batch. The browser applies it throughcommit(), so it is the person's own change: font-gated, one undo step, saved through the queue, live to everybody. Deck text is untrusted input to the model; the op rebuild and the scratch check are the boundary, not the instructions. Config:SLIDES_AIis exactlyonor unset (anything else refuses boot; a key alone turns nothing on),SLIDES_TENSORX_API_KEY,SLIDES_AI_MODELS(comma-separated ids, first preselected, defaultdeepseek/deepseek-v4-flash-0731), andSLIDES_AI_DEV_BASE_URL(another OpenAI-compatible base for a local run; refuses boot outside development). Nothing about a deck is logged.
Not built, and don't write around their absence: charts from Sheets, embeds, an MCP adapter, aspect ratios other than 16:9, comments, and version history. Those are the triggers in spec §9.
Clips are built (internal/slides/clips.go, clipcache.go, fixtures/clip*.mjs): a clip block plays a video asset, play being press, loop or once. The video is an MP4 or WebM of 50 MiB at most, its kind read from the bytes, uploaded and registered like a picture with two more fields: poster, the ref of a PNG or WebP of its first frame (4 MiB, drawn by the uploader's browser), and duration. Clips play muted, inline and without controls; wherever a video does not play (scripts off, thumbnails, the PDF, the presenter's Next, the remote, the editor's stage, and for a reader who asked for less motion a loop, a once or a press not yet made) the poster shows. Videos are served in ranges from an on-disk, content-addressed cache of 1 GiB, read from the store once; a presenting window warms clips one at a time, up to 300 MiB; and a staged video goes back only to whoever staged it (GET /d/{sqid}/uploads/{ref}). There is no sound, no trimming and no embed from another site. docs/api.md is the reference for the API, written for a person and an agent both.
Scenes are a deck's own HTML documents, each drawing a set of named states, run in a sealed frame and carried from slide to slide. docs/scenes.md is the contract a scene keeps, with a worked example in docs/scenes/example.html (its browser test is TestTheExampleSceneAnswersReady), and the steps for building a deck with a scene through the API: the bundle, one batch for the scene and its slides, the version, a still per state. The code: core/src/scene.rs and internal/slides/deck/scenes.go (the document and the version), internal/slides/scenes.go and scenestills.go (the sealed routes and the stills), fixtures/scene-*.mjs (the frame, its layer and the editor's card).
The deployment's object store is bound (2026-11-11, bucket carlos-store-bds-slides) and served through the app, not presigned: cmd/slides wraps it in slides.ThroughApp, so the browser uploads to PUT /d/{sqid}/uploads/{key} and pictures and exports stream back from this app. The presigned path below is the design and still what a presigning store would take, but the page's CSP (default-src 'self', img-src 'self' data:) refuses a browser PUT to the bucket and a picture from it, and the bucket has no CORS for this origin; going direct needs both changed. With no store bound at all the upload endpoints answer 503 and the editor's image field says so.
Layout
internal/slides/ is the app in SKILL.md's five-file shape — models.go, migrations.go plus migrations/, app.go, handlers.go, render.go plus templates/ — with one file per screen area beside them (auth.go, decks.go, viewer.go, share.go, presentation.go, sample.go, live.go, editor.go, snapshot.go, assets.go, svg.go, thumbs.go, export.go, exports.go, api.go, agents.go, agent_assets.go, assets_embed.go, and team mode's team_*.go) and one package per concern nested underneath: core (the wazero host), deck (Go types for the core's JSON view), render (slide HTML), layout (the paint list), svg (the paint list as a picture), fonts (the embedded faces and their metrics), pdfcore (the PDF module's wazero host), present (the presentation SSE hub), live (the deck's own hub: seqs and presence), teamstate (team mode's Home-only users). internal/slides/static/ holds the vendored stylesheets and the committed editor bundle. core/ at the repo root is the Rust crate. manifest/ and gen/ are rastrillo's declarative path, unused here: gen/ and api/v1.json are what rastrillo generate writes for an app with no resources (empty stubs nothing imports, plus gen/locales, the English pack), committed so that rastrillo doctor is clean. Keep it clean on every rastrillo upgrade: doctor --fix, migrate-templates -write internal/slides/templates (templates take their localizer first, $L), generate, then doctor exits 0.
core/pdf/ is a second Rust crate beside the CRDT core: slides_pdf.wasm wraps krilla and krilla-svg and takes one SVG per page plus the Liberation TTFs, and writes one PDF with the text as subset, embedded glyphs. It wrapped svg2pdf until 2026-09-09; that repository was archived on 2026-07-10 naming krilla as its successor, and the swap kept the ABI byte-identical (spec §1 ruling 13). internal/slides/pdfcore hosts it under wazero with the same containment as core but a simpler shape — a fresh module instance per Render, discarded afterwards, under a sixty-second job deadline rather than the CRDT host's one-second call deadline. internal/slides/export.go is the pipeline over it (layout.Layout → svg.Encode with every image inlined → Render), including the notes pages, which are paint lists typeset here with the fonts package. scripts/build-pdf-wasm.sh builds the module; the artifact is committed at internal/slides/pdfcore/testdata/slides_pdf.wasm and the gate checks its input stamp and, on Linux amd64, its bytes, exactly as it does the CRDT core's. internal/slides/exports.go is everything around that pipeline: the screens, the job, and the bytes.
Both wasm hosts cap the memory one instance may take — 512 MiB for pdfcore, 256 MiB for core (defaultMemoryPages in each) — because both run a parser over bytes a deck author controls on an instance shared with everything else. Past the cap the guest's allocator aborts and the host reports an ordinary error, which is what the two …PastTheMemoryLimitIsAnErrorNotACrash tests hold.
fixtures/ at the repo root is the browser half and the contract that keeps it honest: the editor's ES modules, their node --test tests, build-bundles.mjs (esbuild, output committed), and generate.mjs with data/ and vectors/. It is a Node package with a committed lockfile; node_modules/ is not.
The seams
A handful of functions carry most of the app's invariants. Go through them rather than around them; a new handler that reaches past one is the usual way a rule stops holding.
currentUser(w, r) (auth.go) maps sessions.Current(r).Subject — an email address under rastrillo/auth, never a user id — to the users row, making it on first sign-in. It is also the admission recheck: an address no longer on SLIDES_ALLOWED_ADDRESSES is signed out here (offboard — every session row for it deleted, live talks ended, share links left alone) and told so on the sign-in page, which is why it takes a ResponseWriter and answers sessionOffboarded rather than a bare false. The bearer middleware does the same for an agent's operator. Without both, taking an address off the list removed nothing that address already held (spec §6.1, codex 6). actorFor(u) turns the row into the person:<id> string every write records (§6.2); the API's bearer middleware produces agent:<id> the same way, and a presentation remote produces remote:<session>, the one deliberately anonymous actor (§6.2).
visibleDecks(ctx, viewer) is the read scope: owner, team rung, or a grant. Its OR chain is parenthesised inside the string on purpose — every caller chains another Where on, and an unparenthesised OR widens it to "or this deck is on the team rung", defeating the whole seam by operator precedence. deckFor is a deck the person may read; ownedDeckFor is one they own. Both answer 404, never 403, so a stranger holding a sqid cannot learn whether it is real.
openDeck instantiates the Y.Doc: a fresh wasm module, the newest deck_snapshots row applied, every update after it replayed in seq order, and the JSON view that produces. The handle is the caller's to close. A snapshot is derived data and never the truth (snapshot.go) — the log alone still is the deck, so a missing or unreadable snapshot means a slower open and nothing else.
applyOps and appendUpdate are the two write paths into a document, and the only two. Each puts the update row, the seq bump and any deck-row columns in one transaction with the seq as an optimistic lock, so the row and the log commit or roll back together, then publishes the new seq and takes a snapshot if it crossed the boundary. They differ in one line and in what a failure of it means: applyOps (editDeck wraps it with the handle's life and one retry on errDeckBusy) hands the core an op batch this app wrote, so a refusal is a bug; appendUpdate (live.go) hands it bytes off the wire, so a refusal is ordinary and comes back as a 422.
"Refusal" there is two checks on the fresh handle, both before the transaction opens, and they look at different things:
Handle.Check(ctx)— the core'sslides_core_check(ABI 2,core/src/check.rs, mirrored infixtures/check.mjs) — walks the document: every notes fragment, every blocktext, every table cell, and refuses anything outside §2.6 (a formatting attribute other thanb i c h href, a non-paragraphchild, an element or fragment inside a paragraph, an embed). This is the gate that has to exist, because y-prosemirror 1.3.7 deletes anXmlTextwhose attributes it cannot map to a mark: the words are lost in the browser while the server sees nothing wrong (spec ruling 19, codex 3).deck.Parseon the JSON view — the projection — which is what keeps a shape the host's typed structs cannot read out of the log.
The projection alone is not enough and that is the whole point: the view is deliberately tolerant (core/src/view.rs, mirrored in fixtures/view.mjs) and reads straight past an unknown mark. Bytes off the wire can put any shape at any key, and what these two keep out of the log is what would otherwise brick every openDeck after it, or quietly eat somebody's sentence. Nothing else may append to deck_updates.
schema::ordered_maps (core/src/schema.rs) and orderedMaps (fixtures/ydoc.mjs) are the reading order, and there is one of them because there is one idea. Both ordered arrays in the document — the deck's slides and a slide's blocks — are SETS, and the order is an order key on each map in them: a number, absent ranking at the array index, array index breaking ties (spec §2.1–2.3, rulings 18 and 21, codex 4). A reorder writes that key and never moves an array entry, because moving one means deleting the map and inserting a copy, and every edit a peer had in flight against the original — a sentence being typed into a block, or into any block of the slide — is then addressing a deleted type and is lost on merge. move_slide, move_block, add_*, duplicate_slide and canvas-to-flow all go through place_entry/placeEntry. The view sorts by the key and does not expose it, so deck.go, render/, layout/, the viewer, the presenter and the exporter all read one sequence and none of them knows the key is there — which is also why adding a reader is not a reason to teach it about order.
render.Slide(d, index, viewport) is the only place slide HTML is produced, for every surface — the viewer, the presenter, the API's .html twin, the editor's stage and its thumbnails. It builds markup by hand rather than templating it, because html/template cannot take a dynamic tag or attribute name; read the package doc comment for the four invariants that make that safe before adding a block type.
render.SlideWith(..., render.Options{AssetBase}) is that function when the slide has pictures on it, and every real surface has to pass its own base: /d/{sqid}/assets signed in, /s/{token}/assets over a share link, /p/{session}/assets while presenting. One slide is rendered on surfaces authenticated four different ways, and the <img> has to be fetchable by whoever is looking at it. Slide stays for callers that have no pictures to worry about (a test, a fixture) and falls back to render.DefaultAssetBase, which is deliberately a path nothing is mounted at: forget to say which surface you are and you get visibly broken images rather than a URL that quietly works from the wrong place. Note also that the <img src> carries the asset's ref, never its id — the id is the deck's own name for it and stays out of URLs.
serveAsset (assets.go) is the one body behind all three of those routes, and the check inside it is the security property, not a formality: a ref is a content address, so knowing one is knowing the SHA-256 of somebody's file. It resolves the deck and confirms this deck's assets map refers to this ref before it serves a byte; without that, any capability for any deck would fetch any object in the bucket. It costs an openDeck per image request, which is known and noted rather than forgotten. It also requires a deck_assets row for the pair, written only by registerAsset (or the agent's upload, apiPostAsset) after it read, sniffed and sanitised or decoded the bytes: register_asset is an op any member can apply with any ref, and a presigned PUT lands whatever the browser sent, so the map alone would let an unverified object be served.
layout.Layout(d, index) is the other renderer, and the rule about it is the one in the plan: the paint list is the only input to SVG and to PDF. Nothing under svg/, pdfcore/ or export.go reads a deck. Layout measures with the same embedded Liberation faces the browser sets the slide in (fonts/, served as woff2 from static/fonts/ and put on the page by the font gate, below), so the two agree on everything but where a line breaks. Every warning it makes carries the slide it is about (layout.Warning.Slide), because the export's status page lists the warnings of a whole deck and a line that cannot name its slide is a line nobody can act on.
Export(ctx, view, ExportOptions) (export.go) is that pipeline — layout.Layout → svg.Encode with every image inlined → the module's Render — and exports.go is everything around it. Two things there are worth knowing before touching it. The PDF module is compiled once per app, lazily, and closed with the app (pdfRuntime), because compiling it costs the best part of a second and most processes never export. And with no object store bound the finished PDF is held in memory for an hour, capped at 50 MiB per deck and 200 MiB per instance: over either cap the job fails with a sentence the person can act on rather than the instance failing with an OOM nobody can read. When a store IS bound the same job uploads it and drops the held bytes, and the download route 302s to a presigned GET. Both paths are in one handler (serveExport) so neither can rot.
present.Hub is the in-memory fan-out for a live presentation. Its events are whole state, never deltas, so a subscriber that falls behind is dropped and reconnects rather than having events skipped — a skipped event leaves a projector showing slide 4 for the rest of a talk with nothing to notice it.
live.Hub is the same shape for a deck being edited: a seq, which is advisory ("there is something at least this new" — the bytes come from GET /d/{sqid}/updates?since=), and the whole presence set, which is not. Presence lives there and nowhere else — it is not document state, so it never reaches the log, is never snapshotted, and is gone with the process.
The wire the editor speaks
Docs' live-sync design, adopted as written (spec §3.3). Four routes, all in the signed-in group, all behind deckFor, all 404 for a stranger.
GET /d/{sqid}/updates?since=N answers application/octet-stream: every update after seq N, each framed as a 4-byte big-endian length then the bytes, in seq order. Slides-Seq is the highest seq in the body, or N when the body is empty — derived from the bytes in hand, never from a second MAX(seq) query, which could see an update this response does not carry and leave the client holding a cursor for bytes it never received. At since=0 the answer may start from the newest snapshot, and Slides-Snapshot: <seq> says when it did.
POST /d/{sqid}/updates takes one Yjs v1 update, 1 MiB cap. It goes through appendUpdate, is stored with the poster's actor, and answers 204 with Slides-Seq. A refusal from the core is a 422 and an ordinary event: these are bytes off the wire, not a batch this app wrote.
GET /d/{sqid}/stream is SSE and carries no document bytes at all: event: update with data: <seq> (advisory — go and fetch), event: presence with the whole set as JSON, : ping every 15 s, one of each on connect, 5 minute TTL. Whole state rather than deltas, so a subscriber that falls behind is dropped and reconnects.
POST /d/{sqid}/presence takes {client, slide, block} every 20 s and on change. The server stamps the name and the colour from the users row; a client that sends its own is ignored, or presence becomes a place to write somebody else's name. Two missed heartbeats and the sweeper drops it.
The fixtures rule
fixtures/ops.mjs and core/src/ops.rs are two implementations of one op vocabulary (spec §7.2), because the browser writes the document the core reads. fixtures/data/*.json are op batches; node fixtures/generate.mjs runs each through the JS side and writes vectors/<name>.yjs (the Y update) and vectors/<name>.view.json (the JS view of it). internal/slides/core/vectors_test.go loads the same bytes through the core and requires the same view, and also runs the same op batch through the core's own Ops and compares again. generate.mjs also runs checkDoc over every vector before it writes one, so a vector that would not pass the write gate never gets committed in the first place.
So: an op changes on both sides or on neither. Regenerate in the same commit as the change. Never edit a vector to make a test pass — a vector that was quietly adjusted leaves the Go test comparing the core against a JS implementation that no longer exists, and it passes while the two sides drift. The gate regenerates and diffs.
It has already caught something real. href is stored as the one-key map {"href": url}, and the ProseMirror marks are named b, i, c, h, href — spec §1 ruling 12, §2.6. y-prosemirror 1.3.7 has no hook to map mark names to Y attribute names: it writes attributes[mark.type.name] = mark.attrs and reads schema.mark(attrName, attrValue). So the mark's name has to be the attribute's name, and a plain-string href throws inside schema.mark — and y-prosemirror deletes the XmlText when a read throws, which loses the text and not just the link. Naming the marks after the attributes makes the mapping the identity and keeps mapping code out of the editor. The writer is exact; both readers are tolerant, taking any truthy value for b/i/c/h (y-prosemirror writes {}) and either the map or a plain string for href (documents written before the ruling).
How the editor is put together
Read this before changing anything under fixtures/.
The browser is not a second renderer. The stage shows the server's own HTML for the current slide, fetched from GET /d/{sqid}/slides/{id}.html?vp=desktop|phone|thumb, and the client binds a ProseMirror EditorView into each text block already in it. After any structural change lands, the slide is re-fetched. Thumbnails come from the server too. If you find yourself building slide markup in JS, stop.
Structural edits go through fixtures/ops.mjs's applyOps — the same vocabulary the API takes — inside one Y transaction, and reach the server as ordinary Yjs updates through the save queue. Undo is a single Y.UndoManager over the four roots (ydoc.mjs's undoScope: slides, meta, assets and scenes) with this client's origins tracked, driven directly rather than through yUndoPlugin (whose view hook destroys a manager shared by many views the moment the first view goes). commit() calls stopCapturing() first, so each batch is its own undo step.
editor-entry.js is wiring and nothing else; every other module under fixtures/ is one concern and is meant to stay under 300 lines — one does not: canvas.mjs (drag, resize and snapping are one concern and run to about 335), which is noted rather than split. live-updates.mjs, save-queue.mjs and resync-controller.mjs are Docs' modules copied verbatim with a header saying so — this is the second implementation, and extracting them to something shared is slice 4's problem, not yours. save-queue.mjs has since changed here first (its header says how): one save on the wire at a time, each edit numbered, flush() resolving once every edit made before the call is answered (edits made during it are not waited for): true if all were saved, false if one was refused; ok said only when nothing is owed, saving while an answered save leaves more queued. Docs has the same queue (#87).
The bundle is built by hand and committed:
cd fixtures && npm ci && node build-bundles.mjsassets_embed.go resolves editor.<16 hex>.js out of the embedded static/ at package init and panics unless there is exactly one, so a build that stopped emitting one, or a merge that left two, refuses to boot rather than serving an editor that disagrees with the server.
Traps
- Never call
sessions.UserID. Under rastrillo/auth the Subject is the email address, so it answers(0, false)and would scope every owned query touser_id = 0. Map the address to the row first. - Neither committed wasm is rebuilt for you.
go:embedwill happily embed a staleinternal/slides/core/testdata/slides_core.wasmand the Go tests will pass against it; the same is true ofinternal/slides/pdfcore/testdata/slides_pdf.wasm. The gate checks both: on every host it recomputes a hash of each module's inputs (scripts/wasm-stamp.sh) and compares it with the.stampcommitted beside the wasm, and on Linux amd64 it also rebuilds andcmps the bytes. When it fails, runscripts/build-wasm.shorscripts/build-pdf-wasm.sh, copy the module fromcore/targetorcore/pdf/targetinto itstestdata/, and commit the wasm with its.stamp, rather than arguing with it. - The core ABI is version 2 and the host's check is exact-match. Add or change an export in
core/src/abi.rsand you bump bothslides_core_abi_version()incore/src/lib.rsandabiVersionininternal/slides/core/core.go, in the same commit, or the host refuses to instantiate the module — which is the point: it turns "unknown export" deep inside a request into a refusal at load time. Version 2 is whereslides_core_checkarrived (codex 3). Doc::new()andDoc::with_client_id()are banned in the Rust core (clippy.toml) — both draw entropy this wasm build has no safe source for. UseOptions::with_guid_and_client_id. A doc comment alone was got around more than once, which is why it is a lint.- The committed editor bundle is not rebuilt for you either. Change a
.mjsunderfixtures/andinternal/slides/static/editor.<hash>.jsis stale until you runnode fixtures/build-bundles.mjsand commit what it writes. Nothing builds it at run time and CI does not build it for you — the gate rebuilds and diffs, which is a check, not a fix. - A stale vector passes.
vectors_test.gocompares the core against whatever is committed underfixtures/vectors, so a vector nobody regenerated makes it compare the core against a JS implementation that no longer exists. Runnode fixtures/generate.mjsin the same commit as any op change. - Exactly one directory under
internal/.rastrillo migration checkrequires it, which is why every package is nested underinternal/slides/(core,deck,render,layout,svg,fonts,pdfcore,present,live) rather than sitting beside it. - A job outlives its request, so it cannot hold one. The export's sentences — its name, its progress line, every failure it can report — are resolved from the catalog while the request is still here (
exportWords) and carried into the goroutine.rastrillo.Treads the locale off a request; a job that called it would either be holding a request it must not hold or answering in the wrong language. The same goes for the context: use the job's, never the request's. - A hardcoded English string is a bug. Every user-visible string is a key in
internal/slides/locales/en.toml, resolved throughrastrillo.Tat render time. Twelve locales are the suite target; this slice shipsenand leaves the keys ready. Deck titles and timestamps are data, not copy, and are correctly not keys. - Every screen but the editor works with scripts off (spec §8) — including the remote, where each button is a form that POSTs and redirects back. The editor is the one stated exception, and it says so in a
<noscript>that links the viewer. Everywhere else JavaScript is an enhancement and nothing depends on it. - Every user-facing string the bundle shows is still a catalog key. It reaches the browser as a
data-text-*attribute the template renders fromen.toml; an English literal in a.mjsfile is the same bug it would be in Go. - The page's policy loads no
blob:media.ContentSecurityPolicyis rastrillo's default barstyle-src(and a test holds it there), somedia-srcfalls back to'self'and a<video>given an object URL is refused ("rejected by URL safety check"). A clip's poster is drawn from the video's staged bytes, whichGET /d/{sqid}/uploads/{ref}serves back to whoever staged them (internal/slides/clips.go). cargo fmt --checkcoverscore/. It was not in the gate until 2026-09-07 and three files had drifted by then; they were reformatted in the same commit that added the check.
Rules the family holds hard
- Every query touching user-owned rows goes through the seams above — reads and writes, transactions included.
- Never bind a request body onto a GORM model: explicit
map[string]anyplus a.Selectallowlist. - Migrations apply at boot, once each, and are never re-run or reversed. Change
models.go, then runrastrillo migration generateand read the SQL — it may be a full table rebuild rather than anADD COLUMN. Never edit a migration that has shipped. Renames are hand-written (rastrillo migration new rename_x), because a rename is indistinguishable from a drop plus an add. - Every state-changing route is a POST behind
csrf.Protect. Destructive actions get their own confirm-page URL, never a modal. - Markup is the bare
rst-*attribute grammar (<a rst-btn="primary">), neverclass="rst-*". This app's own attributes areslides-*. - WCAG 2.2 AA with no exemptions: 24×24 targets, 320px reflow, colour never the only carrier of state,
alton every image. - Spacing is the scale's (Paul, 2026-11-22: no ad-hoc spacing). A page's blocks sit in Fiesta's
rst-stack(layout.html's<main rst-page rst-stack>, and a box, section or form with blocks of its own), withrst-sectionwhere a section opens andrst-actionsfor a row of buttons; never hand margins between blocks. Every other margin, padding and gap isvar(--rst-sp-N), or says why not with/* spacing-allow: why */: the slide itself (slides.css: the deck's cqw, percentages and its type's em, not the page's), what is drawn over the stage, estilo's inspector and menu geometry, the presenter's notes in their own em.make spacing(inmake ci) checks static/;TestEveryStylesheetIsOnTheSpacingScalechecks the templates'<style>blocks, which the tool does not read.make browserruns Fiesta's rhythm audit (TestEveryScreenKeepsTheRhythm) over every screen at 1440 and 390px, reading around the slide (rhythmCanvas) and nothing else; a new screen joins its list. A hidden input between two of a stack's blocks hides the first from the stack's rule: write hidden inputs first. A stack'sposition: fixedorabsolutechild still takes its margin: zero it. CGO_ENABLED=0throughout. The stack is cgo-free by design and the binary that ships islinux/arm64.- A save is a keepalive request, at most 32KiB, and gzipped from 1KB (
fixtures/save-queue.mjs; found in Docs, #94, 2026-10-26, and the same code here). While a link the page opened is waiting for its answer, WebKit refuses every ordinaryfetch, XHR and Blob read the page starts, at once and with nothing sent, and the page stays editable all the while; keepalive requests andsendBeaconstill go. Keepalive requests and beacons share one 64KiB quota, so the unload beacon never repeats a keepalive save already on the wire. WebKit never settles a keepalive save answered while its page is in the back/forward cache, so the queue sends again onpageshowand gives up on a save left unanswered. A save refused with no answer is "retrying" only if a probe of/healthzcannot reach the server either, and quiet retries back off to 4s. Compress throughCompressionStream's writer, never a Blob. A gzipped save answered 400, 415 or 422 (a server that does not gunzip: a rollback, or a hop that stripsContent-Encoding) is sent again uncompressed, and the page stops gzipping, before the queue, which drops a batch a 4xx answers, sees it. Corrupt gzip is a 400 here as in Docs, not the 422 of an update the core refuses. - Slides drains its streams on SIGTERM (
internal/slides/drain.go,cmd/slides/main.go).net/http's graceful shutdown cancels no request, so an open editor or projector held it for rastrillo's whole ten seconds and the process exited 1, as Docs' did on 2026-10-26.rastrillo.Serveowns the signal and has no hook, so Slides registers its own. A stream opened while stopping gets a clean end with aretry:delay, never an error status, which would end a projector's EventSource for good. Any new long-lived handler must also return ona.draining.done().
Team mode (roster, SLIDES_TEAM_*)
Home implementation/team-members.md Part B and implementation/teammode-package.md §7.1 ("Slides. As Sheets."), on the shared home/teammode package; Sheets main 8e28205 is the reference port. With the five SLIDES_TEAM_* variables set (_ID, _DIRECTORY_ORIGIN, _PROVISIONING_BASE64, _OPERATOR_KEYS_BASE64, _ROSTER_TOKEN; all or none, and only beside SLIDES_HOME_*), Home's roster decides standing on every request and SLIDES_ALLOWED_ADDRESSES becomes optional: if set it only admits local sign-in, empty it admits nobody locally, and it gives nobody standing. Without them nothing in team_*.go runs and every rule above stands; the one difference on a non-team instance is GET /api/team answering {"team_mode":false} (Paul's ruling on Sheets #52).
- Configuration, the marker, the runtime and the probe are
home/teammode's (team_config.go):teamSettingsverifies the record against the Home credentialsnewAppdecoded, before anything migrates;teamBootSchemareadsslides_team_requiredfirst and refuses an activated database without the same binding;teamBootmerges teammode'sslides_teamset and this repo'sslides_team_home(teamstate/) after Slides' and linkstore's;configureTeamopens the runtime with the census overhome_identity_linksandslides_team_home_users. Do not grow a private copy back. A team-mode database stays in team mode: do not "fix" a refused boot by deleting the marker (its triggers refuse that anyway). - Standing is the roster's, per request (
team_access.go):currentUserhands team mode toteamCurrentUser, which resolves the session to its user and Home subject and attachesteammode.AccessasUser.team(never a column). That replaces the allowlist recheck: Member is the team rung (own decks, team-rung decks, ownership of their own); NotMember reaches grants only; Unknown reaches grants with a partial list and answers a retryable 503 for anything else (deckFor,ownedDeckFor, create). Removed people keep their session, as in Docs and Sheets; a session whose identity cannot be read is a 503, never a sign-out. The bearer middleware does the same for an agent's operator. - Home-only members (
team_home_only.go,teamstate/): connect'sAdmit/Unlinked/HomeOnlyhooks, set only in team mode (connect wants all three or none). A roster Member with no account here is asked to choose first (connect's choose page,/account/home/choose, drawn byhome_link.html): "Connect my existing account" goes to the email-only door, "I'm new here" gives them an addresslessusersrow (email NULL), and the sample deck. Identity, never standing. They are shown as "Oficina account …xxxx" wherever an address would be (homeOnlyLabel). - Every write is guarded inside its own transaction (
team_guard.go):deckFor/ownedDeckFordecide whether a write may start,teammode.Guardre-checks standing before and after it in the writer transaction.applyOps,editDeck,appendUpdateandcreateDeckRowtake awriteGuard; app writes go througha.guarded.deckGuardfor a write any reader makes (a grant carries it without standing),memberGuardfor create and every owner action. Refusals answer throughguardRefused. Nil outside team mode, and the write is then its old path exactly.TestTeamEveryWriteRouteRefusesALapseBeforeCommitlists every write route and reads the database back; add yours to it. - Streams and talks re-decide. The deck stream re-asks before every delivery and when a Member lease runs out (
teamStreamAccess). A presentation stands on its presenter's reach (team_present.go): every/p/…request and every projector or follower delivery re-decides; a presenter who is gone ends the talk (as offboarding does), one whose standing is unknown gets a 503 on pages and the talk waits. While standing is unknown both streams are held, not ended: open, delivering nothing but comment pings, re-asked atstreamHoldRetry(the roster'sRetryAfter), and caught up when standing returns — a projector's EventSource fails for good on a 503, sopresentStreamopens under Unknown too. Without a Member lease only a grant holds — asked after the reach query, becauseStatelatches. - Ownership and orphans (
team_owner.go; Paul, 2026-10-30, #33): an owner owns their deck only while Member. On an orphan — a team-rung deck whose owner the roster says is gone — a roster owner may share it and change its title and theme, and may not delete it or change its rung. One predicate per power (mayShareDeck,mayRetitleDeck,mayChangeRung,mayDeleteDeck), passed toownedDeckFor: an owner screen asks for the one power it needs. A departed member's private deck is nobody's orphan. - Lists under Unknown (Paul, 2026-10-28): the deck list shows the grants with a notice (
teamPartial, asked after listing, never for NotMember); the dashboard feed and the API's JSON list are unavailable instead, since neither can carry the notice. - No object store on team instances. When one is bound, presigned GETs are capped at the standing they were minted on (
presignTTLFor).
Fonts: never a flash (Paul, 2026-10-26)
"No flashing, ever!" Slide text is never painted in one face and then another; a visible gap of invisible text counts too, and so does a layout that moves after the slide is shown. This is Docs' design (polish-audit/fonts/NO-FOUT.md, oficina/docs fontgate.go and fixtures/font-session.mjs, nine review rounds) on Slides' model; read Docs' AGENTS.md fonts section for the reasoning behind each rule.
- No stylesheet declares a web face.
slides.cssused to, withfont-display: swap, which is a flash by definition. The three Liberation families exist on a page only once the font gate has loaded all four styles of one and added them todocument.fontstogether (fixtures/font-session.mjs). Every stack names its system faces after the Liberation name, so a page with no script, or whose gate never arrived, is in those system faces for the whole visit: nothing held, fetched for the text, or swapped. - Families, not faces.
render.FamiliesUsedis the deck's: every family its heading and body stacks name (the theme's, ormeta.fontswhere it passessafeFontStack), anywhere in the stack, and Mono if any slide carries code (a code block, or a code mark in any block's text or table cell).fixtures/font-families.mjsis the browser's copy, held to the same answers byfixtures/vectors/font-families.json(both sides read it; hand-written, like Docs' font-stacks.json — a case changes with the rule on both sides in one commit). Speaker notes are drawn in the chrome's face and never count. - A deck's own fonts (
meta.fontFiles) are families too, keyed"u:" + cssin the manifest'suploaded(left out when there are none, so an existing deck's manifest is byte for byte what it was). One is needed when the heading or body stack leads with its css name (render.UploadedUsed;familiesOfViewreturns its key after the catalog's); one only listed, or named later in a stack, is not waited for and stays out ofdocument.fonts. Each face is fetched under the page's own base (/d/{sqid},/s/{token},/p/{session}plus/fonts/{ref}), in its ownformat(), with a variable face's weight as its range ("100 900");FontFacegets the name unquoted (it takes it literally). Same preloads, deadline and commit as the catalog's. In the editor every change is checked on its scratch copy (editor-fonts.mjs'sfamiliesAfter): an uploaded family the changed deck names — this person's pick, a collaborator's — is learned from it (font-session.mjs'slearn, under/d/{sqid}) and the change waits for it like any family it brings in; one the deck already shows that the tab never learned is committed where it is. An uploaded family is known by its name and its set of faces: a new set (a bold added, the family picked again) is learned again, waited for, and put on in place of the old set in one task; undo and redo swap sets with the change (afterHistory). Readers learn too: the viewer's in-place paging andstatic/present.jslearn the incoming page'smanifest.uploaded, and the talk payload carriesuploadedfortalk-store.mjs(learnUploaded), so a font the deck takes on mid-visit is waited for, not fallen back from./d/{sqid}/fonts/{ref}serves a recorded ref the deck does not list yet to the person whose library holds it, so a pick can load before its set_meta lands. A library never gives a family a catalog family's name or a CSS generic keyword (library.go'sreservedFontName): those get the collision suffix. - The page (
fontgate.go,layout.html's font-head, on the viewer in every mode, the projector and follow view, and the editor): in<head>, ahead of every stylesheet, one preload per face of every family the whole deck uses (exact: no more, no fewer, and the gate's own load uses them),<meta name="slides-fonts">with the manifest (the needed families, every family's faces, the theme stacks), the hold (fixtures/fonts-hold.js, a blocking classic script that setsdata-slides-fonts="pending", whichslides.cssanswers by hiding every slide, with a 6 s fail-safe), and the gate (fixtures/fonts-gate.mjs, a module). The server never renders the hold. The presenter window (presenter_window.go) draws live slides at 1920×1080, scaled, so it takes the gate like the viewer. The remote, and the presenter view of a session begun before positions, still show SVG pictures and notes in the chrome's face, so they carry no gate and fetch no font. - The gate: waits for the needed families until 2.5 s from navigation start, commits any family still missing to its system fallback for the visit (it never joins
document.fonts, so it cannot swap in later;data-slides-fonts-fallbacknames it), puts the rest on, on the editor waits for the editor's first mount (settled()) up to 3.5 s, on the presenter window for the pictures of the slides it opens on (Now and Next) to decode, up to the same 3.5 s, then shows the slides once. On the editor it then prefetches the other families at idle (not with Save-Data or on 2G);data-slides-fonts-prefetch="done"marks the end. - After the reveal nothing paints in a family that has not loaded. A person's own change — an op batch through
commit()(theme, font override, code block, new slide, duplicate…), a code mark typed, pasted or dropped in a slide's text (fontGatePlugin), undo, redo — that needs a family not in is held before anything changes: the stage, strip, inspector and Slide menu goinert, the status row under the bar ([slides-fonts-status],fixtures/font-status.mjs, a polite live region with its own fixed-height row) says a font is loading, and then the change runs once, or is refused after 4 s and the row says so. Nothing is queued or replayed; a second change during a wait is refused and said; Backspace, Space and the scrolling keys do nothing on the page during a wait (WebKit's Backspace went back in history), and leaving asks first. A wait never begins in an IME composition. Content from elsewhere is never refused: a collaborator's update (checked on a scratch copy of the doc before it reaches Yjs, FIFO, after any local wait,live-updates.mjsawaits it), a resync, every slide the stage installs (stage.mjs'sbeforeInstall: the server can be ahead of the tab) and the projector's next slide (static/present.js) wait up to 3 s for a new family and commit it past that. - A wait never loses anything, and always lets go. However a wait ends — loaded, failed, timed out, or something in it throwing — the editor comes back and every waiter queued behind it is released in order, in a
finally(fixtures/editor-fonts.mjs; a refusal that threw once stalled every collaborator's change after it). And nothing replaces the views a waiting change belongs to while it waits: a stage install (beforeInstall) and a resync wait for the change, not the other way round, so a refresh already on its way can no longer throw away a paste whose font then loads. A resync rebuilds from the server but carries every local update the server has not acknowledged onto the rebuilt doc and sends it again; the diverged doc takes a fresh Yjs client ID first, since Yjs drops an update from a client whose earlier clocks it never saw (editor-entry.js). The carried updates go into the rebuilt doc before any view of it is mounted, so the words are never off the slide for a frame (fixtures/carry.mjs). Each update is judged from its own structs and delete ranges — a delete range counting as taken in part once the rebuilt doc holds its start, since Yjs deletes up to what it holds and keeps the rest pending: one of which nothing integrates (written on top of the refused text) is not posted; of one that partly integrates, only the part that did is posted, so the server holds what the page shows and nothing of it pending. Client ids while diverged come from the keeper (createKeeper, driven by the doc'sbeforeTransaction): Yjs integrates one client's structs in clock order, so one change held back would strand every later one under its id. A ProseMirror change takes a fresh id once per 500 ms window (every later ProseMirror change has its transactions to replay, so it is never stranded); any other — an undo, a redo, an inspector change — takes one of its own. A fresh id per change was quadratic over a long divergence and left a client per keystroke in the deck;carryis linear too (clocks read from the struct store, one running probe copy), andcarry.test.mjsholds its growth to linear (4000 changes against 1000). Local changes made while diverged — typing, a paste, a delete, a change that waited for its font — are kept as their ProseMirror transactions too (the one dispatched and every one the plugins appended:stage.mjs'sbindViewtakes adispatchTransaction, andeditor-entry.js'saroundDispatchholds them; transactions ySync makes to mirror Yjs are left alone), because Paul ranks a lost edit worse than a flash. When a change's updates cannot integrate — written on the refused text, or on an earlier change that could not be carried as its own updates — it is replayed: its steps mapped through the one span where the rebuilt text differs from what it was made on (the two ends moved past any overlap, as prosemirror-view'sfindDiffdoes), written back with y-prosemirror in acarriedtransaction, and that update posted. The carried changes undo in the steps they were made in: the keeper stamps each, and the undo manager stops capturing where two were made further apart than its 500 ms window. A multi-step change is mapped prosemirror-collab's way (each step through the inverses of those before it, the span, and their replayed forms), not every step through the one span map. An undo or a redo made while diverged is the undo manager's Yjs change, kept with a replay derived from ySync's mirror of it (carry.mjs'sderivedStep: one step from the mirror's before and after, set inaroundDispatchand taken by the nextkeepin the same Yjs transaction), so the resync makes it again as the person saw it — taking text away or putting it back — whatever ids the change it undoes was replayed under; that includes bringing the refused text back when an undo or a redo put it back on screen. Where ProseMirror refuses a mapped step (typing into a paragraph the refused change made) the change falls back to what of its own updates integrates — nothing, there — and the rest are carried as before: nothing posted for it, the save line saying failed, the clipboard as it was.carry.test.mjs,TestFontEnginesAWaitingPasteSurvivesARefusedSave(Claude Fable's eleven paste cases) andTestEnginesEveryChangeWhileARefusalIsPendingIsKept(mixed edits, undo, a change that cannot be kept in the middle), both in Chromium and WebKit (fixtures/engines/replay.mjs,diverged.mjs), andTestEnginesUndoAndRedoWhileARefusalIsPendingEndAsSeen(Claude Fable's seventeen undo and redo cases,undo.mjs) hold it. What is still not kept: a change whose replay cannot be made (the structural case above); a change made elsewhere in the same 500 ms id window as one on the refused text, when its own replay cannot be made either; an undo or a redo that ySync mirrors in more than one view (one across blocks), which goes as its own updates and is kept only where they integrate; and a change outside the text views (an inspector op) written on the refused text. A tab closed while diverged beacons the kept updates with the queue's bytes. Edits made between a batch leaving and its refusal arriving are still lost with it (same client, after the refused clocks). A slide made in an empty deck goes up only once its save is acknowledged (commands.mjsawaits aflush()that is true). A change that could no longer be made once its font was in is said asinterrupted, never as a font that failed. - The first reveal is the final layout. No script measures slide text, so the gate holding until the families are on is what makes the layout final; on the editor it also holds for the first mount. And the editor's stage is served in ProseMirror's own markup (
render.Options.Editing,render/editing.go: one element per paragraph in stage.mjs's tag, the trailing break in an empty one, marks nested and kept open as its serialiser does), witheditor.cssgiving it, before binding, what the editable node gets after (pre-wrap, break-word, contenteditable'sline-break: after-white-space). So an editor that arrives after the reveal binds without moving a pixel:TestFontALateEditorMovesNothingholds markup, layout and pixels equal across a 6 s late mount on generated decks carrying every empty and trailing-empty shape in every bound type. The empty presence overlay is not drawn (it changed the antialiasing of the text under it). A stored phone or both view is not applied by an editor that mounts after the slide was shown. - Slides change in place. A page load hides its slide until the gate has confirmed the faces — an empty stage between two slides. So the viewer and
?present=1(fixtures/viewer-nav.mjs, in the gate bundle) and the projector (static/present.js: a watcher's links; follow, remote and sessions begun before positions only. The presenter window and the slide windows of a positional session are driven by thepresenterbundle instead:presenter-entry.mjswithtalk-*.mjsandpresenter-*.mjs, behindstatic/presskeys.js, a blocking script that keeps the keys pressed before the bundle mounts) fetch the next page, make its families ready, decode its pictures and then swap it in one task, moving the address withpushState; Back and Forward do the same. The current slide stays until the next is complete, never a blank. The links and forms are ordinary without a script. Neighbours are prefetched and their families loaded at idle. The follow view's 5 s refresh is<noscript>only. A presenter form whose in-place answer fails reloads the page, never posts again (the server may have applied it). The projector is latest-state-wins, not a queue of every advance: every request for a slide (a watcher's link, the presenter's button, a stream message) takes the next number of one counter inpresent.js, and an answer is applied only while its number is still the newest, so a slow old answer changes nothing — not the slide, the counter or a blackout. After a change, focus stays on the control that made it (the same pager link or button), or goes to the slide when that control is gone, and "Slide N of M: title" (the page'sdata-announce) is said through a politerole=statusregion that is in the page from the start ([slides-announce]). - Leaving a page lets go of its streams (Docs #86, dadf9c1). Chrome and WebKit keep left pages in the back/forward cache; each one held its EventSource, and after five the next page stalled on HTTP/1.1's six connections.
live-updates.mjs'spageLifecycle(Docs' copy) andpresent.jsclose every stream onpagehide, open none while away, and on apageshowfrom the cache reopen on the next task (WebKit fails one opened inside it) and catch up. The font and viewer prefetches stop too.TestLeavingAPageLetsGoOfItsStreamruns the editor, projector, follow view, presenter and remote in Chromium with its cache on (fixtures/engines/leaving.mjs) and in WKWebView (leaving-webkit.swift, built with swiftc). - The files:
static/fonts/*.woff2are Docs' lossless woff2 of the same TTFsfonts/files/holds for the engine and the PDF (decoded, onlyhead's checksum and flag bit 11 differ, as WOFF2 defines);TestServedWebFacesAreTheseFacesholds each header to its TTF. The TTFs instatic/fonts/stay served for pages cached before this. - Tests. Node:
font-session.test.mjs,font-families.test.mjs,font-uploaded.test.mjs,editor-fonts.test.mjs(in the gate). Go:fontgate_test.go(which pages carry the gate, exact preloads),fonts_test.go. Browser (go test -tags browser -run Font ./internal/slidestest/), through the production serving stack with font files slowed or refused: a DOM probe on every frame and DOM change fails on slide text visible in a face that is in the page but not loaded, a run seen in two faces, a slide whose text vanished after it was shown, and a layout that changed after the first reveal;TestFontEveryInputPathWaitsForItsFamilyis the table of input paths;TestFontTheGateCoversEveryFaceADeckUsesruns decks fromfixtures/generate-random-decks.mjs, which walks the op vocabulary, the text schema's marks and the server's themes and stacks and fails unless every one appeared, and every empty and trailing-empty text shape in every type the editor binds and in table cells. WebKit too:TestFontEnginesFirstRevealIsTheFinalLayout,TestFontEnginesSlidesChangeWithoutAGapandTestFontEnginesAWaitKeepsThePagedrive Chromium (the full browser, not the headless shell, which re-rasterises some glyphs) and WebKit through Playwright (fixtures/engines;npm ciandnpx playwright install chromium webkitthere once), comparing the slide's pixels capture by capture, with two controls that flash on purpose and must be caught.races_browser_test.goholds Astra's second-round interleavings on #27 (a resync during a waiting paste, a first slide through a retried save, stale projector answers, focus and announcements). None of the browser checks is in the gate: run them when you touch a slide surface,slides.css,editor.cssor anything underfixtures/that reaches the stage.
Pushing a branch that adds fonts: the hub may drop a chunked receive-pack and answer 200 with an empty body, which git reports as "unexpected disconnect while reading sideband packet". Push with git -c http.postBuffer=157286400 push so the pack goes out with a length (Docs hit it).
Running it locally
./scripts/run-dev.sh builds and runs the app on localhost:8091 ($SLIDES_DEV_PORT to move it) against a scratch database under $TMPDIR that starts empty every run. Sign in with any address; the magic link is logged to the terminal instead of being mailed, and it is a real link through the real flow.
Development mode is the only place four settings default — a fixed public instance key, mail to the terminal, an allowlist that admits everyone, and a directory-backed object store — and it can only be selected by the -env development flag. $SLIDES_ENV cannot reach it, deliberately: platform config is environment variables, so a stray SLIDES_ENV=development beside the real ones would otherwise be a production-reachable path to a public instance key and to every magic link landing in the instance log. Anywhere but development, a missing SLIDES_ORIGIN, SLIDES_INSTANCE_KEY, SLIDES_SMTP_* or SLIDES_ALLOWED_ADDRESSES is a startup refusal rather than a default — except the allowlist in team mode, where it is optional and empty admits nobody locally.
The gate
.amadan/ci.d/10-gate is the only CI this repo has, it runs on every push to the amadan remote, and it is the same script you run locally:
./.amadan/ci.d/10-gateIt does rustfmt, clippy with the disallowed-methods lint, the wasm build, the cmp against the committed artifact, the Rust tests; then the JS half — npm ci, node --test, the vectors regenerated and the bundle rebuilt and both diffed against what is committed; then make ci (vet, gofmt, Go tests, migration check). make ci alone is the fast loop between edits; the full gate is what you run before pushing.
Since slice 2 it needs Node 20+ and npm, and npm ci wants the registry reachable while it runs — the one part of this gate that is not offline once its caches are warm. .amadan/README.md says why that trade is worth making, what each step catches, and the runner's own two traps. In a sandbox, point NPM_CACHE somewhere writable or npm fails on its cache rather than on the install.
Deploying
One static binary, stamped: make release (refuses an empty version or a dirty tree — a -dirty stamp names a commit plus changes nobody can name, so two different binaries can carry the same string). Then carlos deploy --app slides --account oficina, with carlos store create for the object store and carlos domains attach slides.oficina.works. SLIDES_INSTANCE_KEY and SLIDES_SMTP_PASS go in via carlos secrets, the rest via carlos env, mirroring Docs' set (spec §6.3).
Mail submission. Ship every build with --mail submit: it declares that the build sends through CARLOS mail submission (mail.FromCarlos, newMailer in cmd/slides, From $CARLOS_MAIL_FROM). Until carlos email submission on --app slides runs Slides keeps sending over SMTP (SLIDES_SMTP_*, else CARLOS_SMTP_*, per variable); after it the agent sets CARLOS_MAIL=submit and Slides holds no SMTP credential, and every instance must run a build shipped with the flag. carlos deploy has no --mail flag yet (carlos main 9eec0236), so until it does use carlos ship --app slides --account oficina --mail submit <binary> and then carlos promote --app slides --account oficina <version> (or carlos deploy --mail submit once that ships).
Verify against x-carlos-version on the real host or let carlos deploy watch the URL. carlos channels reports which release a channel points at, which is not the question of what the box is serving — adoption runs on a timer and the two can disagree for up to an hour, with nothing saying "not live yet".
Working through amadan
This repo is hosted on an amadan hub, not GitHub: no gh, no pull request, no GitHub Actions. Post as the agent account (<name>~<operator keymail>), never as Paul. Work happens on a worktree branch and reaches main only by squash merge, after review and with the gate green — amadan ci status -branch <n> exit 0 is the merge gate; exit 2 is pending and exit 3 means nothing ran, and neither is green.
Every branch gets a discussion, opened before the merge, and it is the review record. A squash merge flattens the history that carried the branch's reasoning; the discussion is where that survives. If it does not exist before the merge, the reasoning is not scattered, it is gone.
UX conventions (seeded from profile: considered)
Accessible by construction, progressively enhanced, and never dependent on JavaScript to be usable.
- [x] Icons — lucide, inline —
internal/slides/icons - [ ] Screen flow — one job per screen — a link, then a page for that action alone, then a confirmation; never two ways to start work side by side
- [x] Fields — label, hint, help and error in one envelope, wired with aria-describedby —
ui/field, ui/field-select, ui/field-text - [x] Destructive actions — their own confirm-page URL, never a modal —
ui/confirm-form - [x] State — never colour alone — always a text label too —
ui/status-pill, ui/badge - [ ] Dates — relative, with the absolute date in a title attribute
- [ ] Errors — server-rendered beside the field, in plain language
- [x] Empty states — say what the screen is for, not just that it is empty —
ui/empty-state
[x] is enforced by a vendored component: use it, do not hand-roll an equivalent. [ ] is guidance to apply by hand. A convention absent from this list is one rastrillo has no opinion about.
Edit any line. This file is the source of truth, not the profile name. Nothing re-reads the profile, so changing a line here changes what the app does, and a convention deleted from this file is not one to reinstate.
Work in a worktree, and catch main up first
Take a worktree for the work. Do not work in the shared checkout.
git -C <repo> fetch origin git -C <repo> worktree add ../<repo>-<task> -b <branch> origin/main
Both halves matter, for different reasons.
The worktree, because several sessions share this machine and some share this repository, and a checkout has one HEAD, one index and one working tree between all of them. A branch switch under somebody else's uncommitted work destroys it with nothing on screen to say so, and two sessions editing the same paths disagree quietly instead of conflicting loudly. A worktree gives the work its own HEAD and its own files, and costs a directory.
From origin/main, after a fetch — not from whatever the checkout happens to be sitting on. A branch cut from a stale main is a merge conflict scheduled for later, against files somebody else has renamed in the meantime. A branch cut from another task's branch is worse: it carries that task's commits into yours, where they are reviewed as though you wrote them, and the two can only be separated by hand.
Remove it when the work has landed — git worktree remove — so that git worktree list keeps saying something true.
Written down because of 2026-09-17, in meet. The shared checkout was sitting on one task's branch while holding a different task's feature uncommitted on disk — some four hundred lines, a new migration among them — put there by a session nobody else knew was working in that tree. Two other sessions were meanwhile coordinating over the same checkout by asking each other not to touch it, which is the arrangement a worktree makes unnecessary. Nothing was lost. Nothing about the arrangement would have said so if it had been, and by then the same feature existed twice, once on each side of a rename, because the two sessions had branched from different starting points.
Steps, the talk and the presenter's position
- The document says what arrives and what is in the talk: a block's
step(a number; 1.5 sits between 1 and 2; none means there when the slide is) and, on a list,items: each; a slide'stalk(fullshows only in the full version,parkedis left out of the talk); the deck meta'sarrive. Core, fixtures and Go move together, with shared vectors. Indeck:presses.go(Presses,ArrivalOf,NoteParts) andtalk.go(TalkOrder,Position,Advance,SettleNear,ForReaders); the JS twins arefixtures/presses.mjsandmoves.mjs. - Readers.
ForReaders()is called at each reader boundary, so a parked slide reaches no share, follow or presenting reader./d/and the API stay complete. - Presenting keeps an absolute position on
Presentation(SlideID,Step,Mode,Seq,Positional,TimerAt). A press carries an id, and each window a link id, each with a rising counter (presentation_presses,presentation_links), so a repeated or stale press is answered, never applied twice.POST /p/{session}/pairpairs a phone;GET /p/{session}/talkreads the talk's order. - The editor has the Appears row and the box-menu rows, press numerals, a play-through control, the strip's count, dashed outline and slim bar, the talk toggles, and Deck settings' "How things arrive".