Mapa images: revision 4, applying Fable's diff check
Failed-write copy cleanup is a logged removal through image_trash; §2.4 and IMG7 agree with it; introduced excludes the draft's base revision; L4, IMG6, the team refusal and History's links worded to match.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+25
−13
docs/superpowers/specs/2026-11-17-mapa-images.md+25 −13
CI passed — run details
CI log
=== editor ===
cd editor && npm ci --no-audit --no-fund --loglevel=error
added 16 packages in 330ms
cd editor && node build-bundles.mjs
wrote internal/mapa/static/editor.c25f62142895a785.js (318737 bytes, 99.5KB gzipped; L12 budget 120KB)
cd editor && node --test
✔ L1: mounting then serialising gives cleanBody(body), byte for byte (54.816155ms)
ℹ 760 bodies
✔ L1: mounting a stored body adds nothing, and saving it writes nothing new (68.729481ms)
✔ L2: one edited block changes only that block's bytes; undo gives the body back (107.355099ms)
ℹ 748 single-block edits
✔ L2: inserting or deleting a block changes bytes only at the new seams, by Join (127.206998ms)
ℹ 755 inserts, 715 deletes
✔ L3: seeded edits keep the document and its Markdown saying the same thing (3180.519138ms)
ℹ 18240 edits over 760 bodies
✔ L3: Link to a page makes exactly one chip, and changes nothing else (975.062009ms)
ℹ 4124 links over 760 bodies; refused: {"A page link can’t hold another link or a line break. Select plain words.":610,"A page link can’t show [ or ]]. Select words without them.":370,"Select some words to link them to a page.":163,"Linked here, the Markdown around these words would read differently: a ! before them makes an embed, and a stray ` or * pairs up. Select other words.":17}
✔ linear: trailing spaces (36.937207ms)
✔ linear: trailing whitespace (22.435862ms)
✔ linear: unclosed web links (27.403072ms)
✔ linear: web links with no address (20.532923ms)
✔ linear: unclosed wiki links (19.085338ms)
✔ linear: unclosed embeds (22.508407ms)
✔ linear: closes only (10.493615ms)
✔ the selected words become the chip's shown text (13.482232ms)
✔ words that are the title make a plain [[Title]] (3.95971ms)
✔ spaces at the selection's edges stay outside the chip (1.031865ms)
✔ a date makes a date link, in a heading, an item and a quote (9.555185ms)
✔ bold words lose their bold: a chip carries no marks in Mapa's Markdown (0.997712ms)
✔ only the linked block's bytes change, and undo gives the body back (2.018998ms)
✔ a selection across blocks, over a chip or a break, or of brackets is refused (1.196794ms)
✔ a target the words cannot be linked to as typed is refused (0.218238ms)
✔ ⌘L: over a selection it opens Page link; with none it types [[; in code it does nothing (2.200306ms)
✔ web-linked words are refused: the address would be lost (review M4) (1.583845ms)
✔ words whose Markdown would read otherwise are refused (review M3) (1.668374ms)
✔ ⌘A then ⌘L says why, instead of doing nothing (review low 1) (0.379598ms)
✔ linkCheck says why it refuses (review low 2) (0.595802ms)
✔ golden file has bodies (0.795084ms)
✔ markup.mjs parses every body into Go's blocks, byte offsets and all (16.977404ms)
✔ markup.mjs strips and spans every block as Go does (26.774902ms)
✔ the schema's toDOM draws every body as Go renders it (53.049275ms)
✔ emphasis draws the four pinned outputs (14.212717ms)
✔ a body ends in the editor's empty paragraph (0.28952ms)
✔ a POST that never answers is aborted after the timeout (21.442989ms)
✔ a keepalive POST carries no signal, and an answer clears the timer (0.954482ms)
✔ autosave sends only what differs, and the tab owns the draft it wrote (12.381119ms)
✔ an offered draft never commits by itself; Save commits it (1.357494ms)
✔ reload, then close: sessionStorage says the draft is this tab's own (0.629826ms)
✔ closing carries text not yet sent, and the cap leaves it out (21.772273ms)
✔ clean rebase: applied, the caret survives, the base moves by the rebase POST (4.157539ms)
✔ the block under the caret is the teammate's too, and undo brings back yours (2.418193ms)
✔ typing mid-flight: the merge is not applied and the base does not move (0.968226ms)
✔ a merge the editor cannot represent stops after three tries (4.031955ms)
✔ a conflict is shown, locks the editor's own commits, and Resolve settles it (1.300627ms)
✔ leaving: a conflict stays with the choice; a failed flush offers Leave anyway; a stored draft leaves (1.67183ms)
✔ a stale tab shows the newer draft, offered, and never overwrites it (0.808639ms)
✔ the first scratch commit: empty creates nothing, then one page, then drafts on it (0.615549ms)
✔ noBase and gone lead to the existing choices (0.625447ms)
✔ a commit that merged is applied when nothing was typed since (0.797157ms)
✔ back from the cache: nothing unsaved reloads, unsaved text autosaves at once (6.104873ms)
✔ an own draft committed meanwhile goes on as a new draft (1.284417ms)
✔ a reload keeps a stored draft; unsent text still commits (0.455821ms)
✔ a page deleted mid-edit: what is typed is still stored as the draft, and nothing commits (H1) (0.928323ms)
✔ an offered draft committed in another tab: typing goes on as a new draft (H1) (1.876141ms)
✔ a commit reply without a revision is not a commit; an emptied day starts afresh (H2) (0.742335ms)
✔ Resolve stores what was typed first, and takes no typing until its answer is applied (M1) (2.962419ms)
✔ closing with a choice open, or commits held, still writes the text, never commits (M2) (1.357504ms)
✔ closing inside the settling window sends the loaded version with settling=1 (M3) (0.276856ms)
✔ a clean merge not applied because of typing still ends the choice on show (M4) (0.807878ms)
✔ settling finds the draft committed with a teammate's text: a close still writes (M-A) (0.420605ms)
✔ settling finds another tab's newer draft: the tab shows it before any typing (0.610539ms)
✔ a page deleted before the first autosave: the text is offered as a scratch page, and a close makes one (M-B) (0.496206ms)
✔ an autosave that never answered but landed: its 409 keeps the typing since (L3) (0.475046ms)
✔ marks: em outside strong, bold reopened around italics, edges outside (5.506657ms)
✔ marks close before code, links and atoms, and reopen after (0.433789ms)
✔ untouched blocks and atoms re-emit their source; edited atoms are written from attributes (6.109372ms)
✔ empty blocks are written as nothing (2.005654ms)
✔ an unclosed fence that is no longer last gets its closing fence (1.348918ms)
✔ the structure check puts Join's seam where a kept one would merge two blocks (1.884066ms)
✔ prepareSave adopts the parse when no seam or rewrite can save the document (3.232884ms)
✔ reparse: typed emphasis becomes a mark, "- " after a break becomes an item (2.235633ms)
✔ a trailing hard break stays on screen and is written as nothing (0.851689ms)
✔ the reparse waits while an IME is composing (0.866357ms)
✔ copied blocks paste with their bytes and seams; a cut and paste gives the body back (3.529237ms)
✔ a forged x-mapa slice is refused, and text from outside is read as Markdown (0.836742ms)
✔ rebuild changes origins only, outside undo history (1.546146ms)
✔ applyBody takes a teammate's block, keeps the caret, and ends untouched (1.215278ms)
✔ a block whose context changed is written again: a task toggled, a bullet, a quote (2.113184ms)
✔ a duplicate ^id typed above its holder never takes the id from it (2.447538ms)
✔ a copy-dragged block is reparsed, and says what its Markdown says (1.92878ms)
✔ a history command that throws is refused, never thrown (5.53524ms)
✔ one rename at a time, from either field (1.738755ms)
✔ an empty or unchanged title sends nothing (0.170368ms)
✔ a refusal keeps what was typed, and the title (0.225551ms)
✔ the pending state holds for the busy rule (4.052103ms)
✔ a failed POST says so and keeps the title (0.334193ms)
✔ Update links posts the confirm page's POST (0.258141ms)
✔ clean is CleanTitle's whitespace rule (0.125324ms)
✔ the saver's base follows a rename made over it, and only that (0.262129ms)
✔ closing sends the rename as one keepalive POST (1.312038ms)
✔ a drag whose anchor the document no longer reaches selects to its end (6.185564ms)
ℹ tests 90
ℹ suites 0
ℹ pass 90
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 4659.66519
=== 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 9.288s
? 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-17-mapa-images.md b/docs/superpowers/specs/2026-11-17-mapa-images.md| index e2a86e1..489a082 100644 |
| --- a/docs/superpowers/specs/2026-11-17-mapa-images.md |
| +++ b/docs/superpowers/specs/2026-11-17-mapa-images.md |
| @@ -1,8 +1,8 @@ |
| # Mapa images |
| -**Status:** revision 3, 2026-11-17. For review. Nothing is built. |
| +**Status:** revision 4, 2026-11-17. For review. Nothing is built. |
| - Fable reviewed revision 1 (`4d40e4e`) and found CHANGES REQUIRED: 2 high, 9 medium and 16 low findings. |
| -- Revision 2 (`c27a292`) answered them. Fable's round 2 found no high and five mediums, which this revision answers. §11 maps every finding to its change. |
| +- Revision 2 (`c27a292`) answered them. Fable's round 2 found no high and five mediums, which revision 3 (`a2392bd`) answered. Fable's diff check of revision 3 found two mediums and five lows, with no high, and said no further round was needed. This revision applies them. §11 maps every finding to its change. |
| **Asked for by Paul, 2026-11-17:** *"we should handle image uploads. CARLOS Platform has everything we need to handle that."* The Notion importer (specced separately) depends on this spec. It must bring Notion's images across as real Mapa images (§7). |
| @@ -199,7 +199,7 @@ That is the same shape as the existing rows "revision store" and "ciphertext siz |
| The structure check and the reparse rule still hold. |
| - **L4:** |
| - `markup.mjs` and Go agree on `Image` spans, byte offsets included. |
| - - `toDOM` equals Go's `Render`, `alone` class included. Both read a fixed resolution table in the golden file: available with a width and height, or unavailable. |
| + - The editor's decorated DOM (its `toDOM` output plus the `alone` node decoration, §2.1) equals Go's `Render`. Both read a fixed resolution table in the golden file: available with a width and height, or unavailable. |
| - Width, height and state come from resolutions, never from the node's attributes, as chip state does (level-up §6.4, step 2). So an image's state never makes a block count as edited. |
| ### 2.4 An image whose page becomes a team page |
| @@ -218,7 +218,7 @@ That is the same shape as the existing rows "revision store" and "ciphertext siz |
| - It writes the new page's body with the new addresses. |
| - `tx.commit` then attaches the copies by its ordinary rule (§3.2). |
| -If the write fails, the copies stay pending and are swept (§3.3). No object is orphaned. No S3 call happens while SQLite's writer lock is held. |
| +If the write fails, the verb deletes its own copies at once (§3.2, item 3). No object is orphaned. No S3 call happens while SQLite's writer lock is held. |
| The private note's own images stay private. Its older revisions still reference them, and they age out with its history. This is decision 8 applied to bytes: nothing from the private era ever becomes team-readable in place. |
| @@ -261,7 +261,7 @@ One rule, through the store's scoped accessor (`readrule.go`'s `MayRead`, `aroun |
| - the bulk verbs: "Update links", "Link it" and markers. |
| With attaching on, `tx.commit` attaches each image that is all four of: |
| - - **introduced by this commit:** referenced by the new body and not by the page's current body (for a new page, every reference is introduced); |
| + - **introduced by this commit:** referenced by the new body, and by neither the page's current body nor the draft's base revision. For a new page, every reference is introduced. So a draft started on a revision that held a planted id cannot publish it after the planter takes it out; |
| - pending; |
| - owned by the person committing; |
| - still a row inside its seven-day pending window (§3.3). |
| @@ -274,7 +274,7 @@ One rule, through the store's scoped accessor (`readrule.go`'s `MayRead`, `aroun |
| - The source must be an image that person may read. |
| - Each copy logs `uploaded`. |
| - The object work happens before any transaction (§2.4). |
| - - **When the write that was to use a copy fails** (Make team page, `draftToScratch`), that verb deletes its own copies at once: rows, then objects. So a failure holds no quota for seven days. |
| + - **When the write that was to use a copy fails** (Make team page, `draftToScratch`), that verb deletes its own copies at once, as a removal (§3.3). One transaction deletes the rows, moves their keys to `image_trash` and logs `removed` with the person as actor. The objects are deleted after it, and from the queue if that fails. So a failure holds no quota for seven days and orphans no object. |
| 4. **Restoring a deleted page** (base §3.4) creates a new page id. Its images are re-pointed to that page in the restore's transaction. |
| 5. **A draft on a deleted page** becomes a new scratch page (base §5, `draftToScratch`). This is **the one named exception to item 3's read rule.** The images on a deleted page answer 404 to everyone, so `CopyImage` would refuse them. Before that write: |
| - each image the draft references is copied for the person, **only when it is attached to the draft's own deleted page and the person passes that page's rule** (a team page, or a private page they own); |
| @@ -328,7 +328,7 @@ So an image taken out of the text stays reachable from History and comes back wi |
| - with script, "Remove from Mapa" in a selected image's bubble; |
| - without script, the Markdown screen's **Images on this page** list. It names each image attached to the page by its alt text or "Image without a description", and the viewer's own pending images referenced in the text. It links to **Open** and **Remove**. |
| - **Images already taken out of the text** are in that list too, as "Earlier image, taken out on <date>". A photo deleted from the text can still be removed from History. That list is shown with script on as well, under History. |
| - - History's drawn images link to the same confirm page. |
| + - When History shows an old revision rendered, each image drawn there links to the same confirm page. The word diff's `[image: alt]` tokens are text and link nowhere. |
| - **The confirm page** is `GET /i/{id}/remove`, and the action is `POST /i/{id}/remove`. |
| - **Who may remove:** |
| - any member, for an image on a team page, as any member may delete a page; |
| @@ -359,7 +359,7 @@ So an image taken out of the text stays reachable from History and comes back wi |
| - **Checks happen at upload and copy, never at commit.** A commit is never refused for images. |
| - Upload and copy are refused when the person is over their own allowance. |
| - They are also refused when the team pages are over the team's. |
| - - Each refusal names its own figure: "You've used 1 GiB of images" or "Team pages hold 10 GiB of images". |
| + - Each refusal names its own figure. For the person: "You've used 1 GiB of images". For the team, the sentence below. |
| - **Over the team's allowance, every upload is refused, private ones included,** because an upload does not know where it will go. The message says so: "Team pages hold 10 GiB of images, so Mapa takes no more uploads until some are removed." |
| - **The team's allowance is a soft cap.** It is checked at upload, against images already on team pages. Pending images committed later can carry the total past it, by at most what the members hold pending. |
| - **The account's plan** (§1.1) bounds everything. |
| @@ -528,7 +528,7 @@ The Markdown screen's form gains a file input and a second button, **Upload and |
| | **`tx.commit`** attaches the committer's own pending images that the commit introduces, and stamps and clears `unreferenced_at` (§3.2, §3.3) | IMG7 <br>Two mutants: attaching without the owner check; attaching ids that were not introduced | |
| | **`MakeTeamPage` copies, then writes. `Restore` re-points. `draftToScratch` copies** | IMG7, L9 <br>A mutant: Make team page copying an image that is not attached to its source | |
| | **`Store.Sweep`** sweeps images. `image_trash` is emptied off the boot path (§3.3) | IMG7, gate 8's named exemption | |
| -| **`markup.Image`, the `alone` class, `Render` and the resolver.** The text index skips the address; mentions skip alt text | L1–L4, IMG1 | |
| +| **`markup.Image`, `Render` with its `alone` class, the editor's `alone` decoration, and the resolver.** The text index skips the address; mentions skip alt text | L1–L4, IMG1 | |
| | **Event vocabulary:** object kind `image`, verbs `uploaded` and `removed`. Every event reader already filters on `object_kind = page` (index, recent, versions, verbs) | **gate 8** | |
| | **`config.go`:** `CARLOS_STORE_*` through `blobs.S3FromEnv`. A partial store boots with uploads at 503 and logs loudly (decision 4). Also `MAPA_IMAGE_QUOTA_PERSON` and `MAPA_IMAGE_QUOTA_TEAM` | `config_test.go` | |
| @@ -547,7 +547,8 @@ The Markdown screen's form gains a file input and a second button, **Upload and |
| - **Bo has typed Ana's pending id into a team page.** Each of these leaves the image unattached: |
| - Ana's own commit of that page; |
| - Ana's Revert to the revision that held Bo's text, after Bo removed it; |
| - - Ana's Restore of the page, after Bo deleted it. |
| + - Ana's Restore of the page, after Bo deleted it; |
| + - Ana's save or Resolve of a draft she started on the revision that held Bo's text, after Bo removed it. |
| - **Mutants** (`make mutate`), each of which must be caught: |
| - one drops the route's scope check; |
| - one resolves images attached to other pages; |
| @@ -588,16 +589,15 @@ The Markdown screen's form gains a file input and a second button, **Upload and |
| - an image over 10,000 px on a side or over 50 MP; |
| - an upload over either quota; |
| - an upload with no store (503); |
| - - a fifth blob operation that has waited 10 s. |
| + - an upload or copy that has waited 10 s for the blob semaphore, and a `GET /i/{id}` that has waited 30 s. Each answers 503 with `Retry-After`. |
| - Every served image carries §1.4's headers. |
| - **IMG7, lifecycle.** |
| - **Attaching:** a commit attaches only the committer's own pending images that it introduces. Bulk verbs attach nothing. |
| - **Copying:** only images the person can read are copied. |
| - **`draftToScratch`** copies only images attached to the draft's own deleted page, under that page's rule. A mutant that copies an image attached to another page must be caught. |
| - - **A failed Make team page or `draftToScratch` write** deletes its own copies at once. |
| + - **A failed Make team page or `draftToScratch` write** deletes its own copies at once. It logs `removed` and queues the keys in `image_trash`. |
| - **Make team page:** |
| - copies only images attached to its source; |
| - - leaves pending copies when its write fails; |
| - makes no S3 call inside its transaction. |
| - **Restore** re-points. A deleted page's draft brings copies into its scratch page. |
| - **`unreferenced_at`** is stamped on removal from the text and cleared on Revert. |
| @@ -780,3 +780,15 @@ There were no high findings. Fable said that once M1–M5 were applied as propos |
| | **L5** Attaching a pending image past its window | Attach needs the row still inside its seven days | §3.2 | |
| | **L6** A 10 s wait made a broken image | Serving waits 30 s, and the NodeView retries once | §1.4 | |
| | **L7** Over the team allowance, private uploads were refused without saying why | The message says so | §3.4 | |
| + |
| +**Fable's diff check of revision 3 (`a2392bd`).** No high. Fable said the answers needed no further review round. |
| + |
| +| Finding | Change | Where | |
| +|---|---|---| |
| +| **M1** §2.4 and IMG7 still said a failed write leaves pending copies, which contradicted M5 | Both now say the verb deletes its copies at once | §2.4, IMG7 | |
| +| **M2** The cleanup of failed copies logged no event and could orphan an object | It is a removal: one transaction deletes the rows, queues the keys in `image_trash` and logs `removed` with the person as actor | §3.2, IMG7 | |
| +| **L3** L4 still said `toDOM` draws `alone` | "The editor's decorated DOM", in §6's row too | §2.3, §6 | |
| +| **L4** IMG6 kept the single 10 s limit | 10 s for uploads and copies, 30 s for serving | IMG6 | |
| +| **L5** Two messages for the team refusal | One | §3.4 | |
| +| **L6** "History's drawn images" was ambiguous | Images in a rendered old revision link to the confirm page. Diff tokens link nowhere | §3.3 | |
| +| **L7** A draft based on a revision holding a planted id could publish it after the planter removed it | "Introduced" also excludes the draft's base revision. The case is in IMG1 | §3.2, IMG1 | |