oficina / mapa Public
mapa
The Oficina suite's team knowledge base. The design is docs/superpowers/specs/2026-11-12-mapa-design.md, approved by Paul on 2026-11-12; read it before changing behaviour here. Its §15 records every choice the build made where the spec was silent or ambiguous. A change that departs from the spec needs the same review it had.
A rastrillo app on the current amadan.net/rastrillo/rastrillo path (never the frozen github.com/carlosframework/rastrillo one; TestNoFrozenRastrilloImport forbids it), styled with estilo. Read rastrillo's SKILL.md (go list -m -f '{{.Dir}}' amadan.net/rastrillo/rastrillo) before writing app code. Modelled on Fichas (the in-memory index fed by the event log, the seal, the plaintext gate) and Portero (the pins, .amadan/ci, the Makefile, estilo's files served straight from the module).
Layout
cmd/mapa/—rastrillo.Resolve+Serve, afterLoadConfig.internal/mapa/-config.go— every refusal to boot, tested. -auth.go,auth_navigation.go,door.go— magic-link sign-in with theMAPA_OWNERSadmission list, Docs' keymail continuation, estilo's door. -models.go,migrations/— spec §3.1.seal/— the only encryption. -store.go—Store.write, the one way to write: it refuses to commit a transaction that logged no event (gate 8). Draft writes (drafts.go) and retention (retention.go) are the exemptions, by name (§5). -pages.go,verbs.go,aliases.go,daily.go,share.go,markers.go,commit.go,history.go— the §3.4 and §5 verbs. -markup/— Mapa's Markdown subset: §3.2's blocks, links, the safe renderer and the three-way block merge. -locale/— dates, times and numbers in the reader's locale (level-up build note 85):dates.json, CLDR's date patterns for the offered locales (make locale-dateswrites it from Node's ICU), andformat.go, their interpreter; numbers are rastrillo's.locales.gopicks the reader's locale through rastrillo's middleware and clones the templates per locale. Write every date or count a person reads through it ({{longDate}},{{stamp}},{{number L n}},viewer.Locale,scope.Locale); store and link ISO dates only. The reader's locale is their own (Settings,settings_locale.go, sealed bymembers_locale.go), else their browser's Accept-Language alone, elseMAPA_LOCALE. -index.go,graph.go,views.go,mentions.go,postings.go,search.go,rank.go,suggest.go— the in-memory index, fed by the event log and partitioned by scope (§6.2). -readrule.go,s3.go— S2's rule and S3's layout, item 6's seams. - The Notion import (docs/superpowers/specs/2026-11-17-notion-import.md, phase 1):import_*.go, the only files that importamadan.net/oficina/notion.git.import_connect.go(NotionAccess, the fake in tests),import_credential.go(connect, disconnect, finish, forget),import_book.go(bookkeeping, fenced to notion*), `importrun.goandimportjob.go(leases, Stop, resume, the goroutine),importsurvey.go,importset.go,importtitles.go,importwrite.go(Survey and Write),importstore.go(ImportCreate,ImportUpdate),importimages.go,importimagesstore.goandimportimagesplace.go` (the image step over Mapa images, and notionimages),import_history.go(History's and the kicker's words),import_handlers.go,import_view.go,import_report.goandtemplates/import*.html(the screens). -notionmd/— the import's mapper, Notion's block tree to Mapa's Markdown, pure, checking its own output againstmarkup. It never imports the notion module: its tree is Mapa's own copy. -handlers_*.go,today.go,private.go,settings.go,render.go,shell.go,templates/,static/— the screens, and estilo's files taken straight from the pinned module. - The level-up's shell (docs/superpowers/specs/2026-11-14-mapa-level-up.md):frame.go,menus.go,side.goandtemplates/frame.htmlbuild estilo's stacked bar, the menus and the sidebar with its rail;around.go(the one scoped accessor every new read path uses),mapview.go,calendar.goandstatic/links.*are the Links panel, its map, the week and the month;pins.goandrecent.goare the sidebar's own lists;lastedit.gois the kicker's "Edited by".mapa.jsis the editor's and ⌘K's script layer,links.jsthe panel's andhistory.jsthe History panel's;frame.css,links.css,history.cssandpalette.cssstyle them.versions.go,diff.go,diff_words.goandhistory_view.goare the History panel's list, summaries and word diff (level-up §4.5);typeddate.goandsnippet.goare ⌘K's typed dates and marked snippets. Phase 2's server half:autosave.goandhandlers_autosave.goare the editor's autosave, its merge reply,rebaseandcommit=1;firstscratch.goa new scratch page's single-flight first commit (D12);island.gothe editor's JSON island and/links/resolve;markup/settle.gothe byte-preservingSettle.editor/— the page editor (level-up spec §6):markup.mjs, a line-for-line port ofmarkup/'s parser;schema.mjs, whosetoDOMis the server's HTML; and the bundle build, whose output (internal/mapa/static/editor.<hash>.js) is committed. Gate L4 (parity.test.mjs) holds both tomarkup/testdata/golden.json, which Go writes from the corpus beside it. Change the renderer, the parser or the schema together, thenmake goldenand commit the result.serialize.mjswrites the document back as Markdown, re-emitting untouched blocks and seams fromfidelity.mjs's side table (§6.4), which also holds the settle plugin (reparse, marker and list rules), rebuild andprepareSave;clipboard.mjsis §6.6's copy and paste. Gates L1–L3 (fidelity.test.mjs) run over the same corpus; L3 writesmarkup/testdata/editor.json(make editor-golden), which Go parses ineditor_test.go. The editor on the page:page.mjsreads the island and mounts on the<article>;saver.mjsis §6.5's autosave, commit, rebase, leaving and closing (adapter.mjsis its view of the editor);conflict.mjsthe inline choice;resolutions.mjsandchipview.mjsthe chips' states;keys.mjs,commands.mjsandinputrules.mjsthe keys, blocks and Markdown shortcuts;suggest.mjs,slash.mjsandcombobox.mjsthe[[and/lists;datepicker.mjsthe date picker/→ Date and Insert → Date… open, reading typed dates withtypeddate.mjs, a port oftypeddate.goheld to it byinternal/mapa/testdata/typed_dates.json(build note 83);dates.mjswrites dates from the island's patterns, held to Go bylocale/testdata/date_labels.jsonand L4'sgolden_locales.json;bubble.mjsthe selection's toolbar;pagelink.mjsits Page link and ⌘L (build note 81);anchors.mjsthe ¶;tasks.mjsthe task boxes;writearea.mjsa click on the page's empty area (build note 84);maketeam.mjsMake team page from a selection;accessory.mjsthe phone's row;notices.mjsthe bars and the lead's save status;title.mjsthe title renamed in place, shared with the header's field (build note 78).saver.test.mjsis L9's client half; ininternal/mapatest/,editor_browser_test.goholds L5 and L9 end to end,editor_typing_browser_test.gothe typing, andeditor_access_browser_test.goL10, with axe-core vendored intestdata/axe/. - Images (docs/superpowers/specs/2026-11-17-mapa-images.md, its §12 the build notes):imagefile/sniffs, limits and strips each format without decoding pixels;images.go(types, limits, the blob semaphore),images_store.go(upload, sealing, Put),images_read.go(the read rule, serving bytes, copies, the allowances),images_attach.go(tx.commit's explicit attaching and theunreferenced_atstamp),images_copies.go(Make team page's anddraftToScratch's copies),images_remove.go,images_sweep.go,images_render.go(drawing on page P),images_list.go,images_bucket.go(the bucket's own Put),config_images.go,handlers_upload_read.go(uploads read into bounded memory, never to a temporary file),bodies.go(every body bounded; multipart for upload routes only) andhandlers_images*.go. Ineditor/:imagedom.mjs,imageview.mjs,upload.mjs(its queue gated byupload.test.mjs),imagebubble.mjs,altinset.mjs(the ALT badge and the description field over the image, build note I22). - A team page's look (docs/superpowers/specs/2026-11-22-mapa-columns-icons.md, §2–§4, phase 1):looks.go(the record'siconandbanner, thestyledverb,SetLook),looks_images.go(which images a look may name, and a removal taking its image out of the look),looks_render.go(drawing icons wherever a title is, the band),looks_history.go(History's words),handlers_look.goandtemplates/look.html(POST and the scriptless page),emoji/(Unicode's RGI list, vendored at 16.0, and the picker's JSON,emoji_route.go),images_cache.go(the small-image cache, served only after the read rule) andstatic/look.js(the picker, uploads and Reposition). A record's references are its body's and its look's images (Record.images); chips draw icons from their resolution (markup.ChipIcon), never from a node attribute. - Column layouts (the same spec, §1, phase 2):markup/columns.go(the strict grammar of §1.1, fences as blocks withBlock.Column,FenceLike,Grammar,renderLayout) andmarkup/merge_columns.go(ValidLayouts, the merge's layout rules,alignKeys,addedColumns,WholeOrInside);grammar.go(countedHere, the 409 for a post counted by another grammar);versions_columns.go(History's words). Ineditor/:columns.mjs(the commands),markup.mjs's port of the grammar, the schema'scolumnsandcolumnnodes, fence pseudo-blocks inserialize.mjs(their origins on the containers:originAttr), andfidelity.mjs'sfenceRule(D16).make pandoc-fixturerecords Pandoc's reading (markup/testdata/pandoc.json, COL12). - Pages inside (the same spec, §5, §6.3, phase 3):inside.go(the "In: [[P]]" relation, derived in the index'swithinmap, and the scopedInside),side_inside.go(the Pinned rows' arrows, themapa-opencookie,POST /view/openandGET /p/{id}/inside),import_pins.go(the import pins its roots once, marked in the sealed coordinate). Pins hold up to 20 (pins.gostill reads a list sealed at 12). - The importer's looks (the same spec, §6.1, §6.4, phase 4):import_looks.go(a page's icon and cover prepared before its write, under notion_images' pseudo-blocksicon:andcover:; covers fetched only from Notion's file store and its cover gallery, the one external path the notion module pins), andImportUpdate's styled revision between the renamed and the edited.internal/mapatest/— the gates of spec §11, from the outside.browser_test.gois behind thebrowsertag.scripts/preview/,scripts/mutate/—make preview,make mutate.
Rules Mapa holds hard
- Sealed at rest. Titles, aliases, dates, bodies, drafts, addresses and time zones are sealed. The plaintext columns are exactly §4's list:
plaintext_test.goreads the real schema, and the file scan signs in for real and reads every byte on disk, WAL included (gate 4). The one named exception is rastrillo's: a signed-in address in its ownauth_linksandauth_sessionsrows (spec §4), never in Mapa's tables. - Every write logs an event, in the same transaction (gate 8). Mapa is never an actor: every event names a person.
- A GET never writes. Not a member row, not a draft, not a daily note (gate 10). A person's member row is created by their first write.
- Scope before traversal. Every read of the in-memory index is team pages plus the viewer's own private pages, and nothing anywhere counts what the viewer cannot see (§3.3, §6.3, gate 1).
- A row you may not see is a 404, never a 403.
- Mapa reaches the network in two places only: Notion, through
amadan.net/oficina/notion.git, only fromimport_*.go, only during a run (and the one verify call when a token is saved); and CARLOS's own bucket, for images, fromimages_bucket.goandconfig_images.go. No client, transport, dialler or resolver anywhere else ininternal/mapaorcmd(gate I8 names the two image files). Rastrillo's sign-in mail lives in rastrillo. - Screens work with JavaScript off; destructive actions get their own confirm page.
- The gate is
make ci(vet, gofmt, rastrillo's code budget, Fiesta's spacing check, tests, migration check, andmake editor: npm ci, the bundle rebuilt with no drift,node --test), the same definition CI runs. It needsnodeandnpmon PATH.make spacingholds every margin, padding and gap ininternal/mapa/staticto avar(--rst-sp-N)step or a/* spacing-allow: why */, andmake browser's rhythm audit holds the signed-in screens to the scale (level-up build note 89).CGO_ENABLED=0throughout. Usemake, not barego test: the Makefile pins the toolchain.make browseris gate 7 andmake mutateproves gates 1, 4 and 8 can fail, that a rename carries only drafts on its own base (L9, level-up build note 79), that Recently edited filters team pages inside its query (build note 80), the images' named risks (scripts/mutate/images.go), and that the Notion import's gates I1 to I25 can (MUTATE_GATES=I3,I13runs a few).
Serving
MAPADEK=<base64 32 bytes> MAPAINSTANCEKEY=<secret> \ MAPAOWNERS=ana@example.com MAPAALLOWLOGGED_MAIL=1 \ ./mapa -addr 127.0.0.1:8834
MAPA_TIME_ZONE is the team's default time zone (UTC if unset). MAPA_LOCALE is the team's locale, how dates and numbers are written for a browser that asks for none Mapa offers (en-IE if unset; one of locale.Offered(), spelt as CLDR does). MAPA_IMPORTERS names who may import from Notion, each also an owner; unset, the import does not exist. HOME_DIRECTORY_ORIGIN adds "All apps" to the account menu. GET /healthz and GET /api/version are the framework's. make preview serves the real app over synthetic pages, signed in, on loopback.
Known follow-ups
- estilo's
chromeimports the frozen rastrillo path, sogo.modcarries it indirectly. Mapa imports nothing from it.