| 1 | # 🤖 mapa — design |
| 2 | |
| 3 | **Status:** **APPROVED by Paul, 2026-11-12** ("Yes to all recommendations |
| 4 | and repos"), revision 5. Fable approved revision 3 conditional on three |
| 5 | text edits, which revision 4 made. Paul's approval covers the author's |
| 6 | proposals in §1, as recommended, and the §13 items marked ruled below. The |
| 7 | hub repository `oficina/mapa` exists, with amadan workflow on. **Slice 1 |
| 8 | items 1 to 5 are built** on `feat/slice-1`, for review: not merged, not |
| 9 | deployed, no CARLOS app. Item 6 waits for the team host. §15 records the |
| 10 | build's notes. This line is the one to keep current. |
| 11 | |
| 12 | **Reviews.** Fable 5.2 reviewed revision 1 (`48e72e6`) and asked for |
| 13 | changes (5 high, 9 medium, 9 low). Revision 2 (`2345d97`) answered them. |
| 14 | Fable re-reviewed revision 2 and asked for a narrower set of changes (1 |
| 15 | high, 6 medium, 6 low), which revision 3 (`057d474`) answers. Fable |
| 16 | approved revision 3 conditional on three text edits (M1 to M3) and three |
| 17 | minor notes, all of which revision 4 makes. Fable said no further review |
| 18 | was needed once they were applied. Appendix A maps every |
| 19 | finding from both rounds to the section that answers it. |
| 20 | |
| 21 | **Consumed suite rulings.** This spec consumes `oficina/suite` |
| 22 | `docs/superpowers/specs/2026-09-05-suite-sharing-doctrine.md` at |
| 23 | **revision 11, commit `91affa1`**, including revision 10's "hold private |
| 24 | too, check per person". It cites rulings 7, 8, 9 and 15, plus doctrine |
| 25 | §§4.3, 6, 6.1, 6.3, 6.4, 6.6, 8 and 14. It never restates them (suite |
| 26 | ruling 7). §7 proposes a new contract call, which would be revision 12 of |
| 27 | that doctrine. That is a proposal to the suite, not a ruling. |
| 28 | |
| 29 | *Mapa* is Spanish for map. The name is Paul's. |
| 30 | |
| 31 | --- |
| 32 | |
| 33 | ## 0. The one rule |
| 34 | |
| 35 | **Mapa is the team's knowledge base. Fichas is the team's database. Docs is |
| 36 | where the team publishes.** Paul, 2026-11-12: *"In traditional terms, |
| 37 | Fichas is database, Mapa is knowledge base."* |
| 38 | |
| 39 | - If something wants typed fields, sorting, grouping or a table, it belongs |
| 40 | in Fichas, and Mapa embeds it (§7). |
| 41 | - If something wants pagination, page layout or DOCX/PDF export, it belongs |
| 42 | in Docs, and Mapa can promote a page into one (§9). |
| 43 | - **Mapa is an app of record.** It owns its pages, answers for them, and is |
| 44 | the only thing that may delete them. memoria indexes Mapa as a sibling. A |
| 45 | team's notes are not a memoria feature, for the reason Fichas decision 1 |
| 46 | gives for cards: that would make memoria the app of record for content |
| 47 | people author elsewhere. |
| 48 | |
| 49 | --- |
| 50 | |
| 51 | ## 1. Decisions, and who made them |
| 52 | |
| 53 | **The `Who` column matters: most of this table is the spec author's |
| 54 | proposal and has not been ruled on.** Do not read a proposal as a ruling. |
| 55 | |
| 56 | | # | Decision | Rejected | Who, when | |
| 57 | |---|---|---|---| |
| 58 | | 1 | **Mapa is a new per-team instance app**, with its own DEK, at `<team>.mapa.oficina.works` | Wiki pages as a Docs mode, because Docs is "the same document everywhere": paginated, WYSIWYG, DOCX/PDF out. Notes inside memoria, per Fichas decision 1's reasoning. Notes as a Fichas card type, because Fichas entries are append-only and its unit is a typed record, not prose | Paul, 2026-11-12 | |
| 59 | | 2 | **Linked notes, not a spatial mindmap.** The unit is a page of prose. Structure comes from `[[links]]` in the text. A graph view may come later as one way of looking at the pages | A canvas of nodes and edges as the primary surface | Paul, 2026-11-12 | |
| 60 | | 3 | **Fichas = database, Mapa = knowledge base.** No properties, table views or typed fields in Mapa | Notion's database-inside-a-page | Paul, 2026-11-12 | |
| 61 | | 4 | **Embeds go both ways.** A Fichas card or saved view can be embedded in a Mapa page, and a Mapa page in a Fichas card | One-way references only | Paul, 2026-11-12 | |
| 62 | | 5 | **Daily notes.** One page per person per day. Today's note is the landing page | A blank "new note" as the entry point | Paul, 2026-11-12 ("I'd love to see daily notes") | |
| 63 | | 6 | **One shared namespace per team.** `[[Acme]]` means one page for everyone in the team | Per-person namespaces with team pages layered on top | Paul leaned yes, 2026-11-12 ("Shared namespace makes sense?"); author recommends. **Confirm** | |
| 64 | | 7 | **Only team pages hold titles in the namespace.** Private material is daily notes and untitled scratch pages, and both may link *to* team pages | Private titled pages, which either collide with a teammate's `[[Acme]]` or reveal that a private page exists by refusing the title | **Proposed** (§3.3) | |
| 65 | | 8 | **A page's rung is fixed when it is created.** Sharing private writing creates a new team page from the chosen text. The private page is never re-ruled | Moving a page between rungs, which either makes its private-era revisions team-readable or needs per-revision rungs | **Proposed** (§3.4) | |
| 66 | | 9 | **Bodies keep link text exactly as typed. Titles resolve through aliases at render.** **This is a trade-off, and it reverses revision 1:** links are keyed on text, so deleting a page or freeing an alias, then creating a page with that title, rebinds every link typed with that text, private notes included (§3.4) | Rewriting every linking page's body on rename, which mints revisions in pages nobody edited and, for private notes, in pages the renamer cannot see. Revision 1's id-keyed links, which needed exactly that rewrite to keep S3's bytes fixed (doctrine §6.6) | **Proposed** (§3.2) | |
| 67 | | 10 | **The body is Markdown. A page is a document, not an outliner** | A strict bullet outliner (Logseq, Roam) | Paul, 2026-11-12 ("Document sounds good") | |
| 68 | | 11 | **Saves are revision-checked and merged by block. There is no real-time co-editing in v1** | Docs' collaboration machinery, which is built for paginated layout | **Proposed** | |
| 69 | | 12 | **Embeds are a suite contract call, not glue between two apps.** The owning app serves a typed payload, with no markup, for a named asker. The embedding app renders it with a shared estilo partial (§7) | An iframe from the owning origin, which needs a session at every sibling and relaxes framing refusals. HTML or Markdown handed between siblings, which lets one app put markup into another | **Proposed** | |
| 70 | | 13 | **A team container may embed only team-visible items.** This is checked when the embed is written (§7.4) | Hiding non-team embeds at render only, which cannot hide them from the editor, history, S3 or export | **Proposed** | |
| 71 | | 14 | **SQLite, cgo-free, like every sibling. Everything that is free text or derived from free text is sealed, the link graph included. Search, backlinks and the graph live in an in-memory index rebuilt from sealed rows on wake** | Plaintext link and reference tables, which fail Fichas §4.1's test ("plaintext only where the durable file must answer without the key"), since the graph can be derived at wake | **Proposed** (§4) | |
| 72 | | 15 | **Export is an Obsidian-compatible Markdown vault**: the team's pages, plus the exporter's own private pages | No export; a proprietary format | **Proposed** | |
| 73 | |
| 74 | ## 2. What Mapa is, and is not |
| 75 | |
| 76 | **Is:** a per-team instance app holding pages of Markdown prose, the links |
| 77 | between them, each person's daily notes, and references to items in |
| 78 | sibling apps. Those references render as embeds, resolved per viewer at |
| 79 | render time. |
| 80 | |
| 81 | **Is not:** |
| 82 | |
| 83 | - **Not a database** (decision 3). |
| 84 | - **Not a publishing tool.** It paginates nothing and exports only Markdown. |
| 85 | - **Not an app of record for what it did not author.** An embed is a |
| 86 | reference. The owning app decides every time whether to resolve it. |
| 87 | - **Never an actor** (suite ruling 9). Every write names the person who |
| 88 | made it. |
| 89 | |
| 90 | ## 3. The data model |
| 91 | |
| 92 | ### 3.1 Objects (durable) |
| 93 | |
| 94 | - **Page:** `(id, kind, rung, owner, revision, created_at, updated_at)` |
| 95 | plus a sealed record holding the title (team pages), the date (daily |
| 96 | notes) and the Markdown body. |
| 97 | - `kind` is `page`, `daily` or `scratch`. |
| 98 | - `rung` is `team` or `private`, fixed at creation (decision 8). |
| 99 | - `owner` is a member row id, as in Fichas, not an address. |
| 100 | - **Alias:** `(page_id, sealed title)`. Every title a team page has had. |
| 101 | - **Title print:** `(print, page_id)`, where `print` is HMAC under the |
| 102 | instance key of the title after case- and accent-folding. It covers |
| 103 | current titles and aliases, and is unique. It lets the durable file |
| 104 | refuse a duplicate title without holding it (§4). |
| 105 | - **Daily print:** `(print, page_id)`, the HMAC of `(owner, date)`, unique. |
| 106 | It enforces one daily note per person per day without a plaintext date. |
| 107 | - **Revision store:** `(page_id, revision, at, actor)` plus the sealed |
| 108 | body at that revision. It is kept for the history window (§5) and pruned |
| 109 | after it. |
| 110 | - **Draft:** `(page_id | daily print, person, base_revision, updated_at)` |
| 111 | plus a sealed body. One per person per page. A draft for a daily note |
| 112 | that does not exist yet is keyed by its daily print, and its first commit |
| 113 | creates the page. A draft holds coalesced autosave text before it |
| 114 | becomes a revision (§5). It is not an item, has no revision, and is never |
| 115 | in S1 or S3. |
| 116 | - **Member:** `(id, address print, sealed address, time zone setting)`. |
| 117 | This is the lone-shape admission list's local mirror, as in Fichas. The |
| 118 | sealed time zone is the person's setting. The team's default time zone |
| 119 | is an instance setting in config. |
| 120 | - **Sessions and sign-in rows:** rastrillo's own tables, unchanged from |
| 121 | every sibling. |
| 122 | - **Event:** `(id, nonce, at, actor, object, verb, revision)`, one row for |
| 123 | every write. It feeds the in-memory index and S1 (§8). A write that logs no |
| 124 | event is invisible to both. Gate 8 checks this. |
| 125 | - *Amended by the Notion import (its spec §14.2, §21):* object kind |
| 126 | `import` names a person's own act on the import (`connected`, |
| 127 | `token_replaced`, `disconnected`, `finished`, `forgotten`, `started`, |
| 128 | `stopped`, `resumed`, `started_over`). The index and S1 ignore it. |
| 129 | - *Amended by the Notion import:* the sealed record gains two optional |
| 130 | fields. `origin` (`{source, created, edited}`) says an imported page |
| 131 | came from Notion, with Notion's own times; every later commit carries |
| 132 | it forward. `imported` marks a revision the import wrote; `tx.commit` |
| 133 | clears it on every write but `ImportCreate`'s and `ImportUpdate`'s. |
| 134 | - *Amended by the Notion import:* its own tables, `notion_connections`, |
| 135 | `notion_runs` and `notion_pages`, are listed in its spec §15 and in §4 |
| 136 | below. |
| 137 | |
| 138 | ### 3.2 Derived, in memory only |
| 139 | |
| 140 | Rebuilt from sealed bodies on wake and kept current from the event log. |
| 141 | None of it is written to the durable file: |
| 142 | |
| 143 | - **Links:** `from_page → to_page`, resolved by matching each `[[text]]` in |
| 144 | a body against current titles and aliases. |
| 145 | - **Pending links:** `[[text]]` that resolves to no page. |
| 146 | - **References:** `![[app:item]]` in a body. |
| 147 | - **Unlinked mentions:** team-page titles and aliases that appear in a body |
| 148 | without a link. |
| 149 | - **The search index:** titles, aliases and bodies. |
| 150 | |
| 151 | **What a body holds.** The link text exactly as typed: `[[Acme]]` stays |
| 152 | `[[Acme]]` after Acme is renamed "Acme Ltd". It resolves through the alias |
| 153 | at render. Renaming a page therefore mints a revision for that page only. |
| 154 | Pages that link to it are untouched, which keeps doctrine §6.6's "a |
| 155 | revision names one byte sequence for ever" true for S3 (§8). The editor |
| 156 | offers "Update links to the new title" as an explicit, attributed edit, and |
| 157 | never does it silently. |
| 158 | |
| 159 | **Blocks.** A block is a paragraph, a list item, a heading or a code fence. |
| 160 | Backlink context is "the block that contains the link", found at render, |
| 161 | and needs no stored id. **A block gets a stable id only when something |
| 162 | targets it.** That uses Obsidian's syntax: a `^id` marker at the end of the |
| 163 | block. **A marker is minted only by an edit to the page that holds the |
| 164 | block, by someone editing that page.** Minting it from elsewhere would |
| 165 | write into the target page. If Ana links from her private note to a block |
| 166 | in team page Acme, the marker would appear in Acme's history as an edit by |
| 167 | Ana, telling teammates she linked to it privately. So from a private note, |
| 168 | a block reference is a page link plus a quoted excerpt, and `[[Acme#^id]]` |
| 169 | works only for markers that already exist. In a team page, "Link to this |
| 170 | block" mints the marker as an ordinary attributed edit to that page. The marker is visible text, so it survives the scriptless |
| 171 | textarea. Deleting the block drops it, and links to it then resolve to the |
| 172 | page with a "block removed" note. |
| 173 | |
| 174 | ### 3.3 Rungs, and the namespace |
| 175 | |
| 176 | The doctrine's ladder (ruling 15) has three rungs. Mapa v1 uses two: |
| 177 | |
| 178 | | Kind | Rung | Title in namespace? | Who opens it | |
| 179 | |---|---|---|---| |
| 180 | | `page` | `team` | yes: unique per team, after folding, across titles and aliases | every member | |
| 181 | | `daily` | `private` | no: shown as its date | its owner | |
| 182 | | `scratch` | `private` | no: shown as its first line | its owner | |
| 183 | |
| 184 | - **The `granted` rung is not in v1.** Its trigger is in §12. |
| 185 | - **Backlinks, unlinked mentions, search, autocomplete and "Create" are all |
| 186 | ruled per viewer, and so is the order they come in** (§6.3). Every read |
| 187 | of the in-memory index is scoped to team pages plus the viewer's own |
| 188 | private pages. **Nothing anywhere shows a count of what the viewer cannot |
| 189 | see** (Fichas §9). |
| 190 | |
| 191 | ### 3.4 Verbs |
| 192 | |
| 193 | - **Create a team page:** any member. Its title must not match any current |
| 194 | title or alias (title print). |
| 195 | - **Rename:** any member. The old title becomes an alias. |
| 196 | - **Delete:** any member, through a confirm page. Delete is the only verb |
| 197 | that changes what teammates can open, so it is logged with its actor. The |
| 198 | page's title and aliases are freed. Inbound `[[text]]` stays as typed and |
| 199 | becomes pending, which is honest: the text was written by its authors and |
| 200 | still says what they wrote. If a new page later takes that title, those |
| 201 | links bind to it (decision 9's trade-off). |
| 202 | - **Restore a deleted page:** possible inside the history window (§5), as a |
| 203 | **new item with a new id** at its first revision. S1 has already said |
| 204 | `gone` for the old id, and it stays gone. If the title has been taken |
| 205 | meanwhile, the restorer picks another. |
| 206 | - **Update links:** after a rename, "Update links to the new title" edits |
| 207 | **team pages and the actor's own private pages only**, as edits by the |
| 208 | actor. It reports how many of *those* it changed, and never a count that |
| 209 | includes anyone else's private pages. Other people's private links keep |
| 210 | working through the alias. |
| 211 | - **Free an alias:** an explicit action on the page that owns it. It frees |
| 212 | the title for a new page, and links typed with that text become pending |
| 213 | or rebind to the new page. Aliases otherwise reserve titles until their |
| 214 | page is deleted. |
| 215 | - **Share private writing:** select blocks in a daily or scratch note and |
| 216 | choose "Make team page". This creates a **new** team page holding only |
| 217 | those blocks, at its first revision. The private note gets a link to it |
| 218 | in place of the moved blocks. No private-era revision ever becomes |
| 219 | team-readable (decision 8). |
| 220 | - **Undoing an accidental share:** delete the team page. The spec does not |
| 221 | pretend this unshares anything: teammates may already have read it, and |
| 222 | memoria may hold it until its feed pulls `gone`. A team page cannot be |
| 223 | moved to private, for the same reason, and because the move would claim |
| 224 | more than it can deliver. |
| 225 | - **Date links:** a link whose text is an ISO date (`[[2026-11-12]]`, and |
| 226 | nothing else) is reserved. It never names a team page: a date-shaped |
| 227 | title or alias is refused on create, on rename and when "Make team page" |
| 228 | is used. It opens **the viewer's own daily note** for that date. The |
| 229 | resolution is per viewer and reveals nothing, because each reader reaches |
| 230 | only their own note. Changing your time zone changes which date "today" |
| 231 | is from then on. It never moves or re-dates a note already written. |
| 232 | **Proposed.** The product cost: when Ana writes "see `[[2026-11-12]]`" in |
| 233 | a team page, Bo lands on his own note for that day, probably empty, not |
| 234 | on Ana's. Pointing at what happened on a day means a team page. |
| 235 | |
| 236 | ### 3.5 Document, not outliner — ruled |
| 237 | |
| 238 | Reflect and Obsidian are document-shaped: prose, with lists where you want |
| 239 | them. Logseq and Roam are outliners: every line is a bullet in a tree. |
| 240 | |
| 241 | **RULED, Paul, 2026-11-12: document** ("Document sounds good"). Mapa's |
| 242 | pages are meant to become reference material that people read. Block links |
| 243 | (§3.2) give the addressability outliners are loved for, without forcing |
| 244 | bullets. |
| 245 | |
| 246 | ## 4. The seal boundary |
| 247 | |
| 248 | Under Fichas §4.1's test, plaintext is allowed only where the durable file |
| 249 | must answer a question without the key. The complete plaintext list: |
| 250 | |
| 251 | | Column(s) | Why it must be plaintext | What it leaks | |
| 252 | |---|---|---| |
| 253 | | ids, `kind`, `rung` | rows must be addressable and S1/S2 must answer per rung | how many pages, daily notes and scratch pages exist | |
| 254 | | page and event nonces, event ids | S1 cursors and revision nonces (§5, doctrine §6.6) | nothing beyond row counts | |
| 255 | | revision store `(page_id, revision, at, actor)` | history lists and restore without unsealing every body | **how many times each page was saved, by whom, and when**, inside the window. Ciphertext sizes show how each body grew | |
| 256 | | drafts `(page_id or daily print, person, base_revision, updated_at)` | the coalescing rule (§5) runs without unsealing | that a person has an uncommitted edit to a page, and when they last typed in it | |
| 257 | | member `id`, address print | admission and S2 by address without unsealing | how many members there are. The print shows equality only | |
| 258 | | rastrillo session and sign-in rows (`sessions`, `auth_links`, `auth_sessions`) | inherited, as in every sibling | when each person signed in, **and their address, in the clear** (corrected after review M4: rastrillo writes it into `auth_links` and `auth_sessions` on every sign-in, in every sibling). Sealing it is a suite-wide follow-up in rastrillo, not Mapa's. Gate 4 allows it there by name, and nowhere else | |
| 259 | | *(shown, not stored)* "Ana is editing" on team pages | presence while a draft is under 2 minutes old | that Ana is editing a team page, including edits she later discards. Never shown for private pages | |
| 260 | | `owner` (member row id) | S2 answers `private` → owner without unsealing | who has how many private pages | |
| 261 | | `created_at`, `updated_at`, `revision` | ordering, S1, §6.6 | **when each person writes**, including private notes. A daily note's creation time narrows its date to about a day. Creation on first edit (§6), not first open, means this records writing, not visiting | |
| 262 | | events `(at, actor, object, verb)` | S1 is the event log (Fichas §5's shape) | who did what to which object, and when. Not content | |
| 263 | | title prints, daily prints | uniqueness without the key | equality: two attempts at the same folded title are visibly the same. The number of aliases per page is a rename count. Prints are HMAC under the instance key, so they cannot be checked against a guessed title without that key | |
| 264 | | ciphertext sizes | inherent | roughly how long each body and each draft is | |
| 265 | | *Notion import (its spec §15):* `notion_connections (id, created_by, created_at, verified_at)` | a person's acts on the connection, and the 90-day idle retention, without the key | that a Notion connection exists, who made it, when it was last checked. The token and workspace are sealed | |
| 266 | | *Notion import:* `notion_runs` (id, actor, state, lease, its clocks, its counters, error code) | single-flight, leases, liveness and the status page without the key | when imports ran, who ran them, and how many pages each created, updated, kept and failed. The lease is random | |
| 267 | | *Notion import:* `notion_pages` (id, notion print, state, error code, surveyed run, seen run) | re-runs find a page without the key | how many Notion pages the import has seen and their states. The coordinate (Notion id, Mapa page, revision) and staged tree are sealed. **But the plaintext event log joins them**: a run's `created` events, by its actor, in its window, mark which team pages it made, and sequential ids line them up in Notion's survey order. Not their titles, bodies or Notion ids | |
| 268 | | *Notion import:* egress | the import reads Notion | Mapa dials `api.notion.com` and Notion's file hosts during a run and once when a token is saved. Notion and its storage provider learn the instance's egress address and when it imports. No team content goes out | |
| 269 | |
| 270 | **Sealed:** titles, aliases, dates, bodies, revision bodies, draft |
| 271 | bodies, member addresses (in Mapa's own tables; see the sessions row), time zone settings, and so links, pending links, |
| 272 | references and `^id` markers too. The link graph exists only in memory |
| 273 | (decision 14). |
| 274 | |
| 275 | ## 5. History |
| 276 | |
| 277 | Every write is logged with its actor. Page bodies keep their revisions for |
| 278 | **90 days** (proposed), and restore works inside that window, using Fichas |
| 279 | decision 2's shape. Restore mints a **new** revision. Revisions are random int63 values, |
| 280 | and cursors carry random nonces (doctrine §6.6, as Docs and Fichas adopted |
| 281 | for revision 11). |
| 282 | |
| 283 | **Autosave is coalesced through a draft.** While a person types, autosave |
| 284 | writes their **draft** (§3.1): a sealed row per person per page, separate |
| 285 | from the page. The page body and its revision are never touched in place, |
| 286 | so `(item, revision)` always names one byte sequence (doctrine §6.6). |
| 287 | **The draft is committed as a new revision**, with one event, and every |
| 288 | commit is a `POST` made by the person. A `GET` never writes, and the |
| 289 | platform runs no timers (doctrine §13): |
| 290 | - **On Save**, or **after 2 minutes idle**, the open tab's script `POST`s |
| 291 | the commit. Without script, Save is the only commit. |
| 292 | - **A draft left by a closed tab** is offered on the person's next visit to |
| 293 | that page, or to today's note: "You have unsaved changes: Save or |
| 294 | Discard". Both are `POST`s. |
| 295 | - **A commit is a revision-checked save.** If a teammate's revision landed |
| 296 | in between, the §6 block merge runs. **If two people edited the same |
| 297 | block, the commit does not happen.** It stays a draft, and the person |
| 298 | is shown both versions to choose from the next time they are present. |
| 299 | Nothing is committed that nobody chose. |
| 300 | - **If the base revision has aged out of the 90-day window,** there is no |
| 301 | merge base. The person is shown the current page and their draft side |
| 302 | by side, and chooses. |
| 303 | - **If the draft's page was deleted,** the draft is offered as a new |
| 304 | scratch page. |
| 305 | - **Two tabs** of the same person share one draft, with a version check: a |
| 306 | stale tab's autosave is refused, and that tab reloads the draft rather |
| 307 | than overwriting newer text. |
| 308 | - **An abandoned draft** is kept for 30 days after its last write, then |
| 309 | discarded (proposed). |
| 310 | |
| 311 | Meanwhile: |
| 312 | - A teammate sees the last committed revision, plus "Ana is editing" while |
| 313 | Ana's draft on a **team** page is less than 2 minutes old. It is never |
| 314 | shown for a draft on a private page. Who is editing a team page is not a |
| 315 | rung leak, but it is a disclosure: it shows edits Ana later discards, |
| 316 | which never reach history. It is in the leak list (§4). |
| 317 | - S1, memoria and the history list see revisions, not drafts. |
| 318 | |
| 319 | Two write paths are exempt from gate 8's "every write logs an event", |
| 320 | **by name**: draft writes, because a draft is not an item (its commit is |
| 321 | logged), and retention, which removes what the 90-day and 30-day windows |
| 322 | have passed and changes no item anyone can still reach (added after |
| 323 | review L7; build note 27). |
| 324 | |
| 325 | *Amended by the Notion import (its spec §14.2):* a third exemption, |
| 326 | **bookkeeping**: an import run's own rows, heartbeats, progress, staged |
| 327 | trees and map state that changes no page. It goes through one function |
| 328 | whose transaction may touch only `notion_*` tables (gate I19). A page |
| 329 | write is never bookkeeping, and a person's acts on the import log events. |
| 330 | |
| 331 | ## 6. The surface |
| 332 | |
| 333 | The rastrillo floor applies: **every screen works with JavaScript off.** |
| 334 | |
| 335 | - **Today.** `/` shows today's daily note. Until there is something to |
| 336 | save, it is an empty editor and **no row exists**: the note is created |
| 337 | when its first draft is committed (§5), so a day on which nothing was written leaves no trace in |
| 338 | S1, memoria or the database file. A `GET` never writes. |
| 339 | - **The date and its time zone.** "Today" is in the person's own time zone: |
| 340 | a per-person setting, defaulting to the team's time zone (an instance |
| 341 | setting). Script offers to switch when the browser's zone differs. It |
| 342 | never switches silently. |
| 343 | - **A page.** It shows the rendered Markdown, then backlinks grouped by |
| 344 | source page with their context block, then unlinked mentions (§6.4). |
| 345 | - **Editing.** The scriptless floor is a Markdown `<textarea>` with a Save |
| 346 | button, revision-checked. Script adds live preview, `[[` autocomplete, |
| 347 | coalesced autosave (§5) and link paste. |
| 348 | - **Conflicts.** A save against an older revision is merged three ways by |
| 349 | block. Edits to different blocks merge silently. When two people edit |
| 350 | the same block, the second sees both versions and chooses. Nothing is |
| 351 | lost silently. |
| 352 | - **⌘K.** One box over titles, aliases and bodies, offering "Create *X*" |
| 353 | when nothing in the viewer's scope matches. Without scripts it is |
| 354 | `GET /search?q=` as a full page. |
| 355 | - **Links.** `[[Title]]`, `[[Title|shown text]]`, `[[Title#^id]]`. A |
| 356 | pending link renders as one, and following it offers to create the page. |
| 357 | - **Embeds.** `![[fichas:…]]` and friends (§7). A page that embeds is |
| 358 | served `no-store`. |
| 359 | - **Calma**, and the Oficina door for sign-in. |
| 360 | |
| 361 | ### 6.1 Search speed — targets, and what they rest on |
| 362 | |
| 363 | | Measure | Target | |
| 364 | |---|---| |
| 365 | | Server time per typeahead query, at 10,000 pages | p95 ≤ 5 ms | |
| 366 | | Keystroke to results painted, warm, same region | p95 ≤ 100 ms | |
| 367 | | Cold wake to first search answered, at 10,000 pages | **unmeasured.** Target ≤ 2 s, to be confirmed by gate 6 before it is promised | |
| 368 | |
| 369 | **What the precedents measured, exactly.** Fichas commit `9179761` |
| 370 | measured, at 5,000 customers with 10,000 calls, a 225 ms cold load once per |
| 371 | wake, and 0.37 ms for a search with a filter and a sort. Those are short |
| 372 | structured fields matched by substring, not ranked search over prose. |
| 373 | memoria §7.2 measured 6.8 s to build its index at 90,000 chunks. That is |
| 374 | the closer precedent for prose, and the reason the cold-wake number is |
| 375 | marked unmeasured rather than borrowed. |
| 376 | |
| 377 | ### 6.2 Ranking |
| 378 | |
| 379 | Titles and aliases are prefix-matched and rank first. Bodies are matched by |
| 380 | term and ranked BM25-style. **Every statistic a ranking uses is computed |
| 381 | over team pages only:** document frequencies, the backlink boost and the |
| 382 | average length. A viewer's own private pages are scored against those |
| 383 | team-only statistics. So nobody's private writing can change the order of |
| 384 | anybody else's results, including the viewer's own. A term that appears in |
| 385 | no team page has document frequency 0, and is smoothed as if it appeared in |
| 386 | one (BM25's +1). |
| 387 | |
| 388 | **The scope filter runs before traversal, not after.** Postings are |
| 389 | partitioned: one team partition, plus one partition per person for their |
| 390 | private pages. A query reads the team partition and the viewer's own |
| 391 | partition only, so the time Bo's query takes cannot depend on what Ana's |
| 392 | private notes contain. |
| 393 | |
| 394 | ### 6.3 What the viewer's scope covers |
| 395 | |
| 396 | Every read of the in-memory index is scoped to team pages plus the viewer's |
| 397 | own private pages. That covers search results and their order, ⌘K's |
| 398 | "Create" offer, `[[` autocomplete (team titles and aliases, and the |
| 399 | viewer's own pending link texts only), backlinks, unlinked mentions and any |
| 400 | future graph view. Gate 1 checks this. |
| 401 | |
| 402 | ### 6.4 Unlinked mentions |
| 403 | |
| 404 | Text in a page that matches a team page's title or alias without linking to |
| 405 | it shows on the target page as "Mentioned without a link", with "Link it". |
| 406 | It is computed in memory, never stored, and scoped per viewer (§6.3). |
| 407 | |
| 408 | ## 7. Embeds: a suite contract call (proposed revision 12) |
| 409 | |
| 410 | ### 7.1 What has to be true |
| 411 | |
| 412 | 1. **The viewer decides what shows.** An embed renders only if the person |
| 413 | looking may open the item in its own app, checked at that moment. |
| 414 | 2. **Not visible renders nothing, and never a count** (Fichas §9). |
| 415 | 3. **An unavailable sibling is loud** (doctrine §6.3): "Fichas did not |
| 416 | answer", naming the app, with a retry link. |
| 417 | 4. **No copy at rest.** Embed content is never written to the embedding |
| 418 | app's database and never enters its index. |
| 419 | 5. **Scriptless.** Embeds render server-side. |
| 420 | 6. **No markup crosses apps.** Payloads are typed data. The receiver parses |
| 421 | nothing. |
| 422 | |
| 423 | ### 7.2 Numbering |
| 424 | |
| 425 | **S10.** S4 and S5 are not calls (doctrine §6). S7 is retired (doctrine |
| 426 | §6). S8 is write-as-self. **S9 is reserved** by the cross-rung reach draft |
| 427 | (suite `design/cross-rung-reach`, `2026-09-19-cross-rung-reach-draft.md` |
| 428 | §5, `RouteS9 = "/suite/s9"`) and by Fichas §6 ("S9 (reach) depends on an |
| 429 | unresolved ruling"). This spec does not ask for that draft to be withdrawn. |
| 430 | |
| 431 | ### 7.3 The call |
| 432 | |
| 433 | **S10 embed:** sibling → sibling, consumer token **+ named asker**, which is |
| 434 | S2's credential shape (ruling 8, doctrine §6.1). |
| 435 | |
| 436 | - **Request:** up to 32 `(item, view?)` pairs plus one asker. |
| 437 | - **The asker's subject kind:** `address` while either side is lone |
| 438 | shape. Fichas answers `UNKNOWN` to every `person_ref` (Fichas §6.3). |
| 439 | `person_ref` arrives with the home's identity layer. |
| 440 | - **A view** is a named object in the owning app (§7.6), not an S1 item. |
| 441 | - **Response:** one result per pair, with **three** values. There is no |
| 442 | revision in an embed, so `STALE` does not apply (doctrine §6.6 defines it |
| 443 | against an asked revision). |
| 444 | - `VISIBLE` carries a payload. |
| 445 | - `NOT_VISIBLE` carries nothing. It covers an unknown or deleted item or |
| 446 | view, and one the asker may not open. |
| 447 | - `UNKNOWN` carries nothing and is rendered loudly. |
| 448 | - **Payloads** are a closed set of typed shapes in the suite module, each |
| 449 | with a strict decoder and size caps. **None contains HTML or Markdown |
| 450 | source:** |
| 451 | - **`card`:** a title, up to 12 `(label, value, kind)` fields, the last 3 |
| 452 | entries `(kind, actor, at, text)`, an app URL, and `team_visible: bool` |
| 453 | (§7.4). |
| 454 | - **`list`:** a title, column labels, up to 25 rows of `(cells, app |
| 455 | URL)`, `more: bool`, an app URL, and `team_visible`. **The rows, the |
| 456 | 25-row cut and `more` are computed over rows the asker may open,** |
| 457 | after ruling, so `more` is never a signal that unseen rows exist. In |
| 458 | Fichas today every member sees every card (Fichas §6.1), so the per-row |
| 459 | rule is vacuous there and binding for any app with a ladder. |
| 460 | - **`page`:** a title, an app URL, `team_visible`, `more: bool`, and up |
| 461 | to 40 **typed blocks**: `heading(level, spans)`, `paragraph(spans)`, |
| 462 | `list(ordered, items[spans])`, `quote(spans)`, `code(text)`. A span is |
| 463 | `text`, `emphasis`, `strong`, `code` or `link(spans, url)`. Embeds |
| 464 | inside an embedded page are not expanded: one level only, so cycles |
| 465 | cannot happen. |
| 466 | - **Two classes of URL, checked differently by the receiver's suite |
| 467 | client:** |
| 468 | - **App URLs** (every "open in app" and row URL) must be `https`, with |
| 469 | no userinfo, and a host exactly |
| 470 | `<own team>.<answering app>.oficina.works`. |
| 471 | - **Author links** inside page spans, and Fichas card fields of kind URL |
| 472 | (which a person typed), may be `http` or `https` only. Every |
| 473 | other scheme (`javascript:`, `data:` and the rest) is refused by the |
| 474 | decoder. They render with `rel="noopener noreferrer"`. They are not |
| 475 | team-checked, because a person may link anywhere. |
| 476 | - Both classes get hostile fixtures beside `hostile_hosts.json`. |
| 477 | - **Never cached.** A payload crosses no request boundary. **Doctrine §6.4 |
| 478 | is amended** by this proposal: "any passage shown to a person without an |
| 479 | S2 `VISIBLE` **or an S10 `VISIBLE`** for that person in the same |
| 480 | request". |
| 481 | - **Deadline and wake.** One deadline per page render, concurrent across |
| 482 | siblings. It starts at **800 ms**, doctrine §14's unmeasured default, and |
| 483 | is to be tuned by measurement. The embedding app **pre-warms** the |
| 484 | siblings it embeds from when it wakes (doctrine §6.3), or the first |
| 485 | render after idle would always say "did not answer". A page with more |
| 486 | than 32 embeds makes several concurrent calls. Past 64 embeds, the rest |
| 487 | render as nothing, and the page carries one note: "This page has more |
| 488 | embeds than can be shown at once." A plain link would show where an embed |
| 489 | the viewer may not open must render nothing (§7.1(2)). |
| 490 | - **Rendering:** one estilo partial per shape, so a Fichas card looks the |
| 491 | same inside Mapa as inside Fichas. |
| 492 | |
| 493 | **What S10 adds to a consumer token, stated plainly:** a holder of a |
| 494 | consumer token can already read every live item through S3 since revision |
| 495 | 10. S10 adds **rendered, per-person views**: entry actors and times, which |
| 496 | Fichas' S3 body omits (Fichas §6.4), and saved views with their names and |
| 497 | columns. That goes in the suite leak list (doctrine §9) as a revision-12 |
| 498 | entry. It is not presented as "says less than S3". |
| 499 | |
| 500 | ### 7.4 Team containers embed only team-visible items |
| 501 | |
| 502 | Hiding a non-team embed at render cannot hide it everywhere. The reference |
| 503 | string sits in a team page's Markdown, which every member opens in the |
| 504 | editor, and it is in history, S3 and export. So the rule is enforced |
| 505 | twice. |
| 506 | |
| 507 | **At render, always.** A team container renders nothing for a payload whose |
| 508 | `team_visible` is false, even for a viewer who could open the item. The |
| 509 | one exception is a notice, shown only to a viewer whose own answer was |
| 510 | `VISIBLE`: "This embed isn't shown here because it isn't shared with the |
| 511 | whole team." Without it the item's owner would see the reference in the |
| 512 | editor and nothing on the page. Nobody whose answer was not `VISIBLE` sees |
| 513 | the notice, so it reveals nothing. This |
| 514 | closes every path a reference can arrive by: restore, merge, "Make team |
| 515 | page", text typed during slice 1 before the check existed, a later import, |
| 516 | and the race between the write-time check and commit. It is also the |
| 517 | answer for an item moved down the ladder after it was embedded. |
| 518 | |
| 519 | **At write, for references new in this save.** Only references that are |
| 520 | absent from the base revision are checked. So Bo can always save a page |
| 521 | that holds an embed Ana added, even if that item has since moved down. |
| 522 | - **The embedding app asks S10 with the writer as asker**, and reads |
| 523 | `team_visible`. |
| 524 | - **`VISIBLE`, team-visible:** saved. |
| 525 | - **`VISIBLE`, not team-visible, in a team container:** refused, with a |
| 526 | plain message. |
| 527 | - **`NOT_VISIBLE`:** refused with one message, identical for an unknown |
| 528 | item and one the writer may not open. **When the sibling answers,** |
| 529 | nobody can plant a reference to something they cannot see. |
| 530 | - **`UNKNOWN`, in Markdown:** the save goes through and the typed text is |
| 531 | kept. There is no "unchecked" mark: references live only in memory |
| 532 | (decision 14), so a mark would not survive hibernation, and the diff |
| 533 | rule would never look at the reference again. **Render enforcement |
| 534 | alone covers it.** A reference saved under `UNKNOWN` renders nothing in |
| 535 | a team container unless its payload says `team_visible`. Planting one |
| 536 | leaks only an id the writer already had. Refusing instead would make |
| 537 | every page with an embed unsavable while Fichas is cold. |
| 538 | - **The same check runs on restore and on "Make team page"** for the |
| 539 | references they bring into a team container. A private daily note may |
| 540 | embed anything its owner can open. |
| 541 | |
| 542 | **What the writer learns.** A writer who gets `VISIBLE` may open the item. |
| 543 | In Fichas and Mapa, learning whether it is team-visible tells them nothing |
| 544 | new. In a future app with a `granted` rung, a grantee learns the item's |
| 545 | rung. S1 deliberately carries no visibility flag, so `team_visible` goes in |
| 546 | revision 12's leak-list entry. |
| 547 | |
| 548 | **Fichas → Mapa.** Every Fichas card is team-visible (Fichas §6.1), so a |
| 549 | card's reference field may reference **team Mapa pages only**. There is no |
| 550 | picker: no call lets Fichas list Mapa titles, and S1 carries none. The |
| 551 | person pastes a Mapa page URL. **A reference field is a typed value, so |
| 552 | Fichas refuses that one field on anything but `VISIBLE` with |
| 553 | `team_visible`,** `UNKNOWN` included, and the card still saves without it. |
| 554 | "Mapa did not answer, so this reference wasn't saved; try again." Given |
| 555 | that, and while Mapa answers truthfully, a teammate never sees an empty |
| 556 | reference field, or history naming a change to one, that points at |
| 557 | someone's private note. |
| 558 | |
| 559 | **While both apps are lone shape,** "the team" means each app's own |
| 560 | admission list, and the two lists may differ. `team_visible` is the owning |
| 561 | app's statement about its own list. Provisioning both apps for one team |
| 562 | label from one roster (§10) is what makes the two lists agree. |
| 563 | - **What remains, and goes in the leak list:** an item that was |
| 564 | team-visible when embedded, and that its app later moves down the ladder, |
| 565 | leaves a reference string in team pages and their history. It renders as |
| 566 | nothing. The string is an id. It is never a title or content. |
| 567 | |
| 568 | ### 7.5 The reverse direction |
| 569 | |
| 570 | A Fichas card holds a reference to a Mapa page and asks Mapa's S10 for a |
| 571 | `page` payload for the viewer. Mapa answers `VISIBLE` for a team page to |
| 572 | any member, and `NOT_VISIBLE` for a deleted page. Given §7.4, a private |
| 573 | page never appears there. |
| 574 | |
| 575 | ### 7.6 What it needs from Fichas |
| 576 | |
| 577 | - **Saved views,** for `list` embeds. List state already lives in the URL |
| 578 | (`list.go`), so a view is a named, stored copy of that state per card |
| 579 | type, with an id. **Both personal and team views** (Paul, 2026-11-12: |
| 580 | "should be both"). A personal view is visible to its owner only, so S10 |
| 581 | answers `NOT_VISIBLE` for it to anyone else, and §7.4 means a team Mapa |
| 582 | page may embed only a team view. One question is still open (§13). **It waits until |
| 583 | `feat/level-up` merges** (as of 2026-11-12, `9976eb1`, one commit ahead |
| 584 | of `origin/main`), because it touches the same handlers and templates. |
| 585 | - **An S10 server half for `card` and `list`.** |
| 586 | - **A reference field kind** on cards, for the reverse direction. This |
| 587 | overlaps the "link to another card" field already open with Paul. |
| 588 | |
| 589 | ### 7.7 Mentions across apps (later) |
| 590 | |
| 591 | A Fichas card showing "Mentioned in 4 Mapa pages", with context. This is a |
| 592 | second call: Mapa answers which team blocks reference item X. It is held to |
| 593 | slice 3, so S10 is proved first. |
| 594 | |
| 595 | ## 8. memoria |
| 596 | |
| 597 | Mapa serves the producer half, S1, S2 and S3, from **slice 1**. |
| 598 | |
| 599 | - **S1** lists every live page, daily and scratch included (revision 10). |
| 600 | `gone` means deleted. Rows come from the event log, coalesced as in §5. |
| 601 | - **S2** is Mapa's own read check: `team` → every admitted member; |
| 602 | `private` → its owner. The person is checked before any revision |
| 603 | (doctrine §6.6). |
| 604 | - **S3** serves a layout that **omits absent parts and their separator**, |
| 605 | as Fichas §6.4 does ("a card with only a title is exactly its title"): |
| 606 | - A team page is its title, then a blank line, then the body. With an |
| 607 | empty body it is exactly its title. |
| 608 | - A daily note is its ISO date (fixed at creation, so memoria can answer |
| 609 | by day), then a blank line, then the body. |
| 610 | - A scratch page is exactly its body. |
| 611 | |
| 612 | The body is served **exactly as stored**: |
| 613 | link text as typed, embeds as their reference string, never expanded. Its |
| 614 | bytes change only when that page's revision changes (§3.2). memoria gets |
| 615 | Fichas content from Fichas. |
| 616 | - **A removed member's private pages.** Doctrine §14 asks Paul whether |
| 617 | ownership survives removal. **Until he rules, gate 5's reading holds** |
| 618 | (doctrine §11 gate 5 and §14): losing team standing does not revoke |
| 619 | ownership. So S2 keeps answering `private` → its owner, whether or not |
| 620 | the owner is still on the roster. In the lone shape, "removed" means off |
| 621 | the admission list. The person cannot sign in to Mapa, but S2, asked |
| 622 | about them by name, still answers `VISIBLE` for their own pages. The |
| 623 | doctrine's §4.3 alternative, "reaches nothing, ownership included", is |
| 624 | marked there as an unruled proposal, and Mapa does not build it. Rows |
| 625 | are kept: Mapa decides nothing about deletion before the ruling. |
| 626 | - **Egress** follows doctrine §8 unchanged. Until Paul rules, private pages |
| 627 | are not embedded for semantic recall. memoria finds them by their own |
| 628 | words only, and says so. |
| 629 | - **Conformance.** Mapa uses `conformance.CheckProducer` with pinned |
| 630 | expectations, as Fichas does (Fichas §6.7). `fixtures/custody.json` at |
| 631 | `91affa1` is static: each case is a state to seed, and no transition is |
| 632 | driven. Mapa has two rungs and no grants, guests or links. Expected: |
| 633 | |
| 634 | | Case | Fixture state | Mapa seeds | Expected | |
| 635 | |---|---|---|---| |
| 636 | | `doc-team`, `doc-team-link` | team | a team page | passes, by honest representation | |
| 637 | | `doc-private` | private, owned by the asker | a private page owned by the asker | passes, by honest representation (unlike Fichas) | |
| 638 | | `doc-deleted` | deleted | a deleted page | passes | |
| 639 | | `doc-was-team`, `doc-link`, `doc-link-added-late` | private, owned by someone else | someone else's private page | passes, by seeding equivalence. Mapa holds no link or move history, and the fixture asks for none | |
| 640 | | `doc-guest` | granted to a guest only | someone else's private page | passes, by seeding equivalence: `NOT_VISIBLE` throughout, as the fixture wants | |
| 641 | | `doc-granted` | granted to the asker | **cannot be represented** | **three pinned S2 failures**: the fixture wants `VISIBLE`, `STALE` and `UNKNOWN` at the current, prior and never-issued revisions. Mapa answers `NOT_VISIBLE` to each | |
| 642 | |
| 643 | **Seeding.** The fixture's private cases are seeded as **scratch |
| 644 | pages**, so S3 is exactly the fixture's one-line `s3_body` |
| 645 | (`conformance.go` compares bytes). A daily note always carries its date |
| 646 | line and could not match. The team cases are seeded as team pages with |
| 647 | the fixture string as the title and an empty body, so S3 is exactly that |
| 648 | string. |
| 649 | |
| 650 | That is eight passing cases and one unrepresentable case. The final table |
| 651 | is written from the running harness, as Fichas §6.7 was, and sent to the |
| 652 | suite as evidence. |
| 653 | - **Later, not in the contract today:** outbound links in S3, so memoria |
| 654 | can rank by the link graph. |
| 655 | |
| 656 | ## 9. Promote to Doc (later) |
| 657 | |
| 658 | This creates a Docs document from a team page's Markdown through the |
| 659 | person's own session: the doctrine §7.1 hand-off, not a sibling write. The |
| 660 | Mapa page keeps a reference to the new document. The thinking stays in |
| 661 | Mapa, and the published version lives in Docs. |
| 662 | |
| 663 | ## 10. Where things live |
| 664 | |
| 665 | - **Repository:** `amadan.net/oficina/mapa`, created on the hub when Paul |
| 666 | approves this spec. Until then, a local repository only. |
| 667 | - **CARLOS:** account `oficina`, sqid `bds`, app `mapa`, channel `edge` |
| 668 | (`teams/provision-team.py`). |
| 669 | - **Host form: a prerequisite, and Paul's.** The suite client accepts only |
| 670 | `<team>.<app>.oficina.works` (`CheckSiblingHost`), and |
| 671 | `hostile_hosts.json` refuses bare `docs.oficina.works`. Paul's own |
| 672 | instances serve bare hosts today (`fichas.oficina.works`), so no sibling |
| 673 | call can reach them. This is the same question already waiting on Paul |
| 674 | for the memoria hookup: **his team's label.** Mapa launches on |
| 675 | `<label>.mapa.oficina.works` from day one. **Paul, 2026-11-12: the team |
| 676 | stays in the hostname** (home ruling 16 stands). `mapa.oficina.works` is |
| 677 | the front door, which sends you to your last-used or only team and has a |
| 678 | team switcher. `mapa.oficina.works/<team>` redirects to |
| 679 | `<team>.mapa.oficina.works`. A self-hosted Mapa keeps its oficina.works |
| 680 | name through a DNS record pointing at its own server, never through a |
| 681 | proxy of ours. Fichas needs the same before S10 can work, and both |
| 682 | apps join `provision-team.py`'s `APPS` (Fichas is not in it today). |
| 683 | - **Framework:** rastrillo at its current module path. Sign-in is the |
| 684 | Oficina door, with Docs' `auth_navigation.go` keymail continuation ported |
| 685 | from the first commit. |
| 686 | |
| 687 | ## 11. Testing gates |
| 688 | |
| 689 | The suite conformance harness (S1/S2/S3) runs in CI from slice 1, and S10 |
| 690 | from slice 2. On top of that: |
| 691 | |
| 692 | 1. **Scope leaks nothing.** Bo's search results, their order, ⌘K's Create |
| 693 | offer, `[[` autocomplete, backlinks, unlinked mentions, and the report |
| 694 | from "Update links" are **byte-identical** whether or not Ana's private |
| 695 | notes contain the term, link to the page, hold a pending link with that |
| 696 | text, or link to a block in it. Linking from a private note never writes |
| 697 | to the target page. A mutation |
| 698 | test proves the gate fails when one scope check is removed. |
| 699 | 2. **Titles cannot reveal anything.** No path lets a private page claim a |
| 700 | title. "Make team page" with a taken title asks for another. A |
| 701 | date-shaped title or alias is refused on create, on rename and on "Make |
| 702 | team page". |
| 703 | 3. **Renames keep links and keep revisions honest.** After renaming B, |
| 704 | every `[[Old]]` resolves to B. Page A's revision and S3 bytes are |
| 705 | unchanged. |
| 706 | 4. **The plaintext gate.** Dump the database file. No title, alias, date, |
| 707 | body, link, reference or `^id` appears in the clear, and the plaintext |
| 708 | columns are exactly §4's list. This is Fichas' gate, ported. |
| 709 | 5. **Embeds** (slice 2). `NOT_VISIBLE` renders nothing. `UNKNOWN` renders |
| 710 | loudly and names the app. No payload byte reaches the database or the |
| 711 | index. Embedded pages do not expand embeds. A team container refuses a |
| 712 | non-team item at write. A Markdown save under `UNKNOWN` goes through and |
| 713 | renders nothing until the payload says `team_visible`. A Fichas |
| 714 | reference field under `UNKNOWN` is refused while the card saves. Only a |
| 715 | `VISIBLE` viewer sees the "not shared with the whole team" notice. |
| 716 | Hostile app URLs and author-link schemes are refused. |
| 717 | 6. **Speed at size.** A 10,000-page synthetic fixture. §6.1's warm targets |
| 718 | are asserted. The cold-wake figure is measured and recorded. |
| 719 | 7. **Scriptless.** `make browser` walks today's note, ⌘K, create, link, |
| 720 | save and conflict with JavaScript off, then on, and fails on any console |
| 721 | error. |
| 722 | 8. **Event completeness.** Every write path logs an event, except draft |
| 723 | writes and retention, which are exempt by name (§5). A mutation test |
| 724 | proves the check works. |
| 725 | 9. **A removed member** (§8). Taking a real member off the admission list |
| 726 | stops them signing in. Under gate 5's reading, S2 still answers |
| 727 | `VISIBLE` for their own private pages. When Paul rules on doctrine §14, |
| 728 | this gate is rewritten to his ruling. |
| 729 | 10. **No trace of an unwritten day.** Opening today's note and leaving |
| 730 | without typing creates no row, no draft, no event and no S1 entry. |
| 731 | 11. **Drafts.** Autosave never changes a page body or revision in place. |
| 732 | No `GET` commits. A closed tab's draft is offered on return as Save or |
| 733 | Discard. A same-block conflict leaves the draft uncommitted. A base |
| 734 | revision past the window gets the side-by-side view. A deleted page's |
| 735 | draft is offered as a scratch page. A stale tab cannot overwrite a |
| 736 | newer draft. Drafts are discarded 30 days after their last write. |
| 737 | "Ana is editing" never appears for a private page. |
| 738 | 12. **Render enforcement** (slice 2). A team page whose text holds an embed |
| 739 | of a non-team item renders nothing for it, whatever path brought the |
| 740 | text in. |
| 741 | |
| 742 | *Amended by the Notion import:* its gates I1 to I19 (its spec §18; I14 |
| 743 | with Mapa images) join these, and M1 to M8 hold the notion module. |
| 744 | |
| 745 | ## 12. Deliberately not built |
| 746 | |
| 747 | | Thing | Trigger | |
| 748 | |---|---| |
| 749 | | Real-time co-editing | Same-block conflicts annoying people in real use | |
| 750 | | The `granted` rung | Someone asks to share a daily or scratch note with one colleague | |
| 751 | | Properties, tables, typed fields | Never in Mapa (decision 3) | |
| 752 | | Graph view | Enough pages that a map tells you something a backlink list does not | |
| 753 | | Folders | Never as the primary structure | |
| 754 | | Public publishing | A real need. Docs is the publishing path first | |
| 755 | | Plugins | Never as a general mechanism | |
| 756 | | Import from Obsidian, Reflect | Paul has a vault to bring. **Notion is met** by the Notion import (`2026-11-17-notion-import.md`), phase 1: pages into Mapa | |
| 757 | | Native Mac app | The web app has been lived in | |
| 758 | | AI features | After memoria's AI answer has been lived with. Doctrine §8 governs it | |
| 759 | |
| 760 | ## 13. Open — for Paul |
| 761 | |
| 762 | 1. ~~Document or outliner~~ **Ruled: document** (Paul, 2026-11-12). |
| 763 | 2. ~~Shared namespace; only team pages hold titles~~ **Ruled: yes to |
| 764 | both** (decisions 6 and 7). |
| 765 | 3. ~~Your team's label~~ **Ruled: `paulca`**. Paul's teams are `paulca`, |
| 766 | `campbells`, `tito`, `carlos` and `test`, created by Alta (see oficina |
| 767 | `portero` Part B). |
| 768 | 4. **Saved views in Fichas.** ~~Personal, team, or both?~~ **Ruled: both** |
| 769 | (Paul, 2026-11-12). Still open: when a field a view filters on is |
| 770 | removed, does the view break loudly or drop the filter? **Ruled: break |
| 771 | loudly.** |
| 772 | 5. **A Fichas reference field** (§7.6): is it the same thing as the "link |
| 773 | to another card" field already open, extended to any Oficina item? |
| 774 | 6. ~~Date links open your own daily note~~ **Ruled: yes** (§3.4), with |
| 775 | its stated cost. |
| 776 | 7. ~~Slice 1 without embeds~~ **Ruled: yes** (Paul, 2026-11-12: "makes |
| 777 | sense"). |
| 778 | 8. ~~History window~~ **Ruled: 90 days of page history, abandoned drafts |
| 779 | kept 30 days** (§5). |
| 780 | |
| 781 | ## 14. Slices |
| 782 | |
| 783 | **Slice 1: a knowledge base someone can live in.** No embeds: Paul ruled |
| 784 | on 2026-11-12 that slice 1 ships without them. |
| 785 | 1. The repo, rastrillo scaffold, schema, seal, event log and the plaintext |
| 786 | gate. |
| 787 | 2. Team pages, the shared namespace, aliases, `[[links]]`, backlinks, |
| 788 | pending links, and the §3.4 verbs. |
| 789 | 3. Daily notes and scratch pages. "Make team page". |
| 790 | 4. The in-memory index with per-viewer scope, ⌘K, the search page, and |
| 791 | gates 1 and 6. |
| 792 | 5. The scriptless editor, then the script layer. |
| 793 | 6. The S1/S2/S3 producer half with pinned conformance. Wire it to memoria |
| 794 | once Paul approves the hookup and gives the team label. |
| 795 | |
| 796 | **Slice 2: embeds.** |
| 797 | 1. Suite revision 12: S10, its fixtures, the doctrine §6.4 amendment, the |
| 798 | leak-list entry, and estilo's three partials. |
| 799 | 2. Fichas: the team label and provisioning (§10). Saved views after |
| 800 | `feat/level-up` merges. The S10 server half and the reference field. |
| 801 | 3. Mapa: embeds of cards and views, the S10 server half for pages, and |
| 802 | pre-warm. |
| 803 | 4. Fichas: embedded Mapa pages on cards. |
| 804 | |
| 805 | **Slice 3:** mentions across apps (§7.7), Promote to Doc (§9), and vault |
| 806 | export (decision 15). |
| 807 | |
| 808 | ## 15. Build notes (slice 1) |
| 809 | |
| 810 | Places where the build had to choose because this spec is silent or |
| 811 | ambiguous. Each is the smallest reasonable choice, with its reason. None |
| 812 | changes a ruling. A reviewer who disagrees with one changes the code and |
| 813 | this list together. |
| 814 | |
| 815 | 1. **`pages.gone` is plaintext.** §4's table does not name it. It is S1's |
| 816 | `gone` (§8) and must answer without the key, so it is classed under the |
| 817 | "ids, `kind`, `rung`" row. It leaks how many pages were deleted. |
| 818 | 2. **Drafts carry a random `version`.** §5's two-tab check needs one. It is |
| 819 | redrawn on every draft write and is random, not a counter, so it shows |
| 820 | only that a draft changed, which `updated_at` already shows. |
| 821 | 3. **Events name an object kind.** §3.1's event row says "object". Gate 8 |
| 822 | needs every write logged, and a person's member row and time zone are |
| 823 | written too, so an event's object is a page or a member |
| 824 | (`object_kind`). Its vocabulary is Mapa's own. |
| 825 | 4. **Members carry no timestamps**, so their plaintext is exactly §4's |
| 826 | "member `id`, address print". |
| 827 | 5. **A member row is created by the person's first write**, not by signing |
| 828 | in or opening a page. A `GET` never writes (§5), and gate 10 forbids any |
| 829 | row for an unwritten day. |
| 830 | 6. **`MAPA_TIME_ZONE` is the team's time zone** (§3.1's "instance setting |
| 831 | in config"), and UTC when unset. |
| 832 | 7. **Mapa wears the suite's Oficina accent and mark.** estilo's ring is a |
| 833 | closed set that only Paul changes, and it has no Mapa hue or icon yet. |
| 834 | Placing Mapa on the ring is his call. |
| 835 | 8. **Link syntax cannot be a title.** A title or alias may not contain |
| 836 | `[`, `]`, `|`, `#` or `^`, which `[[Title#^id|shown]]` needs, and is at |
| 837 | most 120 characters. The date reservation of §3.4 refuses any |
| 838 | ISO-date shape, including one that is no real date (`2026-02-30`). |
| 839 | 9. **Restoring a deleted daily note** brings it back as that day's note. |
| 840 | If the person has since written a new note for that day, it comes back |
| 841 | as a scratch page headed with the date, because a day holds one note. |
| 842 | 10. **The Markdown is Mapa's own subset**, not CommonMark: paragraphs, |
| 843 | headings, list items, quotes, code fences and rules, with emphasis, |
| 844 | inline code, `[[links]]` and `http`, `https` and `mailto` links. No raw |
| 845 | HTML is ever rendered. A block is exactly §3.2's, which the block merge |
| 846 | and `^id` markers need, and the parser's typed blocks are what S10's |
| 847 | `page` payload (§7.3) will carry. |
| 848 | 11. **"Update links" keeps each link's `^id` and shown text**, and changes |
| 849 | only the target text. It runs over the candidates the in-memory index |
| 850 | finds in the actor's scope, and the store checks each again before |
| 851 | editing it. |
| 852 | 12. **A deleted page's title prints, aliases and daily print are removed |
| 853 | with it**, so the title and the day are free at once (§3.4). A restore |
| 854 | does not bring the aliases back: it is a new page at its first |
| 855 | revision. |
| 856 | |
| 857 | 13. **A scratch page is created by its first save**, as a daily note is: |
| 858 | "New scratch page" opens an empty editor and writes nothing until Save |
| 859 | carries some text. |
| 860 | 14. **`/d/<date>` always means the viewer's own note for that date.** It |
| 861 | is where every date link leads, so the link is the same bytes for |
| 862 | every reader and resolves per viewer at request time. An unwritten day |
| 863 | still lists its backlinks: the team pages, and the viewer's own, that |
| 864 | link that date. |
| 865 | 15. **The time zone is typed as an IANA name** ("Europe/Dublin") and |
| 866 | checked on the server, so the setting works with scripts off. Settings |
| 867 | and Deleted pages sit in the account menu, beside Appearance. |
| 868 | 16. **`Store.MayRead` is S2's rule**, built now as the seam for item 6: |
| 869 | a team page for every admitted member, a private page for its owner |
| 870 | whether or not they are still admitted (gate 9, under gate 5's |
| 871 | reading). Nothing serves it over the suite contract yet. |
| 872 | |
| 873 | 17. **Gate 6's cold wake is measured: 1.34 s** from opening the database |
| 874 | to the first search answered, at 10,000 synthetic team pages, on Paul's |
| 875 | development Mac (Apple silicon), not production hardware. Warm, through |
| 876 | the real handler with its JSON: ⌘K search p50 0.33 ms, p95 0.65 ms; |
| 877 | `[[` autocomplete p95 0.16 ms. §6.1's 2 s cold target held here, but |
| 878 | this is one machine; the gate logs the figure on every run and fails |
| 879 | only past 10 s. |
| 880 | 18. **Writers keep the index current; readers only read** (review M3 |
| 881 | and its follow-up). Fichas asks `MAX(events.id)` on every request |
| 882 | and the reader that notices a change replays it. In Mapa every write |
| 883 | goes through `Store.write`, which, after its transaction commits, |
| 884 | catches the index up in the writer's own request. A reader takes only |
| 885 | the read lock and never parses someone else's write, so Bo's query |
| 886 | costs the same whatever Ana just wrote. Writes another process makes |
| 887 | (two processes share the file during a CARLOS zero-downtime swap) |
| 888 | are caught up off-request by a watcher that reads the log's head |
| 889 | about once a second and takes the write lock only when the index is |
| 890 | behind. It commits nothing, so it is not one of the timers doctrine |
| 891 | §13 rules out. The first read after a wake loads everything. The |
| 892 | viewer cache still follows an in-process write count. |
| 893 | 19. **Ranking details §6.2 leaves open.** Titles and aliases match when |
| 894 | every query word starts a word of the title. They rank exact title |
| 895 | first, then titles the query begins, then the rest. Bodies need every |
| 896 | word, the last as a prefix. A prefix stands for at most its 32 most |
| 897 | frequent terms in each partition. One typed letter searches titles |
| 898 | only. BM25 uses k1 1.2 and b 0.75. The backlink boost is |
| 899 | 0.5 × ln(1 + team pages linking here), applied to the head of the |
| 900 | BM25 order. The viewer's own daily notes also match by date prefix. |
| 901 | 20. **`[[` autocomplete's "the viewer's own pending link texts"** is read |
| 902 | as the pending texts in the viewer's scope: those typed in team pages |
| 903 | (which every member reads) and in the viewer's own private pages. They |
| 904 | are partitioned like the postings, so a query never reads another |
| 905 | person's. |
| 906 | 21. **Print keys are derived apart from sealing keys** (HKDF info |
| 907 | `oficina/mapa:print:<purpose>`), so no key both encrypts and prints. |
| 908 | |
| 909 | 22. **The keystroke-to-paint target is asserted as keystroke to results |
| 910 | in the page**, warm, at 10,000 pages: p50 6 ms, p95 9 to 12 ms on the |
| 911 | development Mac. Paint follows in the next frame on a real screen. |
| 912 | Headless Chromium has no display to pace frames: its next animation |
| 913 | frame came 20 to 150 ms after the list had rendered, and a DevTools |
| 914 | key event waits for that frame too. So the test types from inside the |
| 915 | page and logs the headless frame time without asserting it. Paul or a |
| 916 | reviewer may want this confirmed by hand in a real browser. |
| 917 | 23. **The block merge refines diff3.** Where both sides kept the same |
| 918 | number of blocks in a changed stretch (edits in place), each block is |
| 919 | resolved on its own, so Ana's edit to one block and Bo's to the next |
| 920 | do not conflict for being neighbours. A save that needs no merge |
| 921 | keeps every byte. *Revised by the level-up (§6.4, D13):* a merged |
| 922 | body keeps the current revision's bytes too. Its blocks, and the |
| 923 | bytes between two of its blocks that are still neighbours, are |
| 924 | emitted as they are; blocks taken from the saver's text bring their |
| 925 | own source and seams; only a seam where the two sides meet is |
| 926 | re-joined with one blank line (a tight list stays tight). If the |
| 927 | result would not parse back to the settled blocks, the whole body is |
| 928 | re-joined that way instead. Resolve's chosen text settles the same |
| 929 | way. |
| 930 | 24. **A conflict offers Yours, Theirs, or Both (yours first)** for each |
| 931 | block both people changed. With no merge base, it is Yours or Theirs |
| 932 | whole. Choosing only what is saved now discards the draft and commits |
| 933 | nothing. "Decide later" leaves the draft as it is. |
| 934 | 25. **New pages have no autosave until their first Save.** A draft is |
| 935 | keyed by a page or by a day (§3.1), and a new team or scratch page has |
| 936 | neither until it exists, so its text is lost if the tab closes before |
| 937 | Save. A fix needs a draft key of its own (a random id from the tab): |
| 938 | a new plaintext column, so a change to §4's list. It is left as a |
| 939 | known limit (README), after review. |
| 940 | 26. **Where a closed tab's draft is offered** (§5): on its page, and on |
| 941 | today's note. Today's note also offers drafts on deleted pages ("Save |
| 942 | as a scratch page" or Discard) and links to drafts on other pages. |
| 943 | 27. **Retention runs when the app wakes** (the platform runs no timers): |
| 944 | drafts past 30 days, revisions past 90 days except each live page's |
| 945 | current one, and a page deleted more than 90 days ago loses its |
| 946 | revisions and sealed record but keeps its gone row for S1. Like draft |
| 947 | writes, it is exempt from gate 8 by name. Between wakes, every read |
| 948 | already ignores what has aged out. |
| 949 | 28. **Restoring from history restores the body.** The title stays as it |
| 950 | is: taking an old title back is a rename, with the namespace's |
| 951 | checks. The event's verb is `reverted`. |
| 952 | 29. **The script layer's timings**: an autosave 1.2 s after typing stops; |
| 953 | the commit two minutes after the last autosave; a pending autosave |
| 954 | flushed when the tab closes. ⌘K is ⌘K or Ctrl+K, and its Create offer |
| 955 | is the last row. The time zone offer remembers "Not now" for that |
| 956 | browser zone. |
| 957 | 30. **GORM's automatic timestamps are off** on pages and drafts: the store |
| 958 | sets every time from its own clock, so the history window, the draft |
| 959 | window and "is editing" all count from the same clock. |
| 960 | |
| 961 | 31. **A stale tab never destroys a newer draft** (review M1). Save and |
| 962 | Discard carry the draft version their page showed. A Save from a tab |
| 963 | that had not seen the person's newest draft still commits when it can |
| 964 | (outcome Kept), and the draft is kept with its base unchanged, so |
| 965 | committing it later merges against that save. Re-basing it onto the |
| 966 | new revision instead would let it overwrite the save. A stale Save |
| 967 | that cannot commit without a choice is refused, and the editor shows |
| 968 | that tab's text again. A stale Discard is refused, and the draft is |
| 969 | offered again as it is now. |
| 970 | |
| 971 | 32. **Pages are named in URLs by a random public id** (review M2): the |
| 972 | page nonce, written once at creation, in base 36 (`/p/2kq9xw3m1ab`), |
| 973 | with a unique index. The sequential row id stays inside the store. It |
| 974 | counted everyone's pages, private ones included, so `/p/1` then |
| 975 | `/p/5` told Bo that someone had written three private pages between. |
| 976 | Alias ids in a team page's rename form stay sequential: they count |
| 977 | renames of team pages, which every member can see in history anyway. |
| 978 | Gate 1 now interleaves Ana's private writes with the team's pages, |
| 979 | drawing team and private nonces from separate repeatable streams in |
| 980 | the test, and `make mutate` holds that it catches a link drawn from |
| 981 | the row id. |
| 982 | |
| 983 | 33. **Small rules the review's lows added.** A deleted page restores |
| 984 | once: the restore moves its text into the new page and leaves only |
| 985 | the gone row (L3). A merge base, a conflict's base and history all |
| 986 | stop at the 90-day window even before retention runs (L2). A query |
| 987 | reads at most 16 words of at most 512 bytes (L6). A return address |
| 988 | with a control character or a backslash is refused (L4). Unlinked |
| 989 | mentions are checked in display order and stop at 100, and gate 6 |
| 990 | times page views, a title of the commonest words included, against |
| 991 | 50 ms (L5). |
| 992 | |
| 993 | --- |
| 994 | |
| 995 | ## Appendix A — revision 2's answers to the Fable review of revision 1 |
| 996 | |
| 997 | | Finding | Answered in | |
| 998 | |---|---| |
| 999 | | H1: S9 reserved, S7 retired | §7.2: S10 | |
| 1000 | | H2: search, ranking and Create unscoped | §6.2, §6.3, gate 1 | |
| 1001 | | H3: non-team embeds visible in source, history, S3 and export | decision 13, §7.4, §7.5 | |
| 1002 | | H4: Markdown and URLs crossing apps | decision 12, §7.3 typed blocks and two URL classes | |
| 1003 | | H5: bare hosts fail `CheckSiblingHost`; subject kind | §10, §13 item 3, §7.3 subject kind | |
| 1004 | | M1: four values without a revision | §7.3: three values | |
| 1005 | | M2: "says less than S3" false | §7.3: "What S10 adds", leak-list entry | |
| 1006 | | M3: per-row citation; `more` | §7.3 `list` | |
| 1007 | | M4: S3 bytes under rename | decision 9, §3.2, §8, gate 3 | |
| 1008 | | M5: custody fixture cases | §8 conformance table | |
| 1009 | | M6: removed owner | §8, gate 9 | |
| 1010 | | M7: plaintext list incomplete; plaintext graph | decision 14, §3.1, §3.2, §4, gate 4 | |
| 1011 | | M8: unspecified verbs | decision 8, §3.4, §6 time zone | |
| 1012 | | M9: block ids under a textarea | §3.2 `^id` markers | |
| 1013 | | L1: precedent numbers | §6.1 | |
| 1014 | | L2: memoria citation | §0, decision 1: Fichas decision 1 | |
| 1015 | | L3: unused rulings cited | header | |
| 1016 | | L4: ordinal | decision 1 | |
| 1017 | | L5: account | §10 | |
| 1018 | | L6: level-up stale | §7.6 | |
| 1019 | | L7: deadline, pre-warm, caps, no-store | §7.3, §6 | |
| 1020 | | L8: creation on open, autosave churn | §5, §6, gate 10 | |
| 1021 | | L9: doctrine §6.4 | §7.3 | |
| 1022 | |
| 1023 | ### Round 2 — Fable's re-review of revision 2 (`2345d97`) |
| 1024 | |
| 1025 | | Finding | Answered in | |
| 1026 | |---|---| |
| 1027 | | H1: removed member inverted | §8, gate 9: gate 5's reading, ownership holds | |
| 1028 | | M1: write-time check gaps and race | §7.4: render enforcement, base-revision diff, each S10 value, restore and Make team page; gate 12 | |
| 1029 | | M2: `^id` minted from a private note | §3.2: minted only by an edit to the target page; gate 1 | |
| 1030 | | M3: coalesced autosave storage | §3.1 draft, §5, gate 11 | |
| 1031 | | M4: plaintext list | §3.1, §4: nonces, revision store, drafts, members, sessions; 90-day window | |
| 1032 | | M5: text-keyed links trade-off; Update links scope | decision 9, §3.4, gate 1 | |
| 1033 | | M6: conformance table | §8: eight pass, one unrepresentable with three pinned failures; S3 layout | |
| 1034 | | L1: zero frequency; timing | §6.2: smoothing, partitioned postings | |
| 1035 | | L2: date link format, refusals, time zone | §3.4, gate 2, §13 item 6 | |
| 1036 | | L3: restoring a deleted page | §3.4: new id | |
| 1037 | | L4: past 64 as links | §7.3: render nothing plus a page note | |
| 1038 | | L5: URL fields, picker, lone-shape lists | §7.3, §7.4 | |
| 1039 | | L6: daily note date in S3 | §8 S3 layout | |
| 1040 | |
| 1041 | ### Round 3 — Fable's conditional approval of revision 3 (`057d474`) |
| 1042 | |
| 1043 | | Finding | Answered in | |
| 1044 | |---|---| |
| 1045 | | M1: S3 layout fails the byte comparison | §8: absent parts omitted; private cases seeded as scratch pages | |
| 1046 | | M2: draft commit on `GET`; unattended conflicts | §5: every commit a `POST` by the person; conflicts stay drafts; window, deleted page, tab version check, 30-day retention; gate 11 | |
| 1047 | | M3: `UNKNOWN` saves, the lost mark, the orphaned sentence | §7.4: render enforcement alone for Markdown; Fichas refuses the field; sentence qualified; gate 5 | |
| 1048 | | L1: "Ana is editing" | §5, §4 leak list | |
| 1049 | | L2: owner sees nothing | §7.4: notice for `VISIBLE` viewers only | |
| 1050 | | L3: §13 numbering | §13 | |
| 1051 | |