oficina / memoria Public

Clone
git clone https://amadan.net/oficina/memoria

Plain git — no account needed to clone.

Download

Download this file

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