Spec §13: number Phase 2's server notes 24-35, after Phase 1's 1-23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Two merged branches had both started at 22.
1 file changed,
+12
−12
docs/superpowers/specs/2026-11-14-mapa-level-up.md+12 −12
CI passed — run details
CI log
=== editor === cd editor && npm ci --no-audit --no-fund --loglevel=error added 16 packages in 803ms cd editor && node build-bundles.mjs wrote internal/mapa/static/editor.9c9edc5536b1d844.js (36245 bytes, 11.3KB gzipped; L12 budget 120KB) cd editor && node --test ✔ golden file has bodies (0.750041ms) ✔ markup.mjs parses every body into Go's blocks, byte offsets and all (15.191831ms) ✔ markup.mjs strips and spans every block as Go does (19.406447ms) ✔ the schema's toDOM draws every body as Go renders it (42.883217ms) ✔ emphasis draws the four pinned outputs (22.348993ms) ✔ a body ends in the editor's empty paragraph (0.36934ms) ℹ tests 6 ℹ suites 0 ℹ pass 6 ℹ fail 0 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 182.383008 === vet === go vet ./... go vet -tags browser ./internal/mapatest/ === fmt === === code === go tool rastrillo budget code The base has no .rastrillo/code.txt: skipping the check that records only go down. budget code: within the limits. === test === CGO_ENABLED=0 go test ./... ? amadan.net/oficina/mapa/cmd/mapa [no test files] ok amadan.net/oficina/mapa/internal/mapa (cached) ? amadan.net/oficina/mapa/internal/mapa/icons [no test files] ok amadan.net/oficina/mapa/internal/mapa/markup (cached) ok amadan.net/oficina/mapa/internal/mapa/seal (cached) ok amadan.net/oficina/mapa/internal/mapatest 13.383s ? amadan.net/oficina/mapa/rastrillo_migration_dump [no test files] ? amadan.net/oficina/mapa/scripts/mutate [no test files] ? amadan.net/oficina/mapa/scripts/preview [no test files] === migration-check === go tool rastrillo migration check rastrillo migration check: models and migrations agree === credits-check === python3 scripts/credits.py --check credits: checked
diff --git a/docs/superpowers/specs/2026-11-14-mapa-level-up.md b/docs/superpowers/specs/2026-11-14-mapa-level-up.md| index 60f3d14..fe0ab41 100644 |
| --- a/docs/superpowers/specs/2026-11-14-mapa-level-up.md |
| +++ b/docs/superpowers/specs/2026-11-14-mapa-level-up.md |
| @@ -1072,18 +1072,18 @@ Phase 1's choices where this spec was silent, or where the build chose different |
| **Phase 2, the server's half** (steps 2 to 5 and 7's server changes, §8): |
| -22. **`Settle`'s seams** (§6.4, D13). Two blocks that were neighbours in mine keep mine's bytes between them, as theirs' do; only a seam where the sides meet follows `Join`. Theirs' leading bytes are kept when its first block comes first. A block both sides changed the same way is taken from theirs. The structure check compares each block's kind, level, list kind and source. |
| -23. **The autosave reply** is `{version, revision, merge?}`, every revision and version as text (they are int63s). `merge` is `{against, body}`, `{against, conflict: true, hunks: [{at, count, base, mine, theirs}]}`, `{noBase: true}` or `{gone: true}`; `at` and `count` are block positions in the text the request carried, and `base`, `mine` and `theirs` each side's exact bytes from the hunk's first block to its last. `revision` is left out for an unwritten day and a deleted page. |
| -24. **`rebase=R`** writes the request's `body` as the draft too. With no draft, to a revision of another page, past the window, or on a deleted page it answers 422 `{refused: "rebase"}`; a stale version is the existing 409. Nothing moves. Every draft write is now compare-and-swap on the version it read, so two tabs racing cannot both win. |
| -25. **`commit=1`** answers as Save does. Version 0 with a body is a tab that never autosaved: its text becomes the draft and is committed. Version 0 with no body is refused (409). |
| -26. **A save that changes nothing** reports the outcome it computed: a `Merged` result equal to the current body still answers `merged` with the body, so the tab takes the teammate's text. From a stale tab it is `Kept`. The draft is dropped only if it is still the version the tab held. Restore still mints a revision: it is its own verb. |
| -27. **Resolve's JSON** `outcome` is `saved`, `merged`, `conflicted`, `noBase` or `kept`. A choice that no longer fits (another revision landed, the draft changed, a choice missing) answers `conflicted` with the current `revision` and `body`; no draft at all is the 404 it was. |
| -28. **Make team page's `revision`** is required: none is stale. The refusal asks the person to choose again. |
| -29. **The first scratch commit (D12) is keyed by a token**, `first=<16–64 of [A-Za-z0-9_-]>` on `POST /scratch`, which the tab draws once for the new page and sends until it learns the page's address. The server keeps (person, token) → page in memory only, for 10 minutes and at most 4,096 at once, and runs the whole create-or-look-up under one lock. So the first request creates the page and answers `{href, page, revision}`; any later one with the token is an autosave of a draft on that page, answered like any autosave plus `{href, page}`; an empty body is 422 `{empty: true}` and creates nothing. Nothing new is stored, so §4 is unchanged. The version check could not key it, because no draft row exists before the page. A token forgotten (past 10 minutes, or across a restart or a CARLOS swap) makes a second page; only a tab still sending its first token that late meets it. |
| -30. **The island** is on `/p/{id}` (and `/p/{id}/history`, the current page with the panel), `/` and `/d/{date}` written or not, and `/scratch/new`. Its `base` is the page's current revision, `"0"` for a day or page not written yet; `draft.base` is the draft's own. Link keys are the target as typed, with `#^id` for a block. A date's `title` is the day in words; a pending link's is empty. `?saved=1` and a day re-shown after a refused Save carry none: neither is the text the draft continues. |
| -31. **`POST /links/resolve`** takes form fields `target`, each a link key (anything after `|` is ignored). Over 32 is 422 `{refused: "too many"}`. The answer is keyed by each key as sent; a key with no target is left out. |
| -32. **The draft bar** says "You're seeing the saved version" under `?saved=1`, with "Show your unsaved version". "Show the saved version" is left off where nothing is saved yet (an unwritten day) and in the Markdown editor. |
| -33. **Gate 1 compares the island's revisions as one value.** Revisions are random in both worlds (doctrine §6.6), so they cannot say anything about Ana's notes; the history scope test already did the same for history links. |
| +24. **`Settle`'s seams** (§6.4, D13). Two blocks that were neighbours in mine keep mine's bytes between them, as theirs' do; only a seam where the sides meet follows `Join`. Theirs' leading bytes are kept when its first block comes first. A block both sides changed the same way is taken from theirs. The structure check compares each block's kind, level, list kind and source. |
| +25. **The autosave reply** is `{version, revision, merge?}`, every revision and version as text (they are int63s). `merge` is `{against, body}`, `{against, conflict: true, hunks: [{at, count, base, mine, theirs}]}`, `{noBase: true}` or `{gone: true}`; `at` and `count` are block positions in the text the request carried, and `base`, `mine` and `theirs` each side's exact bytes from the hunk's first block to its last. `revision` is left out for an unwritten day and a deleted page. |
| +26. **`rebase=R`** writes the request's `body` as the draft too. With no draft, to a revision of another page, past the window, or on a deleted page it answers 422 `{refused: "rebase"}`; a stale version is the existing 409. Nothing moves. Every draft write is now compare-and-swap on the version it read, so two tabs racing cannot both win. |
| +27. **`commit=1`** answers as Save does. Version 0 with a body is a tab that never autosaved: its text becomes the draft and is committed. Version 0 with no body is refused (409). |
| +28. **A save that changes nothing** reports the outcome it computed: a `Merged` result equal to the current body still answers `merged` with the body, so the tab takes the teammate's text. From a stale tab it is `Kept`. The draft is dropped only if it is still the version the tab held. Restore still mints a revision: it is its own verb. |
| +29. **Resolve's JSON** `outcome` is `saved`, `merged`, `conflicted`, `noBase` or `kept`. A choice that no longer fits (another revision landed, the draft changed, a choice missing) answers `conflicted` with the current `revision` and `body`; no draft at all is the 404 it was. |
| +30. **Make team page's `revision`** is required: none is stale. The refusal asks the person to choose again. |
| +31. **The first scratch commit (D12) is keyed by a token**, `first=<16–64 of [A-Za-z0-9_-]>` on `POST /scratch`, which the tab draws once for the new page and sends until it learns the page's address. The server keeps (person, token) → page in memory only, for 10 minutes and at most 4,096 at once, and runs the whole create-or-look-up under one lock. So the first request creates the page and answers `{href, page, revision}`; any later one with the token is an autosave of a draft on that page, answered like any autosave plus `{href, page}`; an empty body is 422 `{empty: true}` and creates nothing. Nothing new is stored, so §4 is unchanged. The version check could not key it, because no draft row exists before the page. A token forgotten (past 10 minutes, or across a restart or a CARLOS swap) makes a second page; only a tab still sending its first token that late meets it. |
| +32. **The island** is on `/p/{id}` (and `/p/{id}/history`, the current page with the panel), `/` and `/d/{date}` written or not, and `/scratch/new`. Its `base` is the page's current revision, `"0"` for a day or page not written yet; `draft.base` is the draft's own. Link keys are the target as typed, with `#^id` for a block. A date's `title` is the day in words; a pending link's is empty. `?saved=1` and a day re-shown after a refused Save carry none: neither is the text the draft continues. |
| +33. **`POST /links/resolve`** takes form fields `target`, each a link key (anything after `|` is ignored). Over 32 is 422 `{refused: "too many"}`. The answer is keyed by each key as sent; a key with no target is left out. |
| +34. **The draft bar** says "You're seeing the saved version" under `?saved=1`, with "Show your unsaved version". "Show the saved version" is left off where nothing is saved yet (an unwritten day) and in the Markdown editor. |
| +35. **Gate 1 compares the island's revisions as one value.** Revisions are random in both worlds (doctrine §6.6), so they cannot say anything about Ana's notes; the history scope test already did the same for history links. |
| ## 14. Findings and what changed |