oficina / mapa Public

Notion import design, revision 3: answer Fable's round 2, follow the images spec

Line-level neutralising at literal/generated seams and task boxes; a
title change as its own rename revision before the body; ImportUpdate's
kept outcome as a sentinel plus bookkeeping; every run write
lease-checked, Stop rotates the lease, one workspace per map, Start over;
bookkeeping fenced (I19); section 12 rewritten against the images spec's
AddImage/CopyImage hook.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 68eec684b4ccdeb3992b2528944aedb06e0ab022 parent fda6c12
1 file changed, +85 −40
  • docs/superpowers/specs/2026-11-17-notion-import.md +85 −40

CI passed — run details

CI log
=== editor ===
cd editor && npm ci --no-audit --no-fund --loglevel=error

added 16 packages in 325ms
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 (49.68525ms)
ℹ 760 bodies
✔ L1: mounting a stored body adds nothing, and saving it writes nothing new (70.406162ms)
✔ L2: one edited block changes only that block's bytes; undo gives the body back (95.921366ms)
ℹ 748 single-block edits
✔ L2: inserting or deleting a block changes bytes only at the new seams, by Join (103.219489ms)
ℹ 755 inserts, 715 deletes
✔ L3: seeded edits keep the document and its Markdown saying the same thing (3148.865318ms)
ℹ 18240 edits over 760 bodies
✔ L3: Link to a page makes exactly one chip, and changes nothing else (971.768328ms)
ℹ 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 (27.42696ms)
✔ linear: trailing whitespace (11.37017ms)
✔ linear: unclosed web links (17.178565ms)
✔ linear: web links with no address (28.512755ms)
✔ linear: unclosed wiki links (22.386759ms)
✔ linear: unclosed embeds (24.309164ms)
✔ linear: closes only (6.233037ms)
✔ the selected words become the chip's shown text (9.745617ms)
✔ words that are the title make a plain [[Title]] (3.936082ms)
✔ spaces at the selection's edges stay outside the chip (1.262635ms)
✔ a date makes a date link, in a heading, an item and a quote (5.332036ms)
✔ bold words lose their bold: a chip carries no marks in Mapa's Markdown (0.75622ms)
✔ only the linked block's bytes change, and undo gives the body back (1.520677ms)
✔ a selection across blocks, over a chip or a break, or of brackets is refused (0.780937ms)
✔ a target the words cannot be linked to as typed is refused (0.164156ms)
✔ ⌘L: over a selection it opens Page link; with none it types [[; in code it does nothing (1.61318ms)
✔ web-linked words are refused: the address would be lost (review M4) (0.791206ms)
✔ words whose Markdown would read otherwise are refused (review M3) (1.622086ms)
✔ ⌘A then ⌘L says why, instead of doing nothing (review low 1) (0.354552ms)
✔ linkCheck says why it refuses (review low 2) (0.609888ms)
✔ golden file has bodies (0.770247ms)
✔ markup.mjs parses every body into Go's blocks, byte offsets and all (23.273592ms)
✔ markup.mjs strips and spans every block as Go does (26.279761ms)
✔ the schema's toDOM draws every body as Go renders it (48.822962ms)
✔ emphasis draws the four pinned outputs (19.622241ms)
✔ a body ends in the editor's empty paragraph (0.368037ms)
✔ a POST that never answers is aborted after the timeout (21.522959ms)
✔ a keepalive POST carries no signal, and an answer clears the timer (1.075215ms)
✔ autosave sends only what differs, and the tab owns the draft it wrote (11.325787ms)
✔ an offered draft never commits by itself; Save commits it (1.36722ms)
✔ reload, then close: sessionStorage says the draft is this tab's own (0.68059ms)
✔ closing carries text not yet sent, and the cap leaves it out (27.56627ms)
✔ clean rebase: applied, the caret survives, the base moves by the rebase POST (2.899249ms)
✔ the block under the caret is the teammate's too, and undo brings back yours (2.218558ms)
✔ typing mid-flight: the merge is not applied and the base does not move (1.22746ms)
✔ a merge the editor cannot represent stops after three tries (3.037146ms)
✔ a conflict is shown, locks the editor's own commits, and Resolve settles it (1.019922ms)
✔ leaving: a conflict stays with the choice; a failed flush offers Leave anyway; a stored draft leaves (1.183087ms)
✔ a stale tab shows the newer draft, offered, and never overwrites it (0.720474ms)
✔ the first scratch commit: empty creates nothing, then one page, then drafts on it (0.694416ms)
✔ noBase and gone lead to the existing choices (0.592545ms)
✔ a commit that merged is applied when nothing was typed since (0.734069ms)
✔ back from the cache: nothing unsaved reloads, unsaved text autosaves at once (8.552624ms)
✔ an own draft committed meanwhile goes on as a new draft (1.8445ms)
✔ a reload keeps a stored draft; unsent text still commits (0.639413ms)
✔ a page deleted mid-edit: what is typed is still stored as the draft, and nothing commits (H1) (1.20082ms)
✔ an offered draft committed in another tab: typing goes on as a new draft (H1) (2.636678ms)
✔ a commit reply without a revision is not a commit; an emptied day starts afresh (H2) (1.01335ms)
✔ Resolve stores what was typed first, and takes no typing until its answer is applied (M1) (5.427675ms)
✔ closing with a choice open, or commits held, still writes the text, never commits (M2) (1.37252ms)
✔ closing inside the settling window sends the loaded version with settling=1 (M3) (0.39158ms)
✔ a clean merge not applied because of typing still ends the choice on show (M4) (1.066199ms)
✔ settling finds the draft committed with a teammate's text: a close still writes (M-A) (0.543033ms)
✔ settling finds another tab's newer draft: the tab shows it before any typing (0.822093ms)
✔ a page deleted before the first autosave: the text is offered as a scratch page, and a close makes one (M-B) (0.686481ms)
✔ an autosave that never answered but landed: its 409 keeps the typing since (L3) (0.707731ms)
✔ marks: em outside strong, bold reopened around italics, edges outside (6.156554ms)
✔ marks close before code, links and atoms, and reopen after (0.4397ms)
✔ untouched blocks and atoms re-emit their source; edited atoms are written from attributes (6.678588ms)
✔ empty blocks are written as nothing (2.46059ms)
✔ an unclosed fence that is no longer last gets its closing fence (1.852496ms)
✔ the structure check puts Join's seam where a kept one would merge two blocks (2.29449ms)
✔ prepareSave adopts the parse when no seam or rewrite can save the document (3.576502ms)
✔ reparse: typed emphasis becomes a mark, "- " after a break becomes an item (2.700518ms)
✔ a trailing hard break stays on screen and is written as nothing (0.55717ms)
✔ the reparse waits while an IME is composing (0.858201ms)
✔ copied blocks paste with their bytes and seams; a cut and paste gives the body back (3.862675ms)
✔ a forged x-mapa slice is refused, and text from outside is read as Markdown (1.017979ms)
✔ rebuild changes origins only, outside undo history (1.759793ms)
✔ applyBody takes a teammate's block, keeps the caret, and ends untouched (1.682448ms)
✔ a block whose context changed is written again: a task toggled, a bullet, a quote (3.675416ms)
✔ a duplicate ^id typed above its holder never takes the id from it (0.826211ms)
✔ a copy-dragged block is reparsed, and says what its Markdown says (1.094471ms)
✔ a history command that throws is refused, never thrown (3.768228ms)
✔ one rename at a time, from either field (2.127639ms)
✔ an empty or unchanged title sends nothing (0.191737ms)
✔ a refusal keeps what was typed, and the title (0.226833ms)
✔ the pending state holds for the busy rule (8.214862ms)
✔ a failed POST says so and keeps the title (0.564463ms)
✔ Update links posts the confirm page's POST (0.260796ms)
✔ clean is CleanTitle's whitespace rule (0.132367ms)
✔ the saver's base follows a rename made over it, and only that (0.311802ms)
✔ closing sends the rename as one keepalive POST (3.015254ms)
✔ a drag whose anchor the document no longer reaches selects to its end (4.322963ms)
ℹ tests 90
ℹ suites 0
ℹ pass 90
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 4583.586125
=== 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.323s
?   	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-notion-import.md b/docs/superpowers/specs/2026-11-17-notion-import.md
index 5375665..c525b74 100644
--- a/docs/superpowers/specs/2026-11-17-notion-import.md
+++ b/docs/superpowers/specs/2026-11-17-notion-import.md
@@ -1,13 +1,13 @@
# Notion import: pages into Mapa, databases into Fichas later
-**Status:** revision 2, 2026-11-17, for review. Revision 1 (`bb9b30d`) was reviewed by Fable (CHANGES REQUIRED: 3 high, 12 medium, 12 low); §24 records what changed. **Paul approved the import on 2026-11-17**, with his 2026-11-14 defaults (§1) and one overrule: images come in as real Mapa images. Everything marked **Proposed** in this spec is the author's recommendation and has not been ruled. Nothing is built.
+**Status:** revision 3, 2026-11-17, for review. Fable reviewed revision 1 (`bb9b30d`, CHANGES REQUIRED: 3 high, 12 medium, 12 low) and revision 2 (`fda6c12`, CHANGES REQUIRED: no high, 4 medium, 11 low). §24 records what each changed. **Paul approved the import on 2026-11-17**, with his 2026-11-14 defaults (§1) and one overrule: images come in as real Mapa images. Everything marked **Proposed** in this spec is the author's recommendation and has not been ruled. Nothing is built.
**Branch:** `design/notion-import` (Mapa).
**Base specs, which still bind:**
- Mapa `2026-11-12-mapa-design.md` (approved): §3 model and the shared namespace, §4 the seal boundary, §5 history, §6 index, gate 8.
- Mapa `2026-11-14-mapa-level-up.md` (approved): §6.3 the editor's subset, §6.4 fidelity.
-- Mapa images, `2026-11-17-mapa-images.md` on `design/images`, **not yet written** when this revision was. §12 states the hook this import needs from it as assumptions A1–A7, for that spec to confirm or change.
+- Mapa images, `2026-11-17-mapa-images.md` on `design/images`, revision 2 (`c27a292`, for review). §12 uses its §7 hook. Revisions 1 and 2 of this spec stated assumptions in its place, before it existed.
- memoria `2026-09-05-notion-ingest-design.md`: its connector is the code this import lifts (§3) and retires (§16).
- Fichas `2026-09-19-fichas-design.md` and the type-designer draft on `design/type-designer`: only for §17's sketch.
- Suite doctrine revision 11 (`91affa1`, as Mapa consumes it): S1–S3, for §16.
@@ -200,13 +200,15 @@ A run is started by an importer's `POST`, mounted inside the session and CSRF gr
### 8.3 Resuming
-- **Single-flight, with a lease.** One run at a time per instance. Starting or resuming a run draws a random **lease** and writes it to the run's row with a conditional update. **Every page transaction checks the lease** and fails if it has changed. So a goroutine that has been reclaimed cannot write another page: its next transaction fails and it exits. Two goroutines can never write the same ledger.
+- **Single-flight, with a lease.** One run at a time per instance. Starting or resuming a run draws a random **lease** and writes it to the run's row with a conditional update. **Every write the run makes checks the lease**: page transactions, and every bookkeeping write too (staging a tree, a row's state, `seen_run`, counters, the heartbeat), each as `… WHERE lease = ?` on the run row in the same transaction. A goroutine whose lease has moved therefore changes nothing at all: its next write fails and it exits. Two goroutines can never write the same ledger.
- **At boot,** a run in `surveying` or `writing` becomes `interrupted`. No run can be live at boot (memoria §9).
- **Liveness is time and progress.** A 20-second ticker writes `heartbeat_at` (memoria §1.3), and every page written or surveyed writes `progress_at`. A run may be reclaimed by Resume when its heartbeat is older than two minutes **or** its progress is older than ten minutes. A ticker alone would keep a wedged run alive forever.
- **The goroutine recovers its own panics** and ends the run `failed` with `internal`, so a crash never leaves a run that looks alive.
-- **Stop** is a button while a run is active. It cancels the run's context. The run ends `stopped`, which offers Resume like `interrupted`.
-- **Disconnect, Finish and Forget are refused while a run is active.** Their pages say "Stop the run first". The run holds the token and reads the staged trees and the map.
-- **Resume and Start.** After `interrupted` or `stopped`, the page offers Resume, which continues the same run with its staged trees. Start is offered only after `done` or `failed`; a failed run's staged trees are cleared when the next run starts.
+- **Stop** is a button while a run is active. In one write it sets the run `stopped` **and rotates its lease**, then cancels the context. So Stop takes effect at once even if the goroutine ignores its context: the goroutine's next write is refused. `stopped` offers Resume like `interrupted`.
+- **Disconnect, Finish and Forget are refused while a run is active.** Their pages say "Stop the run first", and Stop always works, so a stuck run never blocks them.
+- **Disconnect, or replacing the token, ends any resumable run.** The run becomes `failed` with `disconnected`, its staged trees are cleared, and the next run is a Start. A Resume never runs on a token other than the one its survey used.
+- **One workspace per map.** The connection keeps the workspace id `GET /v1/users/me` returns, sealed. A token for a different workspace is refused while a map exists: "This import came from another Notion workspace. Forget the import first."
+- **Resume, Start over and Start.** After `interrupted` or `stopped`, the page offers **Resume**, which continues the same run with its staged trees, and **Start over**, which clears them and begins a new survey (for staged trees that are old, or a workspace that has changed since). Start is offered after `done` or `failed`; a failed run's staged trees are cleared when the next run starts. Staged trees of a run nobody resumes are deleted with the token under §6's 90-day idle retention.
- **Resuming a survey** walks the pages already surveyed *in this run* from their staged trees, with no requests, and asks Notion only for the rest. This is cheaper than memoria's resume, which repeated the whole traversal.
- **Resuming a write** continues from the rows still `staged`. Each page's write is one transaction that also writes its map row (§14.1), so a page and its record in the map land together or not at all. A crash between two pages can never make a second copy on Resume.
- An interrupted run says so, with Resume. It never shows as finished.
@@ -256,7 +258,7 @@ A Mapa title must be unique across titles and aliases after case and accent fold
**Making a title fit** (applied in this order, deterministic, and each change listed in the report):
1. `[` and `]` become `(` and `)`. `|` becomes `/`. `#` followed by a digit is removed (`Issue #42` → `Issue 42`); any other `#` becomes a space. `^` is removed. Runs of spaces collapse.
2. An empty title is `Untitled`.
-3. Over 120 characters: cut at the last word boundary that leaves room, then `…`.
+3. Over 120 characters: cut at the last word boundary that leaves room, then `…`; with no word boundary in reach, cut at a rune.
4. Date-shaped (`2024-03-05`): §9.3.
**Every comparison is on `Fold()`ed text** (case and accent folded, `namespace.go`), as the store's title print is: "free", "planned for another page" and "date-shaped" all fold first, and the date test runs on the fitted title.
@@ -266,7 +268,7 @@ A Mapa title must be unique across titles and aliases after case and accent fold
2. the title, then the parent's (fitted) title in brackets: `Week 1 (Onboarding)`;
3. the same, then ` 2`, ` 3`, and on.
-A root page has no parent, so its second candidate is `Week 1 (Notion)`. **A candidate never exceeds 120 characters:** the base title is cut, with `…`, to leave room for the bracket and the number before they are added.
+A root page has no parent, so its second candidate is `Week 1 (Notion)`. **A candidate never exceeds 120 characters:** the parent's title inside the bracket is cut first, to at most 40 characters with `…`; then the base title is cut, with `…`, to leave room for the bracket and the number. Cuts follow rule 3.
- **An existing Mapa page with the same title is never merged into.** Mapa's `Acme` is somebody's page. Notion's `Acme` becomes `Acme (Notion)` and the report lists it.
- **Assignment is deterministic.** Survey order is the roots sorted by Notion `created_time` then id, then block order inside each page. The same workspace gives the same titles.
@@ -310,7 +312,7 @@ Mapa has no tree. Notion's tree becomes links, both ways:
| `toggle` | a paragraph of the summary in `**bold**`, then its children as ordinary blocks after it | the collapse (counted) |
| `quote` | `> ` quote, one `>` line per line of text. **Text children** (paragraphs, list items, to-dos) follow as more `>` lines, a list item as `> - item`. **Every other child** is written by its own row of this table straight after the quote | the children's block shapes inside the quote; hoisted children (counted) |
| `callout` | as `quote`, the icon's emoji first if it is an emoji: `> 💡 Remember…` | the colour, a custom or file icon, hoisted children (counted) |
-| `code` | a fence: ```` ``` ```` plus the language (lowercased, spaces to `-`; `plain text` gives none). If the code holds a line starting ```` ``` ````, the fence is `~~~`. If it holds both, the block is written as a placeholder with the code in it (counted). The caption, if any, follows as an `*italic*` paragraph | — |
+| `code` | a fence: ```` ``` ```` plus the language (lowercased, spaces to `-`; `plain text` gives none). If the code holds a line starting ```` ``` ```` after any leading spaces (the closing test trims them all: `blocks.go`, and `markup.mjs`'s port), the fence is `~~~`. If it holds both, the block is written as a placeholder with the code in it (counted). The caption, if any, follows as an `*italic*` paragraph | — |
| `divider` | `---` | — |
| `table`, `table_row` | pipe-table text, one paragraph: a header row, a `\| --- \|` row when Notion marks a header, then one line per row. Mapa shows it as lines of text (level-up D10); a future vault export (base decision 15, not built) would render it as a table. A cell's line breaks become spaces; a `\|` inside a cell becomes `/` | layout, column and row header styling. A table that needs sorting or typed columns belongs in Fichas |
| `column_list`, `column` | each column's blocks in order, left to right | side-by-side layout (counted) |
@@ -387,21 +389,31 @@ Each placeholder's Notion id is recorded, sealed, on the ledger row, so phase 2
- **A Notion page URL** (`notion.so/…`, `www.notion.so/…`, a workspace's `*.notion.site/…`, or a bare `/…`), whose last 32 hex digits are the id of an imported page, becomes a `[[link]]` with the run's text as shown text. A link to a block inside it (`#…`) becomes a link to the page, counted.
- **A Notion URL to a page that is not imported** stays a web link while it is `https`. It works for people with Notion access until switch-over, and the report lists it under "links still pointing at Notion".
- **Any other link** is `[text](url)` when `markup.SafeURL` accepts it, and the text alone otherwise (counted). Mapa never makes `javascript:` or `data:` clickable, and the import adds no way round that.
+- **A label that cleaning leaves empty** is replaced by the address itself, so a link never loses its text.
- **Link syntax has limits, and the mapper writes inside them** (`markup/scan.go`): a web link's address may hold no `)` or whitespace, and its label no `]` or line break; a wiki link's shown text may hold no `[`, `]`, `|` or line break. So the mapper always writes the `[text](url)` form, never a bare URL; percent-encodes `(`, `)` and whitespace in the address; and in labels and shown text turns `[` `]` into `(` `)`, `|` into `/`, and line breaks into spaces. `https://en.wikipedia.org/wiki/Foo_(bar)` is written `…/Foo_%28bar%29`.
### 11.4 Literal text Mapa would read as markup (D16)
Mapa has **no escapes** (level-up D11). The editor accepts that because a person typing `*word*` sees what it becomes. An import has nobody watching, and Notion text that discusses Markdown or code is ordinary. Left alone, a Notion line beginning ```` ``` ```` would open a fence that runs to the end of the page (`markup/blocks.go`: an unclosed fence has no end), and two stray backticks would pair up and swallow a link between them (`markup/spans.go`, `codeSpan`).
-**"Meant" is computed first.** Before writing a block, the mapper decides what it means: the block's kind and level, its lines, and its inline parts (literal text, marks, links, mentions, code spans). The check (D9) compares `markup.Parse` and `markup.Spans` of the written block with that, part for part. Literal text must parse as literal text.
+**"Meant" is computed first.** Before writing a block, the mapper decides what it means: the block's kind and level, its task box if it is a to-do, its lines, and its inline parts (literal text, marks, links, mentions, code spans). The check (D9) compares `markup.Parse`, `markup.Spans` and the task box (`render.go`'s `taskBox`) of the written block with that, part for part. Literal text must parse as literal text.
+
+**The table runs over the written line, not over literal text alone.** A reading can form where literal text meets syntax the mapper generated: a literal `!` before a generated `[[Title]]` or date link makes an embed (`spans.go`, the `![[` case); a literal `[` before a generated `[text](url)`, with a later literal `]]`, makes a wiki link. So the mapper assembles each line from its parts, then applies the table to the whole line, inserting only into literal parts or at the seam between a literal part and a generated one.
+
+**The mapper uses `markup`'s own predicates**, exported for the purpose (`StartsBlock`, the item, heading, fence, quote, rule and task patterns, `SafeURL`), never copies of their regexes. A second copy would drift from the parser it is meant to agree with.
**Neutralising.** Mapa has no escape character, so the mapper uses one invisible character, **U+200B ZERO WIDTH SPACE**, at the single place that breaks each reading, and one look-alike for backticks. Each use is counted and the report lists the pages. Go's `TrimSpace` and JavaScript's `trim` both leave U+200B alone, and Go's `\s` does not match it, so the parser and the editor's port agree (level-up §6.4's parity hazards; a corpus case each).
| Literal text that would be read as | Where it is checked | Written as |
|---|---|---|
| a block start at the beginning of any line of a block: a fence (```` ``` ````, `~~~` after any spaces), a heading (`# `), a list item (`- `, `* `, `+ `, `1. `, `1) `), a quote (`>`), a rule (`---`, `***`, `___`) | every line, the first and every hard-break continuation | U+200B before the line's first non-space character. The line looks the same and stays inside its block |
-| `[[` or `![[` | the block's joined literal text, **across run boundaries** (`[[Acme` in a bold run then `]]` in the next is caught) | U+200B between the two `[` |
+| `[[` or `![[` | the written line, **across run boundaries** (`[[Acme` in a bold run then `]]` in the next is caught) | U+200B between the two `[` |
+| a literal `!` or `[` immediately before a generated link (`[[…]]`, a date link, `[text](url)`, and the images spec's `![alt](/i/…)` once built) | the seam between them | U+200B between the literal character and the generated `[` |
+| a literal `[label](http…)` or `![alt](/i/…)`, which would become a web link or, once the images spec is built, an image | the written line | U+200B between `]` and `(` |
+| a to-do's box: a bullet whose literal text starts `[ ] `, `[x] ` or `[X] ` | a bullet list item's text | U+200B before the `[`. (A real to-do is generated as one, and its box is part of "meant") |
| a trailing ` ^word` (a block marker) | the block's last line | U+200B before the `^` |
+
+**The images spec revisits this table** once its image span exists in `markup`: the rows naming `![alt](/i/…)` are written against its §2.1 and get fixtures in that build.
| a backtick | any literal text | U+02CB MODIFIER LETTER GRAVE ACCENT (ˋ), which looks like one. A code-annotated run is the only source of real code spans |
| a bare `http(s)://` | — | left alone: Mapa links it, and Notion usually had |
| `*` | — | left alone. A literal `*a*` becomes emphasis, as in the editor (D11). A marked run holding `*` loses its mark (§11.1) |
@@ -414,25 +426,27 @@ Mapa has **no escapes** (level-up D11). The editor accepts that because a person
**P9: Notion-hosted images become real Mapa images.**
-**The images spec is not written yet.** This spec states what it needs as assumptions. The images spec confirms or changes each, and this section is revised to match before either is built.
+**This section follows the images spec**, `2026-11-17-mapa-images.md` on `design/images`, at revision 2 (`c27a292`, for review, not yet approved). Its §7 is the hook this import uses. Revisions 1 and 2 of this spec stated assumptions (A1–A11) before that spec existed. Each is now answered from it, and where it differs, this spec follows it. If the images spec changes before approval, this section changes with it.
-- **A1, a verb.** The store has a verb that adds an image, by an actor, with an event, from bytes and a declared type, and returns the Markdown that references it.
-- **A2, one transaction.** That verb runs inside the same `Store.write` as the create or commit whose body references the image, so a page and its images land together or not at all.
-- **A3, the reference is in the subset.** Whatever syntax references an image is parsed by `markup` and by the editor's port, and passes the structure check (D9).
-- **A4, checks.** The images spec decides formats and a size cap, and the image verb checks both by sniffing the bytes, never by trusting the type Notion declares. The file transport (§5) reads at most that cap.
-- **A5, alt text.** An image carries alt text. The import uses the Notion caption.
-- **A6, sealed.** Image bytes are sealed under their own purpose, and base §4's list gains whatever the images spec makes plaintext.
-- **A7, lifetime.** An image is kept while any revision in the window references it, so an import update that replaces an image leaves the old one to retention.
-- **A8, scope.** The images spec says whether a reference is valid on any page or only on the page it was added to. If only that page, `notion_images` is keyed by (block, page), and a Notion block that moves to another page is downloaded again.
-- **A9, existence.** The store can say whether an image reference still resolves, so an image retention removed is fetched again rather than referenced dead.
-- **A10, caps beyond one image.** The images spec says whether there is a per-page or per-team total. An image over any cap becomes a placeholder, counted by reason.
-- **A11, the event.** The image verb's event name is the images spec's. It enters the plaintext log, so it goes in base §4's list there.
+**What the images spec gives** (its section in brackets):
+- **`Store.AddImage(ctx, actor, data)`** reads, checks and strips one image, seals it, stores it in CARLOS's bucket as ciphertext, and records it as a **pending** image owned by `actor`, logging `uploaded` (object kind `image`) by that person (§7, §3.2). It is its own write, before and outside the page's transaction. It waits for the blob semaphore rather than failing (§1.4).
+- **`Store.CopyImage(ctx, actor, publicID)`** makes a new pending image from one the actor may read, with a new object (§3.2, §7).
+- **`Image.Markdown(alt)`** gives `![alt](/i/<public id>)`, with alt cleaned: no `[`, `]` or line break, at most 1,000 bytes (§2.1). That form is in Mapa's subset once the images spec is built, parsed by `markup` and by the editor's port, with its own fidelity gates (§2.3).
+- **A commit attaches** each pending image that the new body introduces and the committer owns (§3.2). Every write that goes through `tx.commit` does this, so `ImportCreate` and `ImportUpdate` attach the run's images without any import code of their own.
+- **One image, one place.** An image belongs to one page; on any other page it renders as "Image not available" (§3.1). A file that appears on two pages is added once and copied for the second (§7).
+- **Checks:** at most 10 MiB, 50 megapixels, and 10,000 px a side; the type is sniffed from the bytes (§3.4, §5). Refusals are typed: `ErrImageType`, `ErrImageTooLarge`, `ErrImageDimensions`, `ErrImageQuota`, `ErrNoImageStore` (§7).
+- **Quota:** images on team pages count against the team's allowance, `MAPA_IMAGE_QUOTA_TEAM`, 10 GiB by default, checked at `AddImage` and `CopyImage`, never at commit (§3.4).
+- **Lifetime:** an image the body stops referencing is kept for the 90-day window, then swept at wake (§3.3). A pending image nobody commits is swept after seven days, so a failed run needs no cleanup (§7).
+- **Leaks:** the `images` table shows how many images each page holds, who uploaded each and when, and its size to within 64 KiB (§1.3). The import adds nothing to that row.
**What the import does:**
-- **When:** during Write, before the page's transaction, for each image block that is new or whose `last_edited_time` changed since its last import. Notion's file URLs are signed and expire after about an hour, and Survey may finish long after it read the block. So Write fetches the block again (`GET /v1/blocks/{id}`) for a fresh URL and downloads it through the file transport **before** opening the page's transaction, holding the bytes in memory; the transaction then adds the images and writes the page (A2). No network call happens inside a transaction.
-- **Unchanged images are not downloaded again.** `notion_images` maps a Notion block to the Mapa image it became (§15). An unchanged block reuses it.
-- **A failure is not the page's failure.** An image that fails (host refused, too big, a format the images spec refuses, a 403 from an expired URL) becomes a placeholder, and the page is written. The report counts it by reason. **A permanent failure is recorded** in `notion_images` with the block's edit time, and is not downloaded again until the block changes. A transient one (network, 429, 5xx) is tried again on the next run.
-- **External images** stay links (D13). **Q2** asks Paul whether he wants a second, stricter fetcher for them: public addresses only, `https`, the same caps, no cookies. It would be the first fetch from a host a page chooses, and it is not proposed here.
+- **When:** during Write, **before** the page's transaction, for each image block that is new to this page or whose `last_edited_time` changed since its last import. Notion's file URLs are signed and expire after about an hour, and Survey may finish long after it read the block. So Write fetches the block again (`GET /v1/blocks/{id}`) for a fresh URL, downloads it through the file transport (§5), and hands the bytes to `AddImage` as the run's person. No network call and no `AddImage` happens inside a page transaction.
+- **Then** `ImportCreate` or `ImportUpdate` writes the body holding `image.Markdown(caption)` (the Notion caption as plain text; empty when there is none) and its commit attaches the image.
+- **Reuse.** `notion_images` maps (Notion block, Mapa page) to the Mapa image's public id, sealed. An unchanged block on the same page reuses it, after the run checks, in its own read, that the image row still exists and is attached to that page; one the sweep or a member's "Remove from Mapa" took away is fetched again. **A block that moves to another page**, or a synced block that shows one Notion file on several pages, gets `CopyImage` from the existing Mapa image where the runner may read it, and a fresh download otherwise.
+- **A failure is not the page's failure.** A refused or failed image becomes the images spec's text line, `(Image not imported: <caption or "an image">, <reason>)`, in its place, and the page is written. The report counts images by reason. **A permanent refusal** (type, size, dimensions, host not allowed) is recorded on its `notion_images` row with the block's edit time and is not downloaded again until the block changes. **A transient one** (network, 429, 5xx, an expired URL) is tried again on the next run.
+- **Quota.** Notion's block objects carry no file size, so the run cannot total the images before it starts. Instead, the Start page shows the team's remaining image allowance. On the first `ErrImageQuota` the run stops downloading for the rest of that run: every later image becomes the text line, with "the team's image allowance is full", and the report says so at the top. Raising the allowance and running again fills them in, because those pages render differently and are still untouched (§13.2). `ErrNoImageStore` does the same from the first image: "images aren't set up on this Mapa yet".
+- **External images** stay links (D13). The images spec leaves fetching them to this spec (its §7), and this spec does not propose it. **Q2** asks Paul.
+- **Literal image syntax.** Notion text that happens to read `![…](/i/…)` would become an image reference once the images spec is built. §11.4 neutralises it.
## 13. Re-runs and idempotency
@@ -479,16 +493,22 @@ Write commits pages one at a time while members may be using Mapa. If a member c
### 14.1 The two store methods (D15)
The import writes pages only through two methods in package `mapa`, each **one `Store.write`**:
-- **`ImportCreate`** checks the lease (§8.3), claims the title through the same namespace code `CreateTeamPage` uses (refusing a taken or date-shaped title exactly as it does), creates the page with its record (`origin`, `imported`), adds its images (A2), writes the map row's coordinate, and logs `created`.
-- **`ImportUpdate`** checks the lease, re-reads the page, and writes nothing (outcome *kept*) if its revision is not the one the map holds or it is gone. Otherwise it writes title and body as **one revision**: a changed title goes through the rename verb's namespace code (old title to alias), and the event is `renamed` when the title changed, `edited` when only the body did. It adds images, updates the coordinate's revision, and never touches drafts.
+- **`ImportCreate`** checks the lease (§8.3), claims the title through the same namespace code `CreateTeamPage` uses (refusing a taken or date-shaped title exactly as it does), creates the page with its record (`origin`, `imported`), writes the map row's coordinate, and logs `created`. Its commit attaches the run's pending images that the body introduces (§12).
+- **`ImportUpdate`** checks the lease and re-reads the page. **If its revision is not the one the map holds, or it is gone, the method returns the outcome *kept* and its transaction rolls back** with nothing written: `Store.write` refuses a transaction that logged no event (`store.go`, `ErrUnlogged`), so "write nothing" is a sentinel, the shape `errNoChange` and `quiet` already have. Otherwise, inside the one `Store.write`:
+ - **a title change is its own revision first**, logged `renamed`, holding exactly the previous body, through the rename verb's namespace code (old title to alias), with `carryDrafts` moving drafts on the old revision to it. That keeps `verbs.go`'s invariant that a rename's revision holds its predecessor's body, which `renamedTo` and the editor's base-following rely on;
+ - **a body change is a second revision**, logged `edited`. Drafts are not carried over it: a teammate's draft merges against it on commit (§13.2);
+ - a title-only change is the first alone, a body-only change the second alone;
+ - the coordinate records the **last** revision written. Its commit attaches the run's pending images (§12).
- Neither merges, and neither can be called from a handler: only the run calls them, and a gate (I17) fails if anything else does.
+- **Outcomes that write no page** (*kept*, *unchanged*, *deleted in Mapa*) and `seen_run` are recorded afterwards by a lease-checked bookkeeping write (§14.2). A crash between the two leaves the row as it was, and the next run decides again; I17 covers it.
- **A gate kills the run between every pair of statements** in both methods and in the run loop, resumes, and expects no second page, no false *kept*, and a map that agrees with the pages (I17).
### 14.2 What history records
- **Every import write is a Mapa write** in one transaction with its event (gate 8). The verbs are Mapa's existing ones: `created`, `edited`, `renamed`. The actor is the person who pressed Start or Resume (P7). **Mapa is never an actor** (base §2).
- **No new verb.** An `imported` verb would add nothing the sealed record does not say. It would also not hide much: see §15 on what the plaintext already shows.
-- **Bookkeeping is a third named exemption from gate 8**, beside drafts and retention (base §5): run rows, heartbeats, progress, staging, clearing staged trees, and ledger state that changes no page. A page write is never bookkeeping. **The person's own acts on the connection do log events**, under a new object kind, `import`, naming the person: `connected`, `token_replaced`, `disconnected`, `finished`, `forgotten`, `started`, `stopped`. S1 and the index ignore object kind `import`. §21 records the exemption and the object kind as amendments to base §3.1 and §5.
+- **Bookkeeping is a third named exemption from gate 8**, beside drafts and retention (base §5): run rows, heartbeats, progress, staging, clearing staged trees, and ledger state that changes no page. A page write is never bookkeeping. **The person's own acts on the connection do log events**, under a new object kind, `import`, naming the person: `connected`, `token_replaced`, `disconnected`, `finished`, `forgotten`, `started`, `stopped`. `resumed` and `started_over` too. These are routes a person posts to, so gate 8's route test (`gate8_test.go`) covers them like every other. S1 and the index ignore object kind `import`. §21 records the exemption and the object kind as amendments to base §3.1 and §5.
+- **Bookkeeping touches only `notion_*` tables, and only from the run.** It goes through one function whose transaction may name no other model; its writes are lease-checked (§8.3), so a run still going after Start's request has returned writes only while it holds its lease. **I19 fences the exemption:** a Survey-only run changes no row outside `notion_*`, and the bookkeeping function, mutated to touch `pages`, `revisions`, `aliases`, `title_prints` or `images`, goes red.
- **The sealed record gains two optional fields** (base §3.1's `Record`, JSON, additive):
- `origin`: `{source: "notion", created, edited}`, Notion's own created and last-edited times for the page. Set by the import, and carried forward by every later commit, so a page always knows where it came from, even after its imported revision ages out of the 90-day window. Every verb already opens the record, changes it and seals it again (`CommitFrom`, `Retitle`, `Revert`, `Restore`, relink, markers), so carrying `origin` needs nothing. A page restored from a deleted imported page keeps `origin`: its text did come from Notion. The map does not follow it (§13.2).
- `imported`: `true` on a revision the import wrote. **`tx.commit` clears it on every write unless the caller is `ImportCreate` or `ImportUpdate`.** The verbs carry the whole record forward by default, so without that one line a teammate's edit would read "imported from Notion". Gate I18 runs every verb on an imported page and checks it is cleared and `origin` kept.
@@ -500,16 +520,16 @@ The import writes pages only through two methods in package `mapa`, each **one `
## 15. Sealing
-**New purposes:** `notion.token`, `notion.workspace`, `notion.coordinate` (a row's Notion id, its Mapa page id, the revision the import last wrote, the ids it mentioned that were not imported, its placeholders' ids), `notion.staged` (a surveyed tree), `notion.image` (an image block's id, edit time and Mapa image). Print keys are derived apart, as base build note 21 does: `oficina/mapa:print:notion.page` and `…:notion.image`.
+**New purposes:** `notion.token`, `notion.workspace` (its name and id), `notion.coordinate` (a row's Notion id, its Mapa page id, the revision the import last wrote, the ids it mentioned that were not imported, its placeholders' ids), `notion.staged` (a surveyed tree), `notion.image` (an image block's id, edit time and Mapa image). Print keys are derived apart, as base build note 21 does: `oficina/mapa:print:notion.page` and `…:notion.image`.
**New tables and their plaintext,** to be added to base §4's list and to `plaintext_test.go` with the build:
| Table | Plaintext | Sealed | What the plaintext leaks |
|---|---|---|---|
| `notion_connections` (one row) | `id`, `created_by` (member id), `created_at`, `verified_at` | token, workspace name | that a Notion connection exists, who made it, when it was last checked |
-| `notion_runs` | `id`, `actor`, `state`, `started_at`, `heartbeat_at`, `finished_at`, the counters, `error_code` | — | when imports ran, who ran them, how many pages each created, kept, failed |
+| `notion_runs` | `id`, `actor`, `state`, `lease` (random, redrawn on start, resume and Stop), `started_at`, `heartbeat_at`, `progress_at`, `finished_at`, the counters, `error_code` | — | when imports ran, who ran them, how many pages each created, kept, failed. The lease is random and says nothing |
| `notion_pages` (the map) | `id`, `notion_print` (unique), `state`, `error_code`, `surveyed_run`, `seen_run` | the coordinate record (Notion id, last Notion title, Mapa page id, last written revision, unresolved mention ids, placeholder ids); the staged tree | how many Notion pages exist and their states |
-| `notion_images` | `id`, `block_print` (unique) | the image record | how many images were imported |
+| `notion_images` | `id`, `block_print` (unique: an HMAC of the Notion block id and the Mapa page id together), `state` (`imported`, `refused`, `failed`) | the image record (block id, block edit time, Mapa page id, public id, refusal reason) | how many images were imported, refused and failed. The images spec's own `images` table holds the rest (§12) |
- **What the file still shows, said plainly.** The coordinate is sealed, so no column joins a ledger row to a Mapa page. **But the plaintext event log does.** A run's `created` events, by the run's actor, inside the run's window in `notion_runs`, mark which team pages it made, and sequential `pages.id` and `notion_pages.id` in survey order line them up row for row. So the file shows **which team pages came from a Notion import, and roughly their order in Notion**. It does not show their titles, bodies or Notion ids. This goes in the leak list. `notion_pages` carries no `updated_at`, which would be a second join.
- **Prints are HMACs under the instance key**, equality only, as every print in Mapa (base §4).
@@ -600,7 +620,7 @@ The import writes pages only through two methods in package `mapa`, each **one `
- **I1, fidelity.** For every fixture, the mapper's body equals a committed golden file, passes the structure check (D9) against the meaning computed first (§11.4), and loses nothing outside §10–§11's tables: each loss is in the counts. Fixtures include every row of §11.4's table, across run boundaries; fences and backticks in ordinary text; a heading with a line break; link addresses with `(`; labels with `]`; a marked run holding `*`; and partly-italic bold. No fixture may produce the fallback. **Each imported body opened in the editor and left alone serialises to the same bytes** (L1's rule, run over the import goldens, which join `markup/testdata/corpus/`).
- **I2, an idempotent re-run.** Run, then run again on the same fixtures: no revision, no event, no image download, every page `unchanged`.
-- **I3, untouched and kept.** Change two pages in the fake. Edit one of them in Mapa, rename a third in Mapa. Re-run: the untouched page updates, as the runner, with one event; the edited and renamed pages are kept and listed.
+- **I3, untouched and kept.** Change two pages in the fake. Edit one of them in Mapa, rename a third in Mapa. Re-run: the untouched page updates, as the runner, in one transaction (one event, or two when the title changed too: `renamed` then `edited`); the edited and renamed pages are kept and listed. A teammate's tab holding a draft on the untouched page follows the rename's revision and merges against the edit.
- **I4, never delete on absence.** Two pages imported; the fake drops one; the run is `done` and both pages stand. An interrupted survey reports no absence.
- **I5, links.** Mentions resolve to final titles, collision-renamed ones included. An unshared target is plain text and counted; sharing it and re-running links it where the source is untouched. A Notion URL to an imported page becomes a `[[link]]`.
- **I6, titles.** Duplicates, `[ ] | # ^`, over-long, empty and date-shaped titles all fit by §9.2. The same fixtures give the same titles twice. An existing Mapa page with the title is never written to. A member taking a planned title mid-run is handled by the fix-up pass.
@@ -609,13 +629,15 @@ The import writes pages only through two methods in package `mapa`, each **one `
- **I9, plaintext.** The new tables' plaintext columns are exactly §15's. The file scan runs a full import over fixtures carrying canary titles, bodies, a canary token and canary Notion ids, then reads every byte on disk, WAL included: none appears.
- **I10, no Notion content in logs**, observed over a run against the fake whose error bodies carry canaries (memoria N13).
- **I11, the token is never rendered**: no 8-character run of it in any response (memoria N14).
-- **I12, resuming.** A run left `surveying` becomes `interrupted` at boot and Resume runs. Stop ends a run `stopped`. Disconnect, Finish and Forget are refused during a run. A run with a live ticker and no progress for ten minutes is reclaimable. A resumed survey makes no request for a page already surveyed in that run. A resumed write writes no page twice.
+- **I12, resuming.** A run left `surveying` becomes `interrupted` at boot and Resume runs. Stop ends a run `stopped` at once, **even when the goroutine ignores its context**, and that goroutine's next write of any kind, bookkeeping included, is refused. A reclaimed goroutine writes nothing after the lease moves. Disconnect, Finish and Forget are refused during a run and work after Stop. Disconnect and a replaced token end a resumable run; a token for another workspace is refused while a map exists; Start over clears staged trees. A run with a live ticker and no progress for ten minutes is reclaimable. A resumed survey makes no request for a page already surveyed in that run. A resumed write writes no page twice.
- **I13, who sees Import.** With `MAPA_IMPORTERS` unset every import route 404s for everyone. With it set, a member not named gets 404 on every route, `GET` and `POST`. Nothing outside Import changes for them.
-- **I14, images.** A Notion-hosted image becomes a Mapa image through the images verb; an external one stays a link; an unchanged image block is not downloaded again; an image failure leaves a placeholder and a written page. *Depends on the images spec (§12).*
+- **I14, images.** A Notion-hosted image becomes a Mapa image through `AddImage` and is attached by the page's commit; an external one stays a link; an unchanged image block on the same page is not downloaded again, and one the sweep removed is; a block on a second page is copied; a refusal leaves the text line and a written page, and a permanent one is not downloaded again; the first `ErrImageQuota` stops downloads for the run. *Built with the images spec (§12).*
- **I15, scriptless.** `make browser` connects, starts, watches the meta refresh, resumes and finishes with JavaScript off, then on.
-- **I16, the import never asks to write.** Built with M4's method pin removed (a test-only build tag), a whole run against the fake records every request: only `GET`s and `POST /v1/search`. With the pin in place the fake would never see a write, so this is the version that can go red for the callers.
+- **I16, the import never asks to write.** Using a client from `notiontest` built, through the module's shared internal package, without M4's method pin (no build tag in production code), a whole run against the fake records every request: only `GET`s and `POST /v1/search`. With the pin in place the fake would never see a write, so this is the version that can go red for the callers.
- **I17, crash safety** (§14.1). Killed between every pair of statements in `ImportCreate`, `ImportUpdate` and the run loop, then resumed: no second page, no false *kept*, the map agrees with the pages. And a reclaimed run's goroutine writes no page after the lease moves (§8.3). Nothing but the run calls the two methods.
- **I18, provenance.** Every verb on an imported page (commit, rename, revert, restore, relink, mark) clears `imported` and keeps `origin`.
+- **I19, the bookkeeping exemption is fenced** (§14.2). A Survey-only run changes no row outside `notion_*`. *Mutation: let the bookkeeping function touch `pages`, `revisions`, `aliases`, `title_prints` or `images`, one at a time.*
+- **I1's literal-text fixtures** include each seam row of §11.4: a literal `!` before a mention, a literal `[` before a generated link with a later `]]`, a literal `[label](https://…)`, and a bullet whose text starts `[ ] `.
**And the run is looked at in a browser**, at 0%, mid-survey, mid-write, interrupted and finished, before the build is called done. A template test proves markup exists, not that a run reads sensibly at 40% (memoria §13).
@@ -668,11 +690,11 @@ Not made in this commit. Each lands in the same commit as the code it describes.
## 22. Build order
-0. **This spec, reviewed.** Then Paul's answers to §23. Then the images spec, and §12 revised to match it.
+0. **This spec, reviewed.** Then Paul's answers to §23. §12 already follows the images spec's revision 2; if that spec changes before approval, §12 changes with it.
1. **The module.** The repo; memoria's client and traversal lifted with their history noted; the typed tree; the file fetcher; the fake; the recorder and scrubber; M1–M8.
2. **The mapper** (`notionmd`), against fixtures only: §10–§11, I1, I5's resolution half, I6.
-3. **The run**: tables, the credential, Survey and Write, the screens, I2–I4, I7–I13, I15, I16.
-4. **Images**, once the images verb exists: I14.
+3. **The run**: tables, the credential, Survey and Write, the two store methods, the screens, I2–I4, I7–I13, I15–I19.
+4. **Images**, once the images spec is built: I14.
5. **§19's first real run**, steps 1–11 on `test`.
6. **memoria's retirement** (§16), at the point D14 says.
7. **Steps 12–14 on `paulca`**, when Paul says.
@@ -728,3 +750,26 @@ Recommended answers are written in. None is ruled.
| **L10** Vault export is unbuilt | Said so | §10.1 |
| **L11** "Update links" freezes imported pages | Report splits kept into edited and links-only | §8.5 |
| **L12** Start after an interrupted run | Resume continues it; Start only after `done` or `failed` | §8.3 |
+
+### Round 2: Fable (`claude-fable-5-2`) on revision 2 (`fda6c12`): CHANGES REQUIRED, answered in revision 3
+
+No high findings. Fable said a revision fixing N1–N4 as described needs only a diff check.
+
+| Finding | Change | Where |
+|---|---|---|
+| **N1** Readings form where literal text meets generated syntax: `!` before a generated link, `[` before a generated link, literal `[label](url)`, a bullet starting `[ ] ` | The table runs over the written line; seam rows for `!` and `[`; rows for literal web links, image syntax and task boxes; task box part of "meant"; images spec revisits; a fixture each | §11.4, I1 |
+| **N2** A `renamed` revision that also changes the body breaks `verbs.go`'s invariant and `renamedTo` | Two revisions in one `Store.write`: `renamed` (previous body, `carryDrafts`) then `edited`; the map records the last; I3 updated | §14.1, I3 |
+| **N3** `ImportUpdate` cannot write nothing in a `Store.write` | Returns a sentinel and rolls back; outcomes recorded by a lease-checked bookkeeping write | §14.1 |
+| **N4** The lease guarded only page writes; Stop relied on the context; Resume across Disconnect, a new token, another workspace | Every run write lease-checked; Stop rotates the lease first; Disconnect and token replacement end resumable runs; one workspace per map; Start over; I12 extended | §8.3, I12 |
+| **N5** `lease`, `progress_at` missing from plaintext | Added | §15 |
+| **N6** No `resumed` event; bookkeeping by a running run after Start returns | `resumed`, `started_over` added; bookkeeping lease-checked | §14.2 |
+| **N7** The bookkeeping exemption unfenced | One function, `notion_*` only; I19 | §14.2, I19 |
+| **N8** I16's build tag in production | A `notiontest` client through the shared internal package | I16 |
+| **N9** "A line starting ```" | After trimming leading spaces | §10.1 |
+| **N10** The mapper re-implementing regexes | Calls `markup`'s exported predicates | §11.4 |
+| **N11** Truncation with no word boundary, long parents | Cut at a rune; parent cut to 40 first | §9.2 |
+| **N12** Empty label after cleaning | Uses the address | §11.3 |
+| **N13** Staged trees of runs nobody resumes | Deleted with the token under 90-day idle retention | §8.3 |
+| **N14** Title-only update left drafts behind | `carryDrafts` on the rename revision | §14.1 |
+| **N15** Build step 3 omitted I17, I18 | Listed, with I19 | §22 |
+| *(not a finding)* The images spec landed (`c27a292`) | §12 rewritten against its §7 hook; A1–A11 replaced by what it says; `notion_images` keyed by block and page; quota and `ErrNoImageStore` handling | §12, §15, I14 |