| 1 | # π€ memoria |
| 2 | |
| 3 | The Oficina suite's memory. One instance per team. |
| 4 | |
| 5 | Ask a question, get an answer grounded in your team's own documents β |
| 6 | with a citation you can open, always. |
| 7 | |
| 8 | **What exists today is a search engine with a small AI answer, not an |
| 9 | assistant**, and it has exactly two model calls in it, **both switched |
| 10 | off unless you switch them on**. With them off β the default β the trust |
| 11 | claim is as strong as it gets: |
| 12 | |
| 13 | > memoria's passages and its index are sealed at rest under this team's |
| 14 | > own key, and **no document ever leaves this instance** β not at query |
| 15 | > time, and not at indexing time, because nothing is sent anywhere to be |
| 16 | > indexed. |
| 17 | |
| 18 | **With `MEMORIA_AI=on`, two things change, and this is all of it.** |
| 19 | |
| 20 | **First, an AI answer when nothing checked answers.** When a search has |
| 21 | results but memoria's own checks found no answer (no phone number, VAT |
| 22 | number or similar to show, and no best guess), memoria sends **up to |
| 23 | eight passages** β the top eight that search returned, passages you were |
| 24 | already allowed to read β and your query to **TensorX**, and shows its |
| 25 | answer, marked π€ AI answer, above the results. Every paragraph or bullet |
| 26 | cites the passages it rests on, and one citing nothing is not shown; the |
| 27 | AI may use bold and bullet points and nothing else. It runs only once |
| 28 | you stop typing, never on a keystroke. The reply is kept **in memory** |
| 29 | for ten minutes, so asking the same question about the same passages |
| 30 | again β Enter, a reload β usually does not send them again: it does |
| 31 | when the passages have changed, after a failed or late answer, and once |
| 32 | the reply has aged out or been pushed out by newer ones. π / π under an |
| 33 | answer are kept, sealed, on Reports: the query, your note and which |
| 34 | passages it cited, never the answer's words. It never asks for a calculation: a search |
| 35 | for an average, a total or a count gets no AI answer. To decide whether |
| 36 | memoria's checks found an answer, it repeats the search β and for a |
| 37 | search that asks for a postal address, that repeats the address step |
| 38 | below, so the same passages go to TensorX once more. A search that |
| 39 | finds a checked answer and also asks for a postal address can still send |
| 40 | passages for the address (below). |
| 41 | |
| 42 | A search that names a kind of value β `eircode`, `phone`, `IBAN` β |
| 43 | also finds passages that hold one without saying the word, so `Eircode` |
| 44 | finds an eircode written on its own. That happens inside this instance: |
| 45 | nothing is sent to find them. |
| 46 | |
| 47 | **Second, postal addresses.** When a search asks for a postal address β "office address", "postal address" β |
| 48 | memoria first looks for one with its own checks. Addresses have no |
| 49 | checksum, so those checks cannot find one. It then sends **up to eight |
| 50 | passages per search request** β the top eight that search returned, |
| 51 | passages you were already allowed to read β to **TensorX**, the one named |
| 52 | provider, which points at any addresses in them. **Not while you type:** |
| 53 | live search skips this step on each keystroke and makes one request with |
| 54 | it once you pause typing. Submitting with Enter, or reloading, is another |
| 55 | full request, so one query can send passages more than once. |
| 56 | memoria shows only text it finds byte-for-byte in those passages, marks |
| 57 | each such row π€ with TensorX and the model's name, and never shows the |
| 58 | model's own words. Nothing else is sent: not |
| 59 | the rest of your documents, not your query's other results, and nothing |
| 60 | at all for phone numbers, eircodes, IBANs, VAT numbers or email |
| 61 | addresses, which memoria checks itself. TensorX can read what it |
| 62 | receives; we rely on its retention terms and cannot verify them. |
| 63 | |
| 64 | An earlier draft of the first sentence said "nothing leaves this |
| 65 | instance", which was false and a code review caught it. Signing in fetches |
| 66 | `https://<your address's domain>/.well-known/keymail` **before** anyone is |
| 67 | admitted, so an anonymous visitor can make the instance dial any domain |
| 68 | they type. No document leaves; a DNS name does. |
| 69 | |
| 70 | **The full assistant changes this again, by much more**, and the design |
| 71 | spec is explicit about how: embeddings come from a hosted API, so |
| 72 | switching it on will send **every document in the corpus** to the named |
| 73 | provider once, at indexing time β not just the passages behind an answer. |
| 74 | That is not built. When it is, this paragraph is replaced by Β§3.6 of the |
| 75 | design, and not before: Β§3.6 describes egress this binary does not yet |
| 76 | perform, and saying it early would overstate what leaves as surely as |
| 77 | the old sentence here understated it. |
| 78 | |
| 79 | ## Live |
| 80 | |
| 81 | **https://memoria.oficina.works** β account `bds`, channel `edge`, |
| 82 | serving `71bebef`. Sign in with `paul@keymail.dev`, `paul@rslw.com` or |
| 83 | `paul@tito.io`; real email goes out through the platform's SES, so no |
| 84 | sign-in link is ever written to a log. |
| 85 | |
| 86 | It starts **empty**. Paste or upload on **Add content** (`/add`, linked |
| 87 | from the front page) to fill it β the |
| 88 | seed tool needs filesystem access to the database, so it only works |
| 89 | against a local instance. |
| 90 | |
| 91 | The origin moved here from `memoria.bds.oncarlos.com` on 2026-09-04, once |
| 92 | the certificate issued β the move `docs`, `sheets` and `calendar` had |
| 93 | already made, along with `id.oficina.works` and the apex. It was |
| 94 | `MEMORIA_ORIGIN` and a restart and nothing else: no hostname is compiled |
| 95 | into this binary. |
| 96 | |
| 97 | `memoria.bds.oncarlos.com` still answers. It is the platform route the |
| 98 | custom hostname sits in front of, not a second deployment. Signing in |
| 99 | there still *starts* β but it does not leave you signed in there, because |
| 100 | `MEMORIA_ORIGIN` is the base of every emailed link, so the link lands you |
| 101 | on `oficina.works` and the session cookie is set for that host. Use the |
| 102 | canonical name. |
| 103 | |
| 104 | That value is also the CSRF yardstick and the OAuth `client_id` keymail |
| 105 | validates redirects against, so it must match the host the browser is |
| 106 | actually on. Be precise about how much the CSRF half is doing, though: |
| 107 | `csrf.SameOrigin` reads `Sec-Fetch-Site` **before** it compares origins, |
| 108 | so a browser sitting on the old hostname sends `same-origin` and passes. |
| 109 | What refuses is a scripted post carrying a stale `Origin` header. The |
| 110 | mailed link, not the CSRF check, is what actually funnels people onto one |
| 111 | host. |
| 112 | |
| 113 | **The DEK is the whole corpus.** It lives in `carlos secrets` for this |
| 114 | app, and a copy is at `memoriadrive/DEK-production.txt`. Lose both and the |
| 115 | data is unreadable β exactly as with `SHEETS_DEK`. |
| 116 | |
| 117 | ## Trying it locally |
| 118 | |
| 119 | ``` |
| 120 | cd /home/paulca/memoriadrive |
| 121 | ./run.sh |
| 122 | ``` |
| 123 | |
| 124 | `run.sh` sets `MEMORIA_ALLOW_LOGGED_MAIL=1`, which is a **local-dev-only** |
| 125 | opt-in: without SMTP configured, rastrillo logs the magic link instead of |
| 126 | mailing it, and that link is a live credential. The app now refuses to |
| 127 | start without either real SMTP or that explicit flag, because the default |
| 128 | had been to log sign-in credentials silently. |
| 129 | |
| 130 | Then open **http://127.0.0.1:8823** and sign in. Sign-in goes through |
| 131 | keymail, so use an address on the owners list in `run.sh` |
| 132 | (`paul@tito.io` or `paul@keymail.dev` as it stands). |
| 133 | |
| 134 | It comes pre-seeded with 55 documents and 649 passages β every `.md` in |
| 135 | the `oficina` tree, so the first thing you can search is the suite's own |
| 136 | specs. Try `sealed at rest`, `grants join`, `revoke`, `escritorio`, |
| 137 | `plausible empty list`. |
| 138 | |
| 139 | Things worth poking at, because each is a decision rather than an |
| 140 | accident: |
| 141 | |
| 142 | - Search **ORs** its terms. Ask it a question in words β "what is the |
| 143 | worst available failure shape" β and it works. ANDing would return |
| 144 | nothing, and nothing is indistinguishable from having nothing. |
| 145 | - A no-match page tells you how much *is* indexed, so an absent answer |
| 146 | never looks like an empty index. |
| 147 | - Every result cites a document and a passage number, and the passage |
| 148 | anchors when you follow it. |
| 149 | |
| 150 | ### Adding your own |
| 151 | |
| 152 | Paste or upload text on **Add content** (`/add`), or seed a directory: |
| 153 | |
| 154 | ``` |
| 155 | cd /home/paulca/memoriadrive |
| 156 | MEMORIA_DEK="$(cat DEK.txt)" ./seed --db m.db --dir /path/to/notes --source notes |
| 157 | ``` |
| 158 | |
| 159 | The seed tool uses the same store, chunker and sealing as the app. It is |
| 160 | the honest ancestor of slice 3's connectors, and it bypasses nothing β |
| 161 | without the right DEK it refuses to run. |
| 162 | |
| 163 | ### The DEK |
| 164 | |
| 165 | `DEK.txt` in `memoriadrive` is the key everything is sealed with. **Lose |
| 166 | it and the corpus is gone**, exactly as with Sheets' `SHEETS_DEK`. The |
| 167 | app never generates one: a generated fallback would seal this boot's data |
| 168 | under a key the next boot cannot derive, losing the data quietly instead |
| 169 | of refusing loudly. |
| 170 | |
| 171 | ## Deploying |
| 172 | |
| 173 | ``` |
| 174 | make release |
| 175 | carlos ship --app memoria --account bds --mail submit --version <sha> releases/memoria-linux-arm64 |
| 176 | carlos promote --app memoria --account bds <sha> edge |
| 177 | ``` |
| 178 | |
| 179 | **Mail submission.** Ship every build with `--mail submit`: it declares |
| 180 | that the build sends through CARLOS mail submission (`mail.FromCarlos`, |
| 181 | `internal/memoria/mailer.go`, From `$CARLOS_MAIL_FROM`). Until `carlos |
| 182 | email submission on --app memoria` runs, memoria keeps sending over |
| 183 | `CARLOS_SMTP_*`; after it the agent sets `CARLOS_MAIL=submit`, memoria |
| 184 | holds no mail credential, and every instance must run a build shipped |
| 185 | with the flag. `carlos deploy` has no `--mail` flag yet (carlos main |
| 186 | 9eec0236), so ship and promote as above; once it has, `carlos deploy |
| 187 | --app memoria --account bds --channel edge --mail submit --timeout 5m |
| 188 | releases/memoria-linux-arm64` does both. |
| 189 | |
| 190 | Trust the command `make release` prints over the one written here: it |
| 191 | names the path it actually built. This section used to say |
| 192 | `./releases/memoria-arm64`, which no build has ever produced β the binary |
| 193 | is named for its target, `linux-arm64`. |
| 194 | |
| 195 | `carlos deploy` refuses to run when the tree is unclean, and it counts |
| 196 | untracked files. A stray editor directory or dotfile in the checkout is |
| 197 | enough to stop it, with a message about the version defaulting to the git |
| 198 | sha. When the tracked tree is genuinely clean, pass the sha `make release` |
| 199 | stamped β `--version $(git rev-parse --short HEAD)` β rather than |
| 200 | committing noise to get past it. |
| 201 | |
| 202 | Flags go **before** the binary path; Go's flag package stops parsing at |
| 203 | the first non-flag argument, so a path first makes `--account` invisible. |
| 204 | `carlos deploy`, never `carlos ship` on its own, except for mail |
| 205 | submission's ship-then-promote above until `deploy` takes `--mail`. Then poll |
| 206 | `GET /api/version` rather than trusting `X-Carlos-Version`, which is the |
| 207 | router's adopted release and flips before the process cycles. |
| 208 | |
| 209 | ## The design |
| 210 | |
| 211 | `docs/superpowers/specs/2026-09-03-memoria-design.md`. Draft 3, which |
| 212 | answers independent reviews of drafts 1 and 2 β four passes across Fable |
| 213 | and GPT Sol, every one returning REQUEST CHANGES. Β§1.2 records what changed and why β the |
| 214 | central correction being that authorization is asked of whichever app |
| 215 | owns a document, per person, per query, rather than derived from a |
| 216 | membership table memoria keeps. |
| 217 | |
| 218 | `QUESTIONS-FOR-PAUL.md` is what I could not decide alone. |
| 219 | |
| 220 | ## What is not here |
| 221 | |
| 222 | No assistant, no embeddings, no sibling apps, no external connectors, no |
| 223 | snapshot of the index (it rebuilds at boot β milliseconds at this size, |
| 224 | and Β§12 carries the trigger for changing that). The sequencing is Β§11. |
| 225 | |