carlos / platform Public

Merge origin/main into demo-claim-page-fix

claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ab43a96b3b270f4777d30132c06b4259289dedac parent 467916bparent 3a58ccf
14 files changed, +1,548 −20
  • README.md +3 −1
  • docs/site/api.md +5 −0
  • docs/site/index.md +1 −4
  • docs/site/nav.json +30 −15
  • docs/superpowers/notes/2026-11-06-docs-mockup-review.md +65 −0
  • docs/superpowers/plans/2026-11-06-docs-site-1-mockup-and-foundations.md +317 −0
  • docs/superpowers/plans/2026-11-06-docs-site-2-copy.md +32 −0
  • docs/superpowers/plans/2026-11-06-docs-site-2-structure-and-components.md +296 −0
  • docs/superpowers/plans/2026-11-06-docs-site-index.md +27 −0
  • docs/superpowers/specs/2026-11-06-docs-site-design.md +313 −0
  • internal/docsite/diagrams.go +265 −0
  • internal/docsite/diagrams_test.go +161 −0
  • internal/docsite/fences_test.go +2 −0
  • internal/docsite/nav_test.go +31 −0

CI passed — run details

diff --git a/README.md b/README.md
index 20709b6c0..ad6fc2197 100644
--- a/README.md
+++ b/README.md
@@ -255,7 +255,9 @@ A release is a `vX.Y.Z` tag on this repo plus signed binaries on [carlosframewor
7. **Homebrew.** In `carlosframework/homebrew-tap`, bump `Formula/carlos.rb`: the version, the four url and sha256 pairs from the published `SHA256SUMS.txt`, and the `carlos vX.Y.Z` test string. Open a PR, check each hash against the sums file, and squash-merge it.
8. **apt.** Download the live tree, `apps/bab/apt-carlosframework/releases/<last>/site.tar.gz` from the flagship bucket, and unpack it. Add the two debs under `pool/main/c/carlos/`, and regenerate each architecture's `Packages` with `dpkg-scanpackages --multiversion`. Delete `Release`, `InRelease` and `Release.gpg`, then rebuild `Release` with `apt-ftparchive release`, passing Origin and Label `CARLOS`, Suite and Codename `stable`, the architectures and the component. Write it outside the tree first, or it lists itself. Sign `InRelease` and `Release.gpg` with the SSM key `/carlos/apt-signing-key` in a throwaway `GNUPGHOME`, set `latest.txt` to the tag, and check both signatures with `gpgv` against the tree's own keyring.
9. **Ship apt.** Ship the directory and let `carlos ship` build the tarball. A hand-made tar with a leading `./` entry took apt down once. With `AWS_PROFILE=keymail` and `CARLOS_DEPLOYMENT_BUCKET` set to the flagship bucket, run `carlos ship -app apt-carlosframework -account-id bab -kind static -version vX.Y.Z-1 site/`, then `carlos promote -app apt-carlosframework -account-id bab vX.Y.Z-1 canary/apt` with `CARLOS_RELEASE_KEY` from SSM `/carlos/release-key` set for that one command. The channel is the literal `canary/apt`.
-10. **Changelog.** In a full checkout of `main`, with `gh` and `amadan` signed in, run `git fetch origin --tags '+refs/amadan/closed/*:refs/amadan/closed/*'`, then `go run ./cmd/changelog`. Map each of the new release's bullets to the branches behind it in `docs/site/changelog-links.json`, keyed by the bullet's bold lead, and run it again. Land `docs/site/changelog.json` and the links file on a branch. Then, in `carlosframework/website`, run `node hack/sync-docs.mjs <checkout>` and ship the site the way its AGENTS.md describes. The page is carlosframework.com/platform/changelog.
+10. **Docs and changelog.** Two parts. Part a is owed every release, whatever else is: until 2026-11-06 the docs sync rode on the changelog and kept being put off, and the live site showed 4 of the 10 docs pages.
+ - **10a. Docs.** In `carlosframework/website`, run `node hack/sync-docs.mjs <checkout>` with the platform checkout at the release tag, so the site shows only released behaviour, then `npm run check`. Open and merge the PR, and ship the site the way its AGENTS.md describes. Check that carlosframework.com/docs/ lists every page in `docs/site/nav.json`.
+ - **10b. Changelog.** In a full checkout of `main`, with `gh` and `amadan` signed in, run `git fetch origin --tags '+refs/amadan/closed/*:refs/amadan/closed/*'`, then `go run ./cmd/changelog`. Map each of the new release's bullets to the branches behind it in `docs/site/changelog-links.json`, keyed by the bullet's bold lead, and run it again. Land `docs/site/changelog.json` and the links file on a branch. The release tag predates them, so publish them by syncing from a detached checkout of the tag with just those two files taken from `main`: `git checkout --detach <tag> && git checkout origin/main -- docs/site/changelog.json docs/site/changelog-links.json`, then `node hack/sync-docs.mjs <checkout>` and ship as in 10a. Restore the checkout afterwards (`git checkout <tag> -- docs/site`). The page is carlosframework.com/platform/changelog.
11. **Self-host template.** In `carlos/opentofu` on amadan, on a branch from `main`, run `scripts/bump-carlos vX.Y.Z`. It checks the signature on the release's `SHA256SUMS.txt` and rewrites the hosts' pin and checksum in `modules/region/cloud-init.sh.tftpl`. Then compare the release's "For operators" notes, and any change under `infra/modules/region-host/`, with the template: a new required `host.env` key, a changed `carlos bootstrap`, or an IAM or bucket change that a new host needs goes in the same branch. Run `scripts/check`, then land it with `amadan branch merge carlos/opentofu <branch> -squash -expect <full sha> -message "<subject>"` once CI is green. Note the landed commit.
12. **Self-host guide.** In `carlosframework/website`, move every pin on `src/platform/self-host/index.html` together: the CLI version in the prerequisites, the console `release_url`, the `ok vX.Y.Z` that `/healthz` returns, and the template commit after `git checkout --detach`. Copy changes go through copy review. Merge the PR and ship the site the way its AGENTS.md describes. This can be the same ship as step 10. Check carlosframework.com/platform/self-host/ shows the new version and commit.
diff --git a/docs/site/api.md b/docs/site/api.md
new file mode 100644
index 000000000..58ce3850f
--- /dev/null
+++ b/docs/site/api.md
@@ -0,0 +1,5 @@
+# API reference
+
+The public, versioned API for CARLOS is being designed. Endpoint details are not available yet.
+
+Until then, use the CLI. [The CLI reference](/docs/cli) lists its commands.
diff --git a/docs/site/index.md b/docs/site/index.md
index fe9fd6eca..2c6980018 100644
--- a/docs/site/index.md
+++ b/docs/site/index.md
@@ -6,10 +6,7 @@ and a DNS zone; you publish a release with `carlos ship`, and the platform
places it on instances, routes to it through a shared edge, and keeps TLS,
config, secrets and replication working underneath it.
-These pages are the reference for the platform itself — the commands you
-type, and what happens on a box after you type them. They assume you are
-either running a deployment or shipping onto one. They do not teach Go, and
-they are not a tutorial.
+These pages cover the platform. They explain how it works, how to run a deployment, and how to ship apps onto one. Use the tutorials and guides for step-by-step help. Use the reference to find commands.
If you are a Carloku customer, the docs you want are at
[carloku.com](https://carloku.com). Carloku is CARLOS run for you, and it
diff --git a/docs/site/nav.json b/docs/site/nav.json
index 3a7cef08c..2d5b175dc 100644
--- a/docs/site/nav.json
+++ b/docs/site/nav.json
@@ -1,7 +1,7 @@
{
"sections": [
{
- "title": "Guides",
+ "title": "Tutorials",
"pages": [
{
"slug": "rails",
@@ -16,32 +16,22 @@
]
},
{
- "title": "Reference",
+ "title": "Guides",
"pages": [
- {
- "slug": "cli",
- "label": "The CLI",
- "blurb": "Every carlos command, grouped by whether you are shipping an app, running a deployment, or on a box."
- },
{
"slug": "rootfs",
"label": "Rootfs apps",
"blurb": "What a rootfs app's image is started with, what it can write, and where it may run."
},
- {
- "slug": "scan-callbacks",
- "label": "Receiving scan results",
- "blurb": "Ask for one object to be scanned, read the verdict, and verify the callback that tells you it is done."
- },
{
"slug": "pdfs",
"label": "PDFs",
"blurb": "Render an invoice, attach it to an email, and use Gotenberg from your app."
},
{
- "slug": "plans",
- "label": "Plans",
- "blurb": "Give accounts limits, packs and sponsorship. Plans stay off until you configure a catalog."
+ "slug": "scan-callbacks",
+ "label": "Receiving scan results",
+ "blurb": "Ask for one object to be scanned, read the verdict, and verify the callback that tells you it is done."
},
{
"slug": "domains-buying",
@@ -52,6 +42,31 @@
"slug": "rate-limits",
"label": "Rate limits",
"blurb": "Stop one visitor taking over an instance, set limits per instance, and roll them out safely."
+ },
+ {
+ "slug": "plans",
+ "label": "Plans",
+ "blurb": "Give accounts limits, packs and sponsorship. Plans stay off until you configure a catalog."
+ }
+ ]
+ },
+ {
+ "title": "CLI reference",
+ "pages": [
+ {
+ "slug": "cli",
+ "label": "The CLI",
+ "blurb": "Every carlos command, grouped by whether you are shipping an app, running a deployment, or on a box."
+ }
+ ]
+ },
+ {
+ "title": "API reference",
+ "pages": [
+ {
+ "slug": "api",
+ "label": "API reference",
+ "blurb": "The public API is not available yet. Use the CLI for now."
}
]
}
diff --git a/docs/superpowers/notes/2026-11-06-docs-mockup-review.md b/docs/superpowers/notes/2026-11-06-docs-mockup-review.md
new file mode 100644
index 000000000..cae35c27c
--- /dev/null
+++ b/docs/superpowers/notes/2026-11-06-docs-mockup-review.md
@@ -0,0 +1,65 @@
+# Docs site mockup review (Plan 1 Task 1)
+
+Paul reviewed the mockup on 2026-11-06 (website branch `docs-site-mockup`,
+mockups/docs-site/: home, How it works, Your first app). Plan 2 is written
+from this note.
+
+## Keep
+
+- Everything shown, for now. Paul: "It's fine for now."
+- The docs home: Start here cards, tutorial cards with time estimates, the
+ feature-area grid, the reference entries.
+- How it works: the static system map and the step-through (numbered
+ figures without JavaScript; Back, Next and arrow keys with it).
+- Your first app: the "Before you start" choice (D9), then numbered steps.
+
+## Change
+
+- Paul: "Just make sure the nav doesn't jump too much when I click through?
+ Should the navigation be hard-left? more like Stripe's?"
+ (docs.stripe.com/get-started/use-cases/startup).
+ Done in the mockup (ffe07fc) and adopted for Plan 2:
+ - the nav is pinned to the viewport's left edge on wide screens, full
+ height, with its own scroll and a hairline right border; the article
+ takes the rest of the width;
+ - the page's scrollbar gutter is always reserved, so short and long pages
+ put the nav and the article in the same place;
+ - a small script keeps the nav's own scroll position between pages
+ (progressive enhancement; without it the nav starts at the top and
+ brings the current page's link into view);
+ - the logo lines up with the nav.
+ Checked: nav and article at the same position on all three pages, nav
+ flush left, nav scroll kept across a click.
+
+- Paul, second pass: "Search looks funny, and it should probably not scroll
+ with the nav" (seen in dark mode). Done in the mockup (3ff76c0) and adopted
+ for Plan 2:
+ - the nav is a fixed head (the docs title and search) over a list that
+ scrolls on its own;
+ - search is a button-like box, after Stripe's: a search icon, the label,
+ and a `/` shortcut hint; `/` focuses it; without JavaScript it goes to
+ the page index;
+ - section headings line up with the docs title.
+ Checked: search outside the scrolling list, unmoved when the list scrolls,
+ aligned with the title and the full column width, even border; headings
+ aligned; the list keeps its scroll across a click.
+
+- Paul, third pass: "Why does clicking search make the page scroll?" It
+ followed its no-JavaScript link to the page index. Done in the mockup and
+ adopted for Plan 2: with JavaScript, clicking search or pressing `/`
+ opens a search dialog over the page (the page does not move), typing
+ filters, Enter opens the first result, one Escape closes it. Without
+ JavaScript the link goes to the page index, which lists every page A to Z.
+ The real search indexes page text at build time; the mockup searches
+ titles only.
+
+## Drop
+
+- Nothing.
+
+## Carried into Plan 2 from the build
+
+- On a 390px phone the diagrams are legible but small: the real components
+ need a stacked or zoomable layout below about 30rem.
+- Not yet tried: an "On this page" right rail (Stripe has one). Worth
+ showing Paul in Plan 2's first page rather than deciding now.
diff --git a/docs/superpowers/plans/2026-11-06-docs-site-1-mockup-and-foundations.md b/docs/superpowers/plans/2026-11-06-docs-site-1-mockup-and-foundations.md
new file mode 100644
index 000000000..9d5be98fb
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-06-docs-site-1-mockup-and-foundations.md
@@ -0,0 +1,317 @@
+# Docs site Plan 1: mockup and foundations
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Give Paul a clickable mockup of the new docs site to react to, and
+land the two foundations nothing else can wait for: the website's new
+JavaScript rule and a release step that keeps the live docs current.
+
+**Architecture:** The mockup is throwaway static HTML in the website repo,
+outside `src/` so Eleventy never ships it, styled with the site's own
+stylesheets. Its step-through works as a plain list of numbered figures and
+is enhanced by one small script. The rule change edits the website's design
+documents. The release step edits the platform README's release recipe.
+
+**Tech Stack:** HTML, CSS and inline SVG; one vanilla JavaScript file, no
+dependencies; Node for the mockup's check script; headless Chrome for
+screenshots.
+
+**Spec:** `docs/superpowers/specs/2026-11-06-docs-site-design.md`. Index:
+`docs/superpowers/plans/2026-11-06-docs-site-index.md`.
+
+## Global Constraints
+
+- JavaScript rule (D4, verbatim intent): use JavaScript when it meaningfully
+ improves the experience, and only as progressive enhancement on a page that
+ already works and loads without it. No fetched fonts, no analytics: those
+ parts of the old rule stand.
+- Neutral examples only: `shop`, `example.com`, `shop.example.com`. Never a
+ tenant or customer name.
+- Voice: plain, short sentences, no em dashes. The mockup's words are drafts
+ for layout and are labelled as drafts on every page; they are not copy and
+ do not ship.
+- Shared machine: bind any server to the Tailscale IP `100.119.180.57`
+ (docs-t1), never `0.0.0.0`. Stop it when Paul's review is recorded. Scratch
+ goes under `$TMPDIR` or `~/.cache`, never `/tmp`.
+- Links handed to Paul are Markdown links with the full URL as text and
+ target.
+- Website repo: `/home/paulca/amadan.net/carlos/website` (GitHub,
+ `carlosframework/website`). Platform repo: this worktree. Commit subjects
+ under 80 characters.
+
+## Review Focus
+
+1. **JavaScript off.** Every step-through frame, caption and nav link is
+ visible and in order with scripting disabled. Pinned in Task 1 Step 4.
+2. **Reduced motion.** With `prefers-reduced-motion: reduce`, the enhanced
+ step-through changes frames with no animation and never auto-plays.
+ Pinned in Task 1 Step 4.
+3. **Keyboard only.** Back and Next are buttons reachable by Tab, Left and
+ Right arrows move between frames when the viewer has focus, and the
+ current frame is announced (`aria-live="polite"` on the caption). Pinned
+ in Task 1 Step 4.
+4. **A phone at 390px.** No horizontal scroll on any mockup page; the nav
+ collapses; code blocks scroll inside themselves. Pinned in Task 1 Step 5.
+5. **Print.** Printing How it works prints every frame with its caption, not
+ only the current one. Pinned in Task 1 Step 4.
+
+---
+
+### Task 1: The clickable mockup
+
+**Files** (website repo, branch `docs-site-mockup`, worktree
+`.claude/worktrees/docs-site-mockup`):
+- Create: `mockups/docs-site/index.html` (the docs home)
+- Create: `mockups/docs-site/how-it-works.html`
+- Create: `mockups/docs-site/quickstart.html` (the T1 tutorial page)
+- Create: `mockups/docs-site/mockup.css` (mockup-only layout on top of the
+ site's stylesheets)
+- Create: `mockups/docs-site/stepper.js` (the progressive enhancement)
+- Create: `mockups/docs-site/check.mjs` (structure checks)
+- Create: `mockups/docs-site/serve.sh` (start and stop the review server)
+- Create (platform repo, this branch):
+ `docs/superpowers/notes/2026-11-06-docs-mockup-review.md`
+
+**Interfaces:**
+- Consumes: the site's `src/site.css`, `src/inner.css`, `src/docs.css`,
+ `src/header.css`, `src/footer.css`, linked by relative path
+ (`../../src/...`), never copied.
+- Produces, for Plan 2 to adopt or reject:
+ - The step-through markup contract:
+ `<section class="stepper" aria-label="...">` holding an `<ol>` of
+ `<li><figure><svg>...</svg><figcaption>...</figcaption></figure></li>`,
+ one per frame. With no script, this is the whole experience.
+ - `stepper.js`, which on `DOMContentLoaded` finds every `.stepper`, adds
+ `class="stepper is-enhanced"`, shows one frame at a time, and inserts
+ Back and Next buttons, a "Step n of N" label and a caption region with
+ `aria-live="polite"`.
+ - The nav shape: the six top-level sections of spec §5 in order (Start
+ here, Tutorials, Guides, Operating a deployment, CLI reference, API
+ reference), plus Changelog.
+
+- [ ] **Step 1: Write `check.mjs` with the structure checks, before the pages**
+
+`node mockups/docs-site/check.mjs` reads the three HTML files and exits
+non-zero naming each failure. It checks:
+ - every page links `../../src/site.css` and `mockup.css`, and has a
+ visible element with `class="draft-banner"` whose text contains
+ `Mockup`;
+ - every page has a nav with exactly these links, in this order: Start here,
+ Tutorials, Guides, Operating a deployment, CLI reference, API reference,
+ Changelog;
+ - `how-it-works.html` has one static `figure#system-map` that is not
+ inside a `.stepper`, and exactly one `.stepper` with exactly 5 `<li>`
+ frames, each holding one `<svg>` and one non-empty `<figcaption>`;
+ - no element in any page's source carries `hidden`, `display:none` or
+ `aria-hidden="true"` on a frame: hiding is only ever done by
+ `stepper.js`;
+ - `quickstart.html` opens with a section `id="before-you-start"` holding
+ two links, one to `#install-your-own` and one to
+ `#use-a-running-deployment` (spec D9), and has at least 4 numbered steps
+ (`<ol class="steps">`), a time estimate (`class="time"`), and at least one
+ `<pre><code>` block;
+ - every hostname on every page (in text, links and code) is
+ `example.com` or ends in `.example.com`, or is one of `carloku.com`,
+ `carlosframework.com`; any other hostname is a failure (it keeps tenant
+ and customer names out).
+
+- [ ] **Step 2: Run it and see it fail**
+
+Run: `node mockups/docs-site/check.mjs`
+Expected: FAIL, naming the three missing pages.
+
+- [ ] **Step 3: Build the three pages, the stylesheet and `stepper.js`**
+
+Content, as drafts:
+ - **Docs home (`index.html`):** a "Start here" path of four cards (Why
+ CARLOS, How it works, Security and why, What it does for you); the nine
+ launch tutorials as cards, each with a one-line outcome and a time
+ estimate (T1 to T8 and T3b, titles from spec §6); feature areas as a
+ compact grid from spec §8 (at least 12 areas); CLI and API reference
+ entries, the API one marked "coming: the public API is being designed".
+ A search box that, without JavaScript, is a link to a plain page index.
+ - **How it works (`how-it-works.html`):** the static system map
+ (`figure#system-map`): console, a fleet of boxes each running the edge
+ and instances, the deployment bucket holding releases and database
+ replicas, a second region greyed in; then the step-through "A request
+ wakes a sleeping instance" in 5 frames: the request reaches a box's
+ edge; the edge finds the instance asleep and holds the request; the box
+ starts the instance; the instance answers its health check; the edge
+ sends the held request on and the response comes back. Each frame is the
+ same SVG layout with the active part highlighted in the site's accent and
+ a one-sentence caption. Below it, the headings the real page will have,
+ with one line each saying what goes there.
+ - **Quickstart (`quickstart.html`):** "Before you start" with the D9
+ choice (install your own, or use a running deployment, such as your
+ team's or a hosted one like carloku.com); then numbered steps with code
+ blocks for a small Go app: install the CLI, sign in, ship, open it, watch
+ it sleep, wake it. A time estimate at the top. A "what you learned" box at
+ the end linking to How it works.
+
+`stepper.js` behaviour: Back is disabled on frame 1 and Next on the last;
+Left and Right arrows work while focus is inside the viewer; the caption
+region is `aria-live="polite"`; under `prefers-reduced-motion: reduce` frame
+changes are instant (no CSS transition) and nothing auto-plays; with motion
+allowed, a frame change cross-fades in at most 200 ms and nothing auto-plays
+either. `mockup.css` carries `@media print` rules that show every frame
+regardless of enhancement.
+
+Draw in the site's existing style (`DESIGN.md`: hairline rules, one accent
+per page, no coloured left borders on cards). Use the site's system font
+stacks only.
+
+- [ ] **Step 4: Check the behaviour in a browser, script on and off**
+
+Run: `node mockups/docs-site/check.mjs`
+Expected: PASS.
+
+Then, with headless Chrome against `file://` paths:
+ - scripting off (`--blink-settings=scriptEnabled=false`): screenshot
+ `how-it-works.html` at 1280 wide, full page; all 5 frames and captions
+ are visible in order.
+ - scripting on: one frame visible, "Step 1 of 5", Back disabled.
+ - scripting on with `--force-prefers-reduced-motion`: same, and the
+ computed `transition-duration` on the frame container is `0s`.
+ - print to PDF (`--print-to-pdf`) with scripting on: the PDF text holds
+ all 5 captions.
+ - keyboard: with a small DevTools-protocol script or by hand in a real
+ browser, Tab reaches Back and Next and the Right arrow advances. Write
+ down which way it was checked.
+
+Keep screenshots under `$TMPDIR/docs-mockup/` and delete them at the end of
+the task.
+
+- [ ] **Step 5: Check a phone width**
+
+Screenshot all three pages at 390 wide, full page, scripting on. Expected:
+no horizontal scrollbar (`document.documentElement.scrollWidth <= 390`),
+the nav collapsed, and code blocks scrolling inside themselves.
+
+- [ ] **Step 6: Commit and push the mockup branch**
+
+```bash
+git add mockups/docs-site
+git commit -m "Docs site mockup: home, How it works, quickstart (not shipped)"
+git push origin docs-site-mockup
+```
+
+No PR: the branch is for review and is deleted after Plan 2 adopts what Paul
+keeps.
+
+- [ ] **Step 7: Serve it for Paul**
+
+`mockups/docs-site/serve.sh start` runs
+`python3 -m http.server <port> --bind 100.119.180.57` from the website
+worktree root (so `../../src/` resolves), on a free port, in the background,
+and writes the PID to `$TMPDIR/docs-mockup/server.pid`; `serve.sh stop`
+kills it and removes the file. Hand Paul
+`http://docs-t1.tail5fd3ba.ts.net:<port>/mockups/docs-site/` as a Markdown
+link, and say the words on it are drafts.
+
+- [ ] **Step 8: Record Paul's review, then stop the server**
+
+Write Paul's reactions, verbatim where he gave words, to
+`docs/superpowers/notes/2026-11-06-docs-mockup-review.md` in the platform
+repo, under three headings: Keep, Change, Drop. Run `serve.sh stop`.
+Commit the note on this branch:
+
+```bash
+git add docs/superpowers/notes/2026-11-06-docs-mockup-review.md
+git commit -m "docs site: record Paul's mockup review"
+```
+
+Plan 2 is written from this note. Do not start Plan 2 before it exists.
+
+---
+
+### Task 2: The website's JavaScript rule
+
+**Files** (website repo, branch `js-progressive-enhancement`):
+- Modify: `PRODUCT.md:63-64` (the "Static pages ... no JavaScript ...
+ Binding." bullet)
+- Modify: `DESIGN.md:143-144` (the "one hand-written stylesheet, no build
+ step, no JavaScript, no fetched fonts" sentence)
+- Modify: `DESIGN.md:277-279` ("The Zero Fetch Rule")
+- Modify: `DESIGN.md:464-465` (the "Don't fetch a font or add JavaScript"
+ bullet)
+- Modify: `README.md:10-15` (the paragraph saying the hand-written pages ship
+ with no JavaScript and `/docs` is the one exception)
+
+**Interfaces:**
+- Produces: the rule every later plan's JavaScript is reviewed against.
+
+- [ ] **Step 1: Find every statement of the old rule**
+
+Run: `grep -rn -iE 'no javascript|add javascript|zero fetch' PRODUCT.md DESIGN.md README.md AGENTS.md`
+Expected: the lines listed above, and any others; every hit is edited in
+Step 2 or noted in the commit body as deliberately kept.
+
+- [ ] **Step 2: Rewrite them to the new rule**
+
+The rule, in these words in `PRODUCT.md` (binding) and `DESIGN.md` (The
+Zero Fetch Rule becomes "The Zero Fetch Rule and progressive enhancement"):
+
+> No fetched fonts and no analytics. JavaScript is allowed when it
+> meaningfully improves the experience, and only as progressive enhancement:
+> every page works, reads and loads without it, and the script only adds to
+> a page that is already complete. Scripts are local files, small, with no
+> dependencies, and never needed to read a page.
+
+The `DESIGN.md` Don't bullet becomes: "**Don't** fetch a font, add analytics,
+or make a page depend on JavaScript to be read." `README.md` says the same in
+one sentence. These are agent-facing design documents, not user-facing copy,
+so they do not go through copy review.
+
+- [ ] **Step 3: Check nothing else still states the old rule**
+
+Run: `grep -rn -iE 'no javascript' PRODUCT.md DESIGN.md README.md AGENTS.md`
+Expected: no hits, or only hits explained in the commit body.
+
+- [ ] **Step 4: Commit, open the PR, merge**
+
+```bash
+git commit -am "Allow JavaScript as progressive enhancement (docs site design D4)"
+git push origin js-progressive-enhancement
+gh pr create --base main --title "Allow JavaScript as progressive enhancement" --body "<summary; cites the platform spec D4>"
+```
+
+Paul approved the rule itself on 2026-11-06 (spec D4); merging the PR with
+`gh pr merge --squash` is within that approval. Nothing ships, so no deploy.
+
+---
+
+### Task 3: The docs sync as its own release step
+
+**Files** (platform repo, this branch):
+- Modify: `README.md:258` (release step 10, Changelog)
+
+**Interfaces:**
+- Consumes: the website's `hack/sync-docs.mjs <checkout>` and its `--check`
+ mode; the deploy recipe in the website's `AGENTS.md` "Deploying" section.
+
+- [ ] **Step 1: Split step 10**
+
+Step 10 today bundles the changelog, the docs sync and the website ship,
+and has been put off release after release, which left the live site with 4
+of 10 pages until 2026-11-06. Rewrite it as two steps:
+ - **10. Docs.** Every release, whatever else is owed: in
+ `carlosframework/website`, run `node hack/sync-docs.mjs <checkout>` with
+ the platform checkout at the release tag, `npm run check`, open and merge
+ the PR, and ship the site as its `AGENTS.md` describes. Check that
+ carlosframework.com/docs/ lists every page in `docs/site/nav.json`.
+ - **10b. Changelog.** The current step 10 text, minus the sync and ship
+ sentences, ending "Ship it with step 10's sync when both are ready."
+Keep the numbering of steps 11 and 12 unchanged so other notes that cite
+them stay right.
+
+- [ ] **Step 2: Check the README still reads in order**
+
+Run: `grep -nE '^(9|10|10b|11|12)\. ' README.md`
+Expected: 9, 10, 10b, 11, 12 in that order, each once.
+
+- [ ] **Step 3: Commit**
+
+```bash
+git add README.md
+git commit -m "release recipe: the docs sync is its own step, every release"
+```
diff --git a/docs/superpowers/plans/2026-11-06-docs-site-2-copy.md b/docs/superpowers/plans/2026-11-06-docs-site-2-copy.md
new file mode 100644
index 000000000..5021a69e0
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-06-docs-site-2-copy.md
@@ -0,0 +1,32 @@
+# Docs site Plan 2: copy deck
+
+Every new user-facing string in docs site Plan 2. Rows are `pending` until
+the Luna pass (spec D8) and then `approved` by delegation. Applied verbatim.
+
+Approved 2026-11-06 by delegation: a Luna pass (gpt-5.6-luna) against the
+house rules changed C09, C13, C15, C17, C18 and C19 and passed the rest.
+Its five flags were fact checks (the API is not out yet; the CLI is the
+route until it is, spec D5; the page index lists every page), all
+confirmed against the spec and the build, so none went to Paul.
+
+| id | where | text | status |
+|---|---|---|---|
+| DS2-C01 | docs/site/nav.json (section title) | Tutorials | approved |
+| DS2-C02 | docs/site/nav.json (section title) | Guides | approved |
+| DS2-C03 | docs/site/nav.json (section title) | CLI reference | approved |
+| DS2-C04 | docs/site/nav.json (section title) | API reference | approved |
+| DS2-C05 | website docs.njk (nav link to /platform/changelog/) | Changelog | approved |
+| DS2-C06 | website docs.njk (search box label; also the dialog field's placeholder and accessible name) | Search the docs | approved |
+| DS2-C07 | website docs.njk (title on the / key hint) | Press / to search | approved |
+| DS2-C08 | website docs-search.js (close button accessible name) | Close search | approved |
+| DS2-C09 | website docs-search.js (shown when nothing matches) | No pages match that. | approved |
+| DS2-C10 | website docs-search.js (hint under the results) | Enter opens the first result. Escape closes. | approved |
+| DS2-C11 | website docs.njk (heading of the On this page rail) | On this page | approved |
+| DS2-C12 | website docs-index.njk (heading of the page index) | Every page | approved |
+| DS2-C13 | website docs-index.njk (intro under that heading) | Browse the docs from A to Z. | approved |
+| DS2-C14 | docs/site/nav.json (label of the api page) | API reference | approved |
+| DS2-C15 | docs/site/nav.json (blurb of the api page) | The public API is not available yet. Use the CLI for now. | approved |
+| DS2-C16 | docs/site/api.md (title) | API reference | approved |
+| DS2-C17 | docs/site/api.md (paragraph 1) | The public, versioned API for CARLOS is being designed. Endpoint details are not available yet. | approved |
+| DS2-C18 | docs/site/api.md (paragraph 2) | Until then, use the CLI. [The CLI reference](/docs/cli) lists its commands. | approved |
+| DS2-C19 | docs/site/index.md (replaces the paragraph that says these pages are not a tutorial) | These pages cover the platform. They explain how it works, how to run a deployment, and how to ship apps onto one. Use the tutorials and guides for step-by-step help. Use the reference to find commands. | approved |
diff --git a/docs/superpowers/plans/2026-11-06-docs-site-2-structure-and-components.md b/docs/superpowers/plans/2026-11-06-docs-site-2-structure-and-components.md
new file mode 100644
index 000000000..5f1ddf60a
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-06-docs-site-2-structure-and-components.md
@@ -0,0 +1,296 @@
+# Docs site Plan 2: structure and components
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Turn the live `/docs` into the shape Paul approved in the mockup:
+a hard-left nav with a fixed head and search, an "On this page" rail, a
+search dialog over a build-time index, diagram and step-through components
+that docs pages can use, and the nav regrouped into the spec's sections.
+
+**Architecture:** The platform repo keeps owning the corpus (`docs/site`)
+and its gates (`internal/docsite`): it gains two fence kinds, `diagram` and
+`stepper`, whose SVGs live in `docs/site/diagrams/`. The website renders
+them with a markdown-it fence rule, inlining each SVG so it takes the
+site's colours, and ports the mockup's layout, `nav.js`, `search.js` and
+`stepper.js` into the real docs templates. Everything works without
+JavaScript; scripts only enhance (spec D4).
+
+**Tech Stack:** Go (`internal/docsite` gates); Eleventy 3, markdown-it,
+Nunjucks; vanilla JavaScript, no dependencies; headless Chromium over CDP
+for browser checks (the mockup's `probe.mjs`).
+
+**Spec:** `docs/superpowers/specs/2026-11-06-docs-site-design.md`.
+**Mockup review:** `docs/superpowers/notes/2026-11-06-docs-mockup-review.md`
+(binding for layout). Index: `docs/superpowers/plans/2026-11-06-docs-site-index.md`.
+
+## Global Constraints
+
+- JavaScript only as progressive enhancement (D4): every page works, reads
+ and navigates with scripting off.
+- The nav (mockup review): pinned hard-left on wide screens, full height, a
+ fixed head (docs title and search) over a list that scrolls on its own;
+ scrollbar gutter always reserved; the list keeps its scroll position
+ between pages; section headings line up with the title.
+- Search (mockup review): a button-like box with an icon, the label and a
+ `/` hint; click or `/` opens a dialog over the page without moving it;
+ typing filters; Enter opens the first result; one Escape, a click outside
+ or the one close button closes it; the field is `type="text"
+ role="searchbox"` so the browser adds no clear button. Without
+ JavaScript the box links to the page index on `/docs/`.
+- Copy: house voice, no em dashes, neutral examples. New user-facing
+ strings go through a Luna pass against the house rules (D8), then are
+ applied verbatim. Code, commands and SVG labels inside diagrams are
+ strings too when a person reads them.
+- Docs follow the stable release (spec §4): the platform half of this plan
+ goes live at the next release's step 10a sync. The website half ships
+ when its PR merges and must render today's `nav.json` correctly.
+- Shared machine: any local server binds `127.0.0.1`; stop it after.
+ Scratch under `$TMPDIR` or `~/.cache`.
+- Repos: platform = this worktree (branch `design-docs-site`); website =
+ `/home/paulca/amadan.net/carlos/website`, branch `docs-site-2` in
+ `.claude/worktrees/docs-site-2`.
+
+## Review Focus
+
+1. **A page with no `##` headings.** The "On this page" rail is absent, not
+ an empty box. Pinned in Task 4.
+2. **A diagram fence naming an SVG that does not exist, or a stepper with
+ one frame.** The platform gate fails naming the page and line; the
+ website build fails too rather than rendering a broken figure. Pinned in
+ Tasks 2 and 3.
+3. **An SVG with a `<script>` or an `on*=` attribute.** Refused by the
+ platform gate, since the website inlines SVGs into the page. Pinned in
+ Task 2.
+4. **Search with an empty index or no match.** The dialog says no page
+ matches; Enter does nothing. Pinned in Task 5.
+5. **Narrow screens (390px).** Diagrams scroll sideways inside their own
+ box at a readable size instead of shrinking; the nav collapses to one
+ row; nothing scrolls the page sideways. Pinned in Tasks 3 and 4.
+
+---
+
+### Task 1: The copy deck, with a Luna pass
+
+**Files:**
+- Create: `docs/superpowers/plans/2026-11-06-docs-site-2-copy.md`
+
+**Interfaces:**
+- Produces: approved rows `DS2-C01`.. that Tasks 4 to 6 apply verbatim.
+
+- [ ] **Step 1: Draft every new user-facing string as a row** (`| id | where | text | status |`, status `pending`):
+ nav section titles (Tutorials, Guides, CLI reference, API reference) and
+ the Changelog link; the search box label, its `/` hint's accessible
+ name, the dialog's field label and placeholder, the close button's
+ accessible name, the no-match line, the hint line; the "On this page"
+ rail heading; the page index heading and its one-line intro; the `api`
+ page (title, two short paragraphs: the public API is being designed, and
+ until then the CLI does everything, linking `/docs/cli/`); the rewritten
+ `docs/site/index.md` intro (it must stop saying the pages "are not a
+ tutorial"); the nav blurbs for every page whose section changes.
+- [ ] **Step 2: Run the Luna pass.** `codex exec -m gpt-5.6-luna` with a
+ brief carrying the house rules (plain, short sentences, no em dashes,
+ lower-case after a full stop only where the house style does, neutral
+ examples), answering a key/new/why table plus flags. Apply its changes
+ unless they change a fact; check every rewrite against the sources.
+- [ ] **Step 3: Mark rows approved by delegation**, with a note naming the
+ Luna pass and listing anything flagged for Paul. Commit:
+ `git commit -m "docs site plan 2: copy deck (Luna pass)"`.
+
+---
+
+### Task 2: Diagram and stepper fences in the platform gate
+
+**Files:**
+- Create: `internal/docsite/diagrams.go`
+- Create: `internal/docsite/diagrams_test.go`
+- Create: `internal/docsite/testdata/diagrams/` (fixture pages and SVGs)
+- `docs/site/diagrams/` holds the SVGs. It stays empty until Plan 4's
+ first diagram; `CheckDiagrams` and the website sync treat a missing
+ directory as empty. (Never put Markdown in it: it would become a page.)
+- Modify: `internal/docsite/fences_test.go` (`knownFenceLangs` gains
+ `diagram` and `stepper`)
+
+**Interfaces:**
+- Produces, in Go:
+ - `type Figure struct { File, Caption string }`
+ - `type Diagram struct { Page string; Line int; Kind string /* "diagram" or "stepper" */; Title string; Frames []Figure }`
+ - `func ParseDiagramFence(kind, body string) (Diagram, error)`
+ - `func CheckDiagrams(site *Site, dir string) []string` (problems, each
+ naming page and line)
+- Produces, for the website (Task 3), the fence formats:
+ - ```` ```diagram ```` body: first line `file: <name>.svg`, the rest is
+ the caption (one or more lines, non-empty).
+ - ```` ```stepper ```` body: first line `title: <text>`, then two or
+ more frames, each a line `frame: <name>.svg` followed by its caption
+ lines (non-empty).
+ - SVG names match `^[a-z0-9][a-z0-9-]*\.svg$` and resolve under
+ `docs/site/diagrams/`.
+
+- [ ] **Step 1: Write the failing tests** in `diagrams_test.go`:
+ `TestParseDiagramFence` (a diagram; a 3-frame stepper; refusals for a
+ missing `file:`, an empty caption, a stepper with 1 frame, a bad name like
+ `../x.svg` or `X.SVG`); `TestCheckDiagramsFindsMissingFiles`;
+ `TestCheckDiagramsRefusesActiveSVG` (an SVG with `<script`, an
+ `onload=`, or an `href="javascript:`, each refused naming the file);
+ `TestCheckDiagramsOnTheRealCorpus` (no problems in `docs/site`).
+- [ ] **Step 2: Run and watch them fail.**
+ `go test ./internal/docsite/ -run 'Diagram' -count=1` → FAIL, undefined
+ `ParseDiagramFence`.
+- [ ] **Step 3: Implement** `ParseDiagramFence` and `CheckDiagrams`, reading
+ fences from `Page.Fences` (already parsed). Add the two languages to
+ `knownFenceLangs`.
+- [ ] **Step 4: Run** `go test ./internal/docsite/ -count=1` → PASS.
+- [ ] **Step 5: Commit** `docsite: diagram and stepper fences, gated`.
+
+---
+
+### Task 3: Render diagrams and steppers on the website
+
+**Files** (website, `docs-site-2`):
+- Create: `hack/docs-markdown.mjs` (the configured markdown-it instance and
+ the fence rule, imported by `eleventy.config.js` and by the test)
+- Create: `hack/test-docs-markdown.mjs`
+- Create: `src/docs-stepper.js` (from `mockups/docs-site/stepper.js`)
+- Modify: `eleventy.config.js` (use `hack/docs-markdown.mjs`; passthrough
+ `src/docs-stepper.js`)
+- Modify: `hack/sync-docs.mjs` (copy `docs/site/diagrams/*.svg` to
+ `src/docs/diagrams/`, and check them in `--check`)
+- Modify: `src/docs.css` (diagram and stepper styles from
+ `mockups/docs-site/mockup.css`, including print, reduced motion, and the
+ narrow-screen rule below)
+- Modify: `package.json` (`check` also runs `node hack/test-docs-markdown.mjs`)
+
+**Interfaces:**
+- Consumes: Task 2's fence formats.
+- Produces: `renderDocsMarkdown(src: string, opts: { diagramsDir: string }): string`
+ and the HTML contract the mockup fixed: `<figure class="diagram">` with
+ the inlined `<svg>` and a `<figcaption>`; `<section class="stepper
+ diagram" aria-label="<title>"><ol class="frames"><li class="frame">
+ <figure>…<figcaption>…</figcaption></figure></li>…</ol></section>`.
+
+- [ ] **Step 1: Write the failing test** `hack/test-docs-markdown.mjs`:
+ renders a fixture with one diagram and one 3-frame stepper from a temp
+ diagrams dir and asserts the contract above (inlined `<svg`, never
+ `<img`; 3 `li.frame`; captions present; `aria-label` equals the title);
+ asserts a missing SVG throws naming the file; asserts an SVG holding
+ `<script` throws.
+- [ ] **Step 2: Run** `node hack/test-docs-markdown.mjs` → FAIL (module missing).
+- [ ] **Step 3: Implement** the module and wire it into the config. The
+ narrow-screen rule: below `30rem` a diagram's SVG keeps `min-width:
+ 36rem` inside a container with `overflow-x: auto`, so it scrolls in its
+ own box at a readable size.
+- [ ] **Step 4: Run** the test → PASS; `npm run check` → PASS.
+- [ ] **Step 5: Commit** `Docs: render diagram and stepper fences`.
+
+---
+
+### Task 4: The docs layout from the mockup
+
+**Files** (website, `docs-site-2`):
+- Modify: `src/_includes/docs.njk` (nav head with title and search; the
+ scrolling `nav-groups` list; the Changelog link; the "On this page" rail;
+ script tags for `docs-nav.js`, `docs-search.js` and `docs-stepper.js`,
+ all `defer`)
+- Modify: `src/docs.css` (port the mockup's hard-left nav, nav head,
+ search box, scrollbar gutter, logo alignment, heading alignment and
+ narrow-screen collapse)
+- Create: `src/docs-nav.js` (from `mockups/docs-site/nav.js`)
+- Create: `hack/probe-docs.mjs` (the mockup's `probe.mjs`, pointed at the
+ built `_site` served on `127.0.0.1`)
+- Modify: `eleventy.config.js` (passthrough the new scripts)
+
+**Interfaces:**
+- Consumes: the copy rows for the nav head, Changelog link and rail heading.
+- Produces: the rail markup `<aside class="docs-toc" aria-label="On this page">`
+ listing the page's `##` headings, shown at `min-width: 75rem`; the
+ sidebar's per-page sub-list is removed (the rail replaces it).
+
+- [ ] **Step 1: Port the probe and run it against today's built site** →
+ the layout checks FAIL (nav not flush left, search scrolls with the nav,
+ no rail).
+- [ ] **Step 2: Implement** the template and CSS changes.
+- [ ] **Step 3: Add the rail checks**: a page with headings shows the rail
+ at 1440 wide and lists them in order; a page with no `##` headings has no
+ `.docs-toc` element at all; the rail is hidden below 75rem.
+- [ ] **Step 4: Run** `npm run check` and `node hack/probe-docs.mjs` → all
+ PASS, with scripting on and off, reduced motion, print and 390px.
+- [ ] **Step 5: Commit** `Docs: hard-left nav, fixed search head, On this page rail`.
+
+---
+
+### Task 5: Search over a build-time index
+
+**Files** (website, `docs-site-2`):
+- Create: `src/docs-search-index.njk` (permalink `/docs/search-index.json`:
+ one entry per page with `title`, `section`, `url`, `headings` (`##` and
+ `###` text with anchors) and `text` (the page's prose, markdown stripped,
+ at most 2,000 characters))
+- Create: `src/docs-search.js` (from `mockups/docs-site/search.js`, now
+ fetching the index on first open and matching title, headings and text;
+ a heading match links to `url#anchor`)
+- Modify: `src/docs-index.njk` (the page index: every page, A to Z, under
+ the approved heading)
+
+**Interfaces:**
+- Consumes: the copy rows for search and the page index.
+- Produces: `/docs/search-index.json` (a JSON array as above).
+
+- [ ] **Step 1: Write the failing probe checks**: the index exists and
+ lists every page in `docsnav.json`; typing a word that appears only in a
+ page's body (pick one at test time from the index's `text`) returns that
+ page; typing a heading returns `url#anchor`; no match shows the approved
+ no-match line and Enter does nothing; the page does not move on open;
+ the close button, Escape and a click outside each close it; with
+ scripting off the box goes to `/docs/#` + the page index anchor and that
+ list holds every page.
+- [ ] **Step 2: Run** → FAIL.
+- [ ] **Step 3: Implement.** Rank title matches above heading matches above
+ text matches; show at most 10.
+- [ ] **Step 4: Run** `npm run check` and the probe → PASS.
+- [ ] **Step 5: Commit** `Docs: search over a build-time index`.
+
+---
+
+### Task 6: Regroup the nav and add the API page (platform)
+
+**Files** (platform):
+- Modify: `docs/site/nav.json`
+- Create: `docs/site/api.md`
+- Modify: `docs/site/index.md` (the approved intro)
+
+**Interfaces:**
+- Consumes: the copy rows for section titles, blurbs, the API page and the
+ index intro.
+- Produces: `nav.json` sections in this order: **Tutorials** (`rails`,
+ `laravel-and-django`), **Guides** (`rootfs`, `pdfs`, `scan-callbacks`,
+ `domains-buying`, `rate-limits`, `plans`), **CLI reference** (`cli`),
+ **API reference** (`api`). Slugs do not change, so no page moves and no
+ link breaks. Start here and Operating a deployment are added by Plans 4
+ and 5 with their first pages; an empty section is never shown.
+
+- [ ] **Step 1: Write the failing test** in `internal/docsite/nav_test.go`:
+ `TestNavSectionsInSpecOrder` asserts every section title is one of the
+ spec's (Start here, Tutorials, Guides, Operating a deployment, CLI
+ reference, API reference), that they appear in that order (some may be
+ missing), and that no section is empty.
+- [ ] **Step 2: Run** `go test ./internal/docsite/ -run TestNavSections -count=1` → FAIL.
+- [ ] **Step 3: Edit** `nav.json`, add `api.md`, rewrite the `index.md` intro.
+- [ ] **Step 4: Run** `go test ./internal/docsite/ -count=1` → PASS; then,
+ in the website worktree, `node hack/sync-docs.mjs <this worktree>` and
+ `npm run check` → PASS, and the probe → PASS against the regrouped nav.
+ Revert the sync in the website worktree afterwards: the website takes
+ the platform docs only at a release (step 10a).
+- [ ] **Step 5: Commit** `docs: regroup the nav into the docs site sections; API page`.
+
+---
+
+### Task 7: Ship the website half
+
+- [ ] **Step 1:** Push `docs-site-2`, open the website PR, merge it with
+ `gh pr merge --squash` (Paul's "proceed and build", 2026-11-06).
+- [ ] **Step 2:** Deploy from a clean export as the website's `AGENTS.md`
+ "Deploying" section says, recording the previous version first.
+- [ ] **Step 3:** Check `X-Carlos-Version` on all three hosts, then run
+ `node hack/probe-docs.mjs https://carlosframework.com` against the live
+ site → PASS.
+- [ ] **Step 4:** Record the result in the ledger and stop any local server.
diff --git a/docs/superpowers/plans/2026-11-06-docs-site-index.md b/docs/superpowers/plans/2026-11-06-docs-site-index.md
new file mode 100644
index 000000000..2f019374f
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-06-docs-site-index.md
@@ -0,0 +1,27 @@
+# CARLOS Platform docs site: plan index
+
+**Spec:** `docs/superpowers/specs/2026-11-06-docs-site-design.md` (approved by
+Paul 2026-11-06).
+
+The spec is several projects in one: site foundations, the Start here
+content, the tutorials (each with its own example app), the guides, and the
+CLI reference. Each plan below produces something shippable on its own.
+
+Plans 1 and 2 are written in full (Plan 1 done 2026-11-06). Paul reviews a clickable mockup at the end of
+its Task 1, and that review decides the layouts the later plans build. Each
+later plan is written when the one before it lands, from the spec plus the
+mockup review notes (`docs/superpowers/notes/2026-11-06-docs-mockup-review.md`,
+written in Plan 1 Task 1).
+
+| Plan | Scope | Spec sections | Depends on |
+|---|---|---|---|
+| 1. Mockup and foundations | the clickable mockup; the website's JavaScript rule (D4); the docs sync as its own release step | §4, D4, §11 steps 2 and 7 (rule) | nothing |
+| 2. Structure and components | the new nav and section structure in `docs/site/nav.json` and the website templates; today's pages moved into it with redirects; the diagram and step-through components; search | §5, §4 (diagrams), §9 (links) | Plan 1 mockup review |
+| 3. CLI reference | one page per command group; usage and flags generated from the CLI's own FlagSets; the flags gate; anchors and redirects for every heading the changelog links | §7 (CLI), §9 | Plan 2 |
+| 4. Start here | Why CARLOS, How it works (system map + four step-throughs), Security and why, the feature tour; full copy review with Paul (D8) | §5.1, D2, D3, D8 | Plan 2 |
+| 5. Launch tutorials, first wave | T1 quickstart (with the D9 fork), T7 install (from the website's self-host page), T8 when things go wrong; their example apps and drift tests | §6 | Plans 2 and 4 |
+| 6. Launch tutorials, second wave | T2 per-customer SaaS, T4 static site, T5 one-off prospect site, T6 project manager dashboard; revise T3 Rails | §6 | Plan 5 |
+| 7. Guides | one guide or reference entry for every feature area in §8 not covered by Plans 3 to 6; the page-to-place audit of §5 closed | §5.3, §8 | Plan 3 |
+
+The API reference fills in from the public v1 API project, which has its own
+design (D5).
diff --git a/docs/superpowers/specs/2026-11-06-docs-site-design.md b/docs/superpowers/specs/2026-11-06-docs-site-design.md
new file mode 100644
index 000000000..027eb2e2e
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-06-docs-site-design.md
@@ -0,0 +1,313 @@
+# CARLOS Platform docs site: design
+
+Status: APPROVED by Paul, 2026-11-06. A clickable mockup (docs home and nav, How it works with one step-through, one tutorial page) is the first task of the plan.
+Origin: a question from a team member about running rake tasks on rootfs apps
+showed that the Rails guide was out of date and that most of the platform
+cannot be found from the docs. Paul asked for an end-to-end rethink.
+
+## 1. Intent
+
+A best-in-class documentation site for the CARLOS Platform. It covers the
+full breadth of the platform and shows people how to use it, with tutorials
+and working examples, a CLI reference and, later, an API reference. The bar
+Paul set is the breadth and polish of go.tito.io/docs.
+
+**The reader** is someone on a tech team somewhere who is evaluating CARLOS,
+installing it, or getting apps running on it (Paul). They arrive knowing
+nothing about CARLOS.
+
+**What the evaluator needs, in Paul's words:** how easy and lightweight it
+is, how it works (with diagrams), what it is doing, how secure it is and why,
+and then the breadth of features that will make their lives easier.
+
+## 2. Decisions (Paul's, 2026-11-06)
+
+- D1. **Two separate doc sets.** The CARLOS Platform docs describe the
+ platform itself, never a particular deployment of it. carloku.com's docs
+ are about running apps on Carloku and stay completely separate. Carloku is
+ one deployment of the platform, like any other.
+- D2. **"How it works" is the part to make excellent at launch** (Paul took
+ the recommendation). "Lightweight" and "secure, and why" are both shown
+ through the architecture, so they are built on it.
+- D3. **Diagrams are a mix of static and step-through.**
+- D4. **JavaScript rule, changed:** use JavaScript when it meaningfully
+ improves the experience, and only as progressive enhancement on a page
+ that already works and loads without it. This replaces the website's
+ binding "no JavaScript" rule (website `PRODUCT.md` line 64, `DESIGN.md`
+ "The Zero Fetch Rule" and its Don'ts). The no-fetched-fonts and
+ no-analytics parts of that rule are not changed by this decision.
+- D5. **A public, versioned API is the goal**, but it is its own project
+ with its own design. This site reserves the API reference section and its
+ page shape (section 7); it does not design the API.
+- D6. **The CLI reference is one page per command group**, not one long page.
+- D7. **The launch tutorials** are the nine in section 6.
+- D9. **The quickstart starts with a choice.** T1 opens with "Before you
+ start": you need a CARLOS deployment you can sign in to. Either install
+ your own (T7, which ends by sending the reader back to T1) or use one
+ already running: your team's, or a hosted deployment such as carloku.com.
+ After that choice the tutorial is the same for everyone and uses only
+ `carlos` commands that work on any deployment. (Paul agreed to offering
+ the choice; the wording of the two routes is my draft.)
+- D8. **Copy review split:** "How it works" and "Security" go to Paul in full
+ copy review. All other pages get a Luna pass against the house rules, and
+ Paul sees only what Luna flags.
+
+## 3. Goals, non-goals, anti-goals
+
+Goals:
+
+- An evaluator can decide whether CARLOS suits them from the site alone,
+ without installing anything.
+- A developer gets a first app running from a tutorial without needing
+ anything outside the site.
+- An operator can install, grow, upgrade and recover a deployment from the
+ site.
+- Every feature a customer can use is findable from the nav or search, and
+ has at least a guide or a reference entry.
+- The docs cannot quietly drift from the code: CI fails when they do
+ (section 9).
+
+Non-goals:
+
+- Carloku's own docs (sign-up, Carloku plans and prices, Carloku-specific
+ domains). They live on carloku.com.
+- Designing the public API (D5).
+- Translations.
+- Rewriting the website's look. The docs use the site's existing design
+ system (website `DESIGN.md`).
+
+Anti-goals (would be a failure even if it technically works):
+
+- Marketing in the clothes of documentation. Claims about lightness or
+ security without the diagram, mechanism or number behind them.
+- Naming any tenant or customer anywhere. Examples are neutral (`shop`,
+ `example.com`).
+- Docs that describe Carloku's settings as if they were the platform's.
+- A page that needs JavaScript to be read.
+- Duplicated explanations that drift: one fact lives on one page and other
+ pages link to it.
+
+## 4. Where it lives and how it is built
+
+As today:
+
+- Source: `docs/site/` in the platform repo. A page changes in the same pull
+ request as the code it describes, and the platform's Go tests gate it
+ (`internal/docsite`).
+- Rendered by carlosframework.com (repo `carlos/website`, Eleventy 3 with
+ markdown-it and markdown-it-anchor) under `/docs`. The website vendors
+ the corpus with `hack/sync-docs.mjs`.
+
+Found during design: the website's vendored copy holds 4 pages (cli, plans,
+rate-limits, scan-callbacks), while `docs/site` has 10. The Rails, Laravel
+and Django, Rootfs, PDFs and domains pages are not on the live site. The sync
+must run as part of shipping a platform release from now on; how (CI job,
+release step) is the builder's call.
+
+**Which version the docs describe (my call):** the published site describes
+the latest stable platform release. A docs change still lands in the same
+pull request as its code, on `main`, and goes live when that code is
+released: the sync runs at release, from the release tag. Behaviour that is
+merged but not released, or released but off behind a switch, is not
+documented as available. One version at a time; no per-version docs yet.
+
+The website also has hand-written platform pages outside `/docs`:
+`src/platform/index.html`, `src/platform/self-host/index.html` (an AWS trial
+install with OpenTofu) and `src/start/index.html` (getting started). They
+are folded into the new structure: the self-host page becomes the basis of
+T7, the start page is reconciled with T1, and the old URLs redirect.
+
+Diagrams are inline SVG in the website's hairline style, authored as source
+files under `docs/site/` so they are versioned and reviewed with the pages.
+The exact authoring format (hand-drawn SVG, or a text source compiled to
+SVG at build time) is the builder's call, provided the output is static SVG
+that renders with no JavaScript.
+
+## 5. Information architecture
+
+Top-level nav, in order. Names are working names; final labels go through
+copy review.
+
+1. **Start here** (evaluators)
+ - **Why CARLOS**: easy and lightweight, shown with the parts list, the
+ costs and the time from nothing to a running app.
+ - **How it works** (the deepest section at launch, D2). Static diagrams:
+ the system map (console, boxes, edge, instances, storage, regions,
+ fleets) and what each part holds. Step-throughs (D3), at least: a ship
+ and deploy with no downtime; a request arriving at a sleeping instance
+ and waking it; a box failing and its instances recovering; a
+ one-off command (`carlos run`).
+ - **Security, and why**: written for someone doing a security review.
+ How instances are isolated, what a box holds and never holds, how
+ secrets are sealed and to whom, who can do what (roles, service
+ credentials), what is audited, and what the operator of a deployment
+ can and cannot see. Built on the How it works diagrams; it reuses them
+ rather than redrawing.
+ - **What it does for you**: the feature tour. Each feature is one short
+ entry tied to the chore it removes, linking to its guide.
+2. **Tutorials** (section 6).
+3. **Guides**, grouped by feature area. Task pages ("Run a one-off command",
+ "Add a domain", "Read a database at a point in time"), much of it moved
+ out of today's `cli.md`. The starting inventory is in section 8.
+4. **Operating a deployment**: install, configure, grow (boxes, fleets,
+ regions), observe (alerts, logs), upgrade and roll back, recover.
+5. **CLI reference** (D6, section 7).
+6. **API reference**: reserved (D5, section 7).
+7. **Changelog**: already rendered from `docs/site/changelog.json` at
+ `/platform/changelog/`; linked from the docs nav.
+
+Every existing page in `docs/site` is mapped to a place in this structure.
+Part of that mapping is deciding for each page, and each section of
+`cli.md`, whether it is platform material or belongs to Carloku (D1).
+
+Search: a good first use of D4. A build-time index plus a small script that
+filters it, on top of a nav that works without it. My call; the builder may
+choose the tool.
+
+## 6. Tutorials (D7)
+
+Each tutorial is a real app under `examples/`, and its page quotes from it
+under a drift test like `internal/docsite/rails_sample_test.go`. A tutorial
+states what it shows and roughly how long it takes.
+
+| # | Tutorial | Shows | Status |
+|---|---|---|---|
+| T1 | Quickstart: a small Go app with SQLite that sleeps and wakes | ship, open, sleep, wake; the native binary shape | new |
+| T2 | A per-customer SaaS app | one instance and database per customer, custom domains and certificates, seeded instances | new |
+| T3 | Rails with a worker on your own fleet | rootfs apps, release process, workers, store, `carlos run` and `carlos console` | exists (`examples/rails-shop`, `rails.md`), revise |
+| T3b | Laravel and Django | what changes from T3 | exists (`laravel-and-django.md`), keep as notes: no example apps of their own at launch (my call), so the quote rule does not apply to it |
+| T4 | A static site | custom headers, preview sites, the asset cache | new |
+| T5 | A one-off site for one audience | a temporary static site with a demo or presentation for one prospect, shared as a link, expiring by itself | new |
+| T6 | A dashboard for a project manager | a small internal app for one person: pulls status from a few tools' APIs on a schedule, behind sign-in, secrets for the API keys, sleeps between visits | new |
+| T7 | Install a deployment | console, first fleet, first box | new |
+| T8 | When things go wrong | restore from backup, point-in-time read, upgrade and roll back | new |
+
+**Box failure and recovery (my call):** the How it works step-through and T8
+show the behaviour of the stable release as a deployment gets it by
+default. Where recovery is operator-led, they show the operator's steps.
+Automatic failover in HA regions is shown only once it is released and on
+for new deployments; until then it gets a short "in HA regions" note at
+most.
+
+**Install environments (my call):** T7 covers the install path that exists
+today, AWS with the OpenTofu modules, and says so. Other providers are
+documented when their adapters ship; the architecture pages stay
+provider-neutral.
+
+Later (not launch): an invoicing app (email, PDFs, schedules, store), a Node
+app as a rootfs image (JIT rules), growing a deployment (boxes, regions,
+alerts).
+
+T6's data sources stay generic (any HTTP API with a token), so the example
+does not depend on a vendor. T5 depends on temporary static sites, which are
+live today.
+
+## 7. References
+
+**CLI reference (D6).** One page per command group with an index page. Each
+command's usage line and flag table are generated from the CLI itself, so
+they cannot drift; hand-written prose explains the command and links to the
+guides for how-tos. CI checks flags, not only top-level command names (today
+`internal/docsite/cliscan.go` deliberately skips flags; that changes once
+the flags come from generation rather than hand-written prose). Today's
+`cli.md` is 3,286 lines with 76 command sections; its anchors are linked from
+the changelog (`internal/changelog`), so the split keeps working links, by
+redirects or an anchor map, for every heading the changelog has linked.
+
+**API reference (reserved, D5).** At launch the section exists, says the
+public API is being designed, and points to the CLI. The page shape, taken
+from go.tito.io/docs/api and recorded here as requirements for the API
+project:
+
+- Getting started (auth, errors, pagination, conventions), then resources by
+ area, then object schemas.
+- Per endpoint: method and path, one-line summary, the permission it needs,
+ parameters, responses by status, copyable examples, and a response
+ example.
+- Example tabs: `curl`, JavaScript, and the equivalent `carlos` command.
+- Examples captured from the API's own tests; an OpenAPI document checked
+ against the real routes in CI.
+- A try-it panel that takes the reader's key, as progressive enhancement.
+- The generic reference on this site, and a copy served by each
+ deployment's console with that deployment's base URL and the reader's own
+ apps in the examples.
+- Webhooks and events next to the endpoints that cause them, with signature
+ checks shown in more than one language.
+
+## 8. Feature areas (starting inventory)
+
+To be verified against the code and the changelog by the builder; the
+builder adds any area missing here. Each area gets at least one guide page
+or reference entry.
+
+Apps and releases (ship, promote, versions, zero-downtime deploys, swap
+hold); instances (create, sleep and wake, always-on, seeded instances,
+moves between regions); rootfs apps (the image contract, processes,
+workers, release); one-off commands and terminal sessions (`carlos run`,
+`carlos console`); databases (replication, backups, `carlos db query` and
+`pull`, point-in-time reads); store (buckets, uploads); config and secrets
+(sealed config, fleet secrets keys); domains (custom domains, certificates,
+buying domains, regional domains); the edge (routing, request protection,
+rate limits, asset cache, static headers, streams and WebSockets); static and
+temporary sites; email (sending, tenant senders); PDFs; scan callbacks;
+schedules; logs, activity and audit; analytics; alerts and fleet traffic;
+members, roles, invites, sign-in options, service credentials and run
+credentials; plans and caps (for a deployment that sells plans); fleets and
+boxes (own boxes, managed fleets, regions, HA pools); operating a deployment
+(install, host.env, upgrades and rollback, the release channels).
+
+## 9. Drift gates
+
+What CI checks, building on `internal/docsite`:
+
+- Every top-level CLI command and every flag is in the CLI reference
+ (generated pages).
+- Every tutorial page quotes its example app accurately (drift tests per
+ example, like the Rails one).
+- Every internal link and anchor resolves, including links from the
+ changelog.
+- The copy gates the repo already uses for approved copy apply to docs
+ pages written through copy decks.
+- The website's vendored copy matches a known platform sha (the sync
+ script's `--check` mode).
+
+## 10. Voice and copy
+
+- Paul's house voice: plain, short sentences, no em dashes (full stop and a
+ new sentence), neutral examples, no tenant names.
+- Copy review as in D8. Each page's prose is drafted, then reviewed before
+ it is written into `docs/site`; code blocks and command output are not
+ copy.
+- The writing-pipeline and humane-docs guidance applies to every page.
+
+## 11. Order of work
+
+My call, for Paul to check:
+
+1. Already under way, separate from this design: the Rails guide fix (the
+ stale "carlos run does not reach rootfs instances yet" line) and a
+ "Commands and consoles" section on the Rootfs page, on branch
+ `rails-guide-run-console`.
+2. Sync the website so all of today's pages are live, and make the sync part
+ of shipping docs.
+3. New IA and nav, with today's pages moved into it and `cli.md` split into
+ command-group pages with generated usage and flags.
+4. Start here: How it works (with diagrams), Security, Why CARLOS, the
+ feature tour.
+5. Tutorials T1, T7, T8, then T2, T4, T5, T6, and revise T3.
+6. Guides for every area in section 8 not yet covered.
+7. The search enhancement, and the website rule change of D4 (website
+ `PRODUCT.md`, `DESIGN.md`), landed before the first page that uses
+ JavaScript.
+
+The API reference fills in when the public API project lands.
+
+## 12. Left to the builder
+
+- Diagram authoring format, within the constraints in section 4.
+- The search tool.
+- How the sync runs.
+- Page-level structure inside a guide or reference page, following the
+ patterns already set by `rails.md` and `rootfs.md`.
+- How the command-group pages are generated, as long as usage and flags come
+ from the CLI's own definitions.
diff --git a/internal/docsite/diagrams.go b/internal/docsite/diagrams.go
new file mode 100644
index 000000000..cea247007
--- /dev/null
+++ b/internal/docsite/diagrams.go
@@ -0,0 +1,265 @@
+package docsite
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+)
+
+// Diagrams in the docs are fenced blocks the website renders as figures,
+// inlining each SVG from docs/site/diagrams/ so it takes the page's
+// colours. Two kinds:
+//
+// ```diagram
+// file: system-map.svg
+// The caption, one or more lines.
+// ```
+//
+// ```stepper
+// title: A request wakes a sleeping instance
+// frame: wake-1.svg
+// The first frame's caption.
+// frame: wake-2.svg
+// The second frame's caption.
+// ```
+//
+// A stepper reads as numbered figures without JavaScript and as one frame
+// at a time with it. The website parses the same format (the website's
+// hack/docs-markdown.mjs), so a change here changes there too.
+
+// Figure is one SVG and its caption.
+type Figure struct {
+ File string
+ Caption string
+}
+
+// Diagram is one diagram or stepper fence.
+type Diagram struct {
+ Page string
+ Line int
+ Kind string // "diagram" or "stepper"
+ Title string // steppers only
+ Frames []Figure
+}
+
+var diagramFile = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*\.svg$`)
+
+// An inlined SVG is checked against an allowlist, not a blocklist (Astra's
+// final review found encoded and unusual forms a blocklist missed). The
+// website's hack/docs-markdown.mjs applies the same rules.
+var (
+ svgProlog = regexp.MustCompile(`^\s*<\?xml[^>]*\?>`)
+ svgComment = regexp.MustCompile(`(?s)<!--.*?-->`)
+ svgTag = regexp.MustCompile(`<(/?)([^\s/>]+)([^>]*)>`)
+ svgAttrs = regexp.MustCompile(`^(\s+[A-Za-z_:][\w:.-]*\s*=\s*("[^"]*"|'[^']*'))*\s*/?\s*$`)
+ svgAttr = regexp.MustCompile(`([A-Za-z_:][\w:.-]*)\s*=\s*("[^"]*"|'[^']*')`)
+ svgEntity = regexp.MustCompile(`&(?:amp|lt|gt|quot|apos);`)
+ svgLocalRef = regexp.MustCompile(`^#[A-Za-z_][\w-]*$`)
+ svgURL = regexp.MustCompile(`url\(`)
+ svgLocalURLs = regexp.MustCompile(`^(?:[^u]|u[^r]|ur[^l]|url[^(]|url\(#[A-Za-z_][\w-]*\))*$`)
+)
+
+var svgElements = setOf("svg", "g", "defs", "title", "desc", "rect", "circle", "ellipse", "line", "polyline", "polygon", "path", "text", "tspan", "marker", "use", "linearGradient", "radialGradient", "stop", "clipPath", "symbol")
+
+var svgAttributes = setOf("id", "class", "viewBox", "width", "height", "x", "y", "x1", "y1", "x2", "y2", "cx", "cy", "r", "rx", "ry", "dx", "dy", "d", "points", "transform",
+ "fill", "fill-opacity", "stroke", "stroke-width", "stroke-dasharray", "stroke-linecap", "stroke-linejoin", "stroke-opacity", "opacity",
+ "font-size", "font-weight", "font-family", "letter-spacing", "text-anchor", "dominant-baseline",
+ "role", "aria-label", "aria-labelledby", "aria-hidden", "focusable", "xmlns", "xmlns:xlink", "version", "preserveAspectRatio",
+ "marker-start", "marker-mid", "marker-end", "markerWidth", "markerHeight", "markerUnits", "refX", "refY", "orient",
+ "offset", "stop-color", "stop-opacity", "gradientUnits", "clip-path", "clipPathUnits", "href", "xlink:href")
+
+func setOf(names ...string) map[string]bool {
+ m := make(map[string]bool, len(names))
+ for _, n := range names {
+ m[n] = true
+ }
+ return m
+}
+
+// svgProblem returns why an SVG may not be inlined, or "" if it may.
+func svgProblem(svg string) string {
+ body := svgComment.ReplaceAllString(svgProlog.ReplaceAllString(svg, ""), "")
+ if strings.Contains(body, "<!") {
+ return "carries a DOCTYPE, CDATA or entity declaration"
+ }
+ if amps := strings.Count(body, "&"); amps != len(svgEntity.FindAllString(body, -1)) {
+ return "carries a character reference other than &amp; &lt; &gt; &quot; &apos;"
+ }
+ tags := svgTag.FindAllStringSubmatch(body, -1)
+ if strings.Count(body, "<") != len(tags) {
+ return "carries a < that does not open a tag"
+ }
+ for _, m := range tags {
+ name, attrs := m[2], m[3]
+ if !svgElements[name] {
+ return fmt.Sprintf("carries a <%s> element, which is not on the allowed list", name)
+ }
+ if m[1] == "/" {
+ if strings.TrimSpace(attrs) != "" {
+ return fmt.Sprintf("carries a malformed </%s>", name)
+ }
+ continue
+ }
+ if !svgAttrs.MatchString(attrs) {
+ return fmt.Sprintf("carries an unquoted or malformed attribute on <%s>", name)
+ }
+ for _, a := range svgAttr.FindAllStringSubmatch(attrs, -1) {
+ key, val := a[1], a[2][1:len(a[2])-1]
+ if !svgAttributes[key] {
+ return fmt.Sprintf("carries a %s attribute, which is not on the allowed list", key)
+ }
+ if (key == "href" || key == "xlink:href") && !svgLocalRef.MatchString(val) {
+ return fmt.Sprintf("carries %s=%q; only links to #ids in the same SVG are allowed", key, val)
+ }
+ if svgURL.MatchString(val) && !svgLocalURLs.MatchString(val) {
+ return fmt.Sprintf("carries %s=%q; url() may only point to #ids in the same SVG", key, val)
+ }
+ }
+ }
+ return ""
+}
+
+// UnclosedFence reports the 1-based line of a fence that is opened and
+// never closed. Markdown renders such a fence to the end of the page,
+// swallowing everything after it, and the page parser records only
+// closed fences, so the other gates would never see it.
+func UnclosedFence(body string) (int, bool) {
+ open, mark := 0, ""
+ for i, line := range strings.Split(body, "\n") {
+ m, _, ok := fenceDelim(strings.TrimSpace(line))
+ if !ok {
+ continue
+ }
+ if open == 0 {
+ open, mark = i+1, m
+ } else if sameFence(m, mark) {
+ open, mark = 0, ""
+ }
+ }
+ return open, open != 0
+}
+
+// ParseDiagramFence parses the body of a diagram or stepper fence.
+func ParseDiagramFence(kind, body string) (Diagram, error) {
+ d := Diagram{Kind: kind}
+ lines := strings.Split(strings.TrimSpace(body), "\n")
+ var cur *Figure
+ var caption []string
+ flush := func() error {
+ if cur == nil {
+ return nil
+ }
+ cur.Caption = strings.Join(strings.Fields(strings.Join(caption, " ")), " ")
+ if cur.Caption == "" {
+ return fmt.Errorf("%s has no caption", cur.File)
+ }
+ d.Frames = append(d.Frames, *cur)
+ cur, caption = nil, nil
+ return nil
+ }
+ start := func(key, line string) error {
+ name := strings.TrimSpace(strings.TrimPrefix(line, key))
+ if !diagramFile.MatchString(name) {
+ return fmt.Errorf("%q is not a diagram file name (lower case letters, digits and hyphens, ending .svg)", name)
+ }
+ if err := flush(); err != nil {
+ return err
+ }
+ cur = &Figure{File: name}
+ return nil
+ }
+ switch kind {
+ case "diagram":
+ if len(lines) == 0 || !strings.HasPrefix(lines[0], "file:") {
+ return d, errors.New("a diagram fence starts with a file: line")
+ }
+ if err := start("file:", lines[0]); err != nil {
+ return d, err
+ }
+ caption = lines[1:]
+ if err := flush(); err != nil {
+ return d, err
+ }
+ case "stepper":
+ if len(lines) == 0 || !strings.HasPrefix(lines[0], "title:") {
+ return d, errors.New("a stepper fence starts with a title: line")
+ }
+ d.Title = strings.TrimSpace(strings.TrimPrefix(lines[0], "title:"))
+ if d.Title == "" {
+ return d, errors.New("the stepper's title is empty")
+ }
+ for _, line := range lines[1:] {
+ if strings.HasPrefix(line, "frame:") {
+ if err := start("frame:", line); err != nil {
+ return d, err
+ }
+ continue
+ }
+ if cur == nil {
+ if strings.TrimSpace(line) != "" {
+ return d, errors.New("text before the first frame: line")
+ }
+ continue
+ }
+ caption = append(caption, line)
+ }
+ if err := flush(); err != nil {
+ return d, err
+ }
+ if len(d.Frames) < 2 {
+ return d, fmt.Errorf("a stepper needs at least 2 frames, this one has %d", len(d.Frames))
+ }
+ default:
+ return d, fmt.Errorf("%q is not a diagram kind", kind)
+ }
+ return d, nil
+}
+
+// CheckDiagrams parses every diagram and stepper fence in the site and
+// checks each SVG it names exists under dir and is inert. Each problem
+// names the page and the fence's line. A missing dir is treated as empty.
+func CheckDiagrams(site *Site, dir string) []string {
+ var problems []string
+ checked := map[string]string{}
+ for _, p := range site.Pages() {
+ if line, ok := UnclosedFence(p.Body); ok {
+ problems = append(problems, fmt.Sprintf("%s:%d: a fence is never closed, so the rest of the page renders as code", p.Slug, line))
+ }
+ for _, f := range p.Fences {
+ if f.Lang != "diagram" && f.Lang != "stepper" {
+ continue
+ }
+ where := fmt.Sprintf("%s:%d", p.Slug, f.Line)
+ d, err := ParseDiagramFence(f.Lang, f.Body)
+ if err != nil {
+ problems = append(problems, fmt.Sprintf("%s: %v", where, err))
+ continue
+ }
+ for _, fr := range d.Frames {
+ verdict, seen := checked[fr.File]
+ if !seen {
+ verdict = checkSVG(filepath.Join(dir, fr.File))
+ checked[fr.File] = verdict
+ }
+ if verdict != "" {
+ problems = append(problems, fmt.Sprintf("%s: %s %s", where, fr.File, verdict))
+ }
+ }
+ }
+ }
+ return problems
+}
+
+func checkSVG(path string) string {
+ raw, err := os.ReadFile(path)
+ if err != nil {
+ return "does not exist in docs/site/diagrams"
+ }
+ if why := svgProblem(string(raw)); why != "" {
+ return why + " (an inlined SVG may hold only drawing elements and attributes)"
+ }
+ return ""
+}
diff --git a/internal/docsite/diagrams_test.go b/internal/docsite/diagrams_test.go
new file mode 100644
index 000000000..64b64bb25
--- /dev/null
+++ b/internal/docsite/diagrams_test.go
@@ -0,0 +1,161 @@
+package docsite
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestParseDiagramFence(t *testing.T) {
+ d, err := ParseDiagramFence("diagram", "file: system-map.svg\nOne console, one bucket\nand a fleet of boxes.")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if d.Kind != "diagram" || len(d.Frames) != 1 || d.Frames[0].File != "system-map.svg" || d.Frames[0].Caption != "One console, one bucket and a fleet of boxes." {
+ t.Errorf("diagram parsed as %+v", d)
+ }
+
+ s, err := ParseDiagramFence("stepper", "title: A request wakes an instance\nframe: wake-1.svg\nThe request arrives.\nframe: wake-2.svg\nThe edge holds it.\nframe: wake-3.svg\nThe instance answers.")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if s.Title != "A request wakes an instance" || len(s.Frames) != 3 || s.Frames[2].File != "wake-3.svg" || s.Frames[1].Caption != "The edge holds it." {
+ t.Errorf("stepper parsed as %+v", s)
+ }
+
+ refusals := map[string][2]string{
+ "no file line": {"diagram", "One console."},
+ "empty caption": {"diagram", "file: map.svg\n \n"},
+ "one frame": {"stepper", "title: T\nframe: a.svg\nOnly one."},
+ "no title": {"stepper", "frame: a.svg\nOne.\nframe: b.svg\nTwo."},
+ "empty frame": {"stepper", "title: T\nframe: a.svg\nframe: b.svg\nTwo."},
+ "path escape": {"diagram", "file: ../x.svg\nCaption."},
+ "upper case name": {"diagram", "file: X.SVG\nCaption."},
+ "not an svg": {"diagram", "file: map.png\nCaption."},
+ "unknown kind": {"chart", "file: map.svg\nCaption."},
+ "text before file": {"stepper", "title: T\nloose text\nframe: a.svg\nOne.\nframe: b.svg\nTwo."},
+ }
+ for name, c := range refusals {
+ if _, err := ParseDiagramFence(c[0], c[1]); err == nil {
+ t.Errorf("%s: accepted", name)
+ }
+ }
+}
+
+func diagramSite(t *testing.T, body string) *Site {
+ t.Helper()
+ p := Parse("guide", body)
+ return &Site{Sections: []Section{{Title: "Guides", Pages: []*Page{p}}}, BySlug: map[string]*Page{"guide": p}}
+}
+
+func TestCheckDiagramsFindsMissingFiles(t *testing.T) {
+ dir := t.TempDir()
+ if err := os.WriteFile(filepath.Join(dir, "here.svg"), []byte(`<svg xmlns="http://www.w3.org/2000/svg"></svg>`), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ site := diagramSite(t, "# Guide\n\n```diagram\nfile: here.svg\nPresent.\n```\n\n```stepper\ntitle: T\nframe: here.svg\nOne.\nframe: gone.svg\nTwo.\n```\n")
+ problems := CheckDiagrams(site, dir)
+ if len(problems) != 1 || !strings.Contains(problems[0], "gone.svg") || !strings.Contains(problems[0], "guide") {
+ t.Errorf("problems = %q, want one naming guide and gone.svg", problems)
+ }
+}
+
+func TestCheckDiagramsReportsBadFences(t *testing.T) {
+ site := diagramSite(t, "# Guide\n\n```stepper\ntitle: T\nframe: a.svg\nOnly one.\n```\n")
+ problems := CheckDiagrams(site, t.TempDir())
+ if len(problems) != 1 || !strings.Contains(problems[0], "guide:3") {
+ t.Errorf("problems = %q, want one naming guide:3", problems)
+ }
+}
+
+func TestCheckDiagramsRefusesActiveSVG(t *testing.T) {
+ for name, svg := range map[string]string{
+ "script": `<svg><script>alert(1)</script></svg>`,
+ "onload": `<svg onload="alert(1)"></svg>`,
+ "onclick": `<svg><rect OnClick="x()"/></svg>`,
+ "javascript": `<svg><a href="javascript:alert(1)"><text>x</text></a></svg>`,
+ "foreign": `<svg><foreignObject><div>x</div></foreignObject></svg>`,
+ // Astra's final review: a blocklist missed these.
+ "slash onload": `<svg/onload=alert(1)></svg>`,
+ "encoded js href": `<svg><a href="java&#x73;cript:alert(1)"><text>x</text></a></svg>`,
+ "xlink js": `<svg xmlns:xlink="http://www.w3.org/1999/xlink"><use xlink:href="java&#x73;cript:x"/></svg>`,
+ "iframe": `<svg></svg><iframe srcdoc="&lt;script&gt;alert(1)&lt;/script&gt;"></iframe>`,
+ "style element": `<svg><style>body { display: none }</style></svg>`,
+ "style attribute": `<svg><rect style="display:none"/></svg>`,
+ "external use": `<svg><use href="https://example.com/x.svg#a"/></svg>`,
+ "data uri": `<svg><image href="data:image/svg+xml;base64,PHN2Zz4="/></svg>`,
+ "doctype entity": `<!DOCTYPE svg [<!ENTITY x "y">]><svg>&x;</svg>`,
+ "unquoted attr": `<svg><rect width=10 /></svg>`,
+ } {
+ dir := t.TempDir()
+ if err := os.WriteFile(filepath.Join(dir, "bad.svg"), []byte(svg), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ site := diagramSite(t, "# Guide\n\n```diagram\nfile: bad.svg\nCaption.\n```\n")
+ problems := CheckDiagrams(site, dir)
+ if len(problems) != 1 || !strings.Contains(problems[0], "bad.svg") {
+ t.Errorf("%s: problems = %q, want one naming bad.svg", name, problems)
+ }
+ }
+}
+
+func TestCheckDiagramsOnTheRealCorpus(t *testing.T) {
+ site, err := Load(root)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, p := range CheckDiagrams(site, filepath.Join(root, "diagrams")) {
+ t.Error(p)
+ }
+}
+
+func TestCheckDiagramsAcceptsAPlainSVG(t *testing.T) {
+ dir := t.TempDir()
+ svg := `<?xml version="1.0" encoding="UTF-8"?>
+<!-- a comment is fine -->
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 40" role="img" aria-labelledby="t">
+ <title id="t">Console &amp; boxes</title>
+ <defs><marker id="arrow" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0 0 L10 5 L0 10 z"/></marker></defs>
+ <g class="parts">
+ <rect class="shape on" x="1" y="1" width="40" height="20" rx="4"/>
+ <circle cx="70" cy="10" r="5" class="shape"/>
+ <line class="line" x1="41" y1="11" x2="65" y2="11" marker-end="url(#arrow)"/>
+ <text x="5" y="15" class="small" text-anchor="start">edge <tspan class="on">on</tspan></text>
+ <use href="#arrow"/>
+ </g>
+</svg>`
+ if err := os.WriteFile(filepath.Join(dir, "plain.svg"), []byte(svg), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ site := diagramSite(t, "# Guide\n\n```diagram\nfile: plain.svg\nCaption.\n```\n")
+ if problems := CheckDiagrams(site, dir); len(problems) != 0 {
+ t.Errorf("a plain SVG was refused: %q", problems)
+ }
+}
+
+func TestUnclosedFenceIsCaught(t *testing.T) {
+ if line, ok := UnclosedFence("# Guide\n\n```stepper\ntitle: T\nframe: a.svg\nOne.\n"); !ok || line != 3 {
+ t.Errorf("UnclosedFence = %d, %v; want 3, true", line, ok)
+ }
+ if _, ok := UnclosedFence("# Guide\n\n```sh\nx\n```\n"); ok {
+ t.Error("a closed fence was reported")
+ }
+ site := diagramSite(t, "# Guide\n\n```stepper\ntitle: T\nframe: a.svg\nOnly one.\n")
+ problems := CheckDiagrams(site, t.TempDir())
+ if len(problems) != 1 || !strings.Contains(problems[0], "guide:3") || !strings.Contains(problems[0], "never closed") {
+ t.Errorf("problems = %q, want one naming guide:3 and an unclosed fence", problems)
+ }
+}
+
+func TestEveryFenceInTheCorpusIsClosed(t *testing.T) {
+ site, err := Load(root)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, p := range site.Pages() {
+ if line, ok := UnclosedFence(p.Body); ok {
+ t.Errorf("%s:%d: a fence is never closed, so the rest of the page renders as code", p.Slug, line)
+ }
+ }
+}
diff --git a/internal/docsite/fences_test.go b/internal/docsite/fences_test.go
index 9424fc5dd..3795c5119 100644
--- a/internal/docsite/fences_test.go
+++ b/internal/docsite/fences_test.go
@@ -24,6 +24,8 @@ var knownFenceLangs = map[string]bool{
// word (rails_sample_test.go holds it to that), and the Laravel notes
// show the one line of config/database.php that differs.
"dockerfile": true, "ruby": true, "php": true,
+ // Rendered as figures by the website; gated by CheckDiagrams.
+ "diagram": true, "stepper": true,
}
func TestFenceLanguagesAreDeclared(t *testing.T) {
diff --git a/internal/docsite/nav_test.go b/internal/docsite/nav_test.go
index 8f2d5d9b3..a8c987f87 100644
--- a/internal/docsite/nav_test.go
+++ b/internal/docsite/nav_test.go
@@ -78,3 +78,34 @@ func TestNavNamingAMissingPageFails(t *testing.T) {
t.Fatal("Load succeeded on a nav.json naming a page that does not exist")
}
}
+
+// specSections is the docs site's section order (spec
+// docs/superpowers/specs/2026-11-06-docs-site-design.md §5). A section may
+// be missing until its first page lands, but never empty and never out of
+// order.
+var specSections = []string{"Start here", "Tutorials", "Guides", "Operating a deployment", "CLI reference", "API reference"}
+
+func TestNavSectionsInSpecOrder(t *testing.T) {
+ site, err := Load(root)
+ if err != nil {
+ t.Fatal(err)
+ }
+ next := 0
+ for _, sec := range site.Sections {
+ at := -1
+ for i := next; i < len(specSections); i++ {
+ if specSections[i] == sec.Title {
+ at = i
+ break
+ }
+ }
+ if at < 0 {
+ t.Errorf("section %q is not one of %q, or is out of order", sec.Title, specSections)
+ continue
+ }
+ next = at + 1
+ if len(sec.Pages) == 0 {
+ t.Errorf("section %q is empty", sec.Title)
+ }
+ }
+}