| 1 | # π€ fichas |
| 2 | |
| 3 | The Oficina suite's card cabinet. One instance per team. |
| 4 | |
| 5 | A *ficha* is an index card; a *fichero* is the cabinet it sits in. |
| 6 | |
| 7 | **Nothing is built.** This repo is a design document and this README. |
| 8 | There is no module, no binary and no schema yet. |
| 9 | |
| 10 | ## What it is meant to be |
| 11 | |
| 12 | Typed records β *cards* β with append-only *entries* attached to them, and |
| 13 | references out to items in Docs, Sheets and Calendar. The first stack is a |
| 14 | CRM: a Customer card, a Call Log entry, and a summary on the card that is |
| 15 | derived from its entries and cites them. |
| 16 | |
| 17 | The ancestor is DabbleDB, not Microsoft Access. What is worth stealing is |
| 18 | schema-by-refinement, entity promotion and views-as-first-class-objects β |
| 19 | not the generic-database-builder positioning, whose best execution still |
| 20 | found no market. The part that could not have been built in 2008 is that |
| 21 | the model replaces HyperTalk: you reshape a card type in a sentence rather |
| 22 | than in a dialog. |
| 23 | |
| 24 | ## Why it is not part of memoria |
| 25 | |
| 26 | memoria is not an app of record and its decision 7 keeps it that way β it |
| 27 | serves nobody to ask, so it cannot own content that needs an owner, a |
| 28 | deletion story and a per-item visibility answer. Fichas owns its content |
| 29 | and answers for it; memoria indexes it, cites it and reaches into it like |
| 30 | any other sibling. |
| 31 | |
| 32 | Fichas would also be **the first app to serve the suite contract's server |
| 33 | half** β `suite/README.md` says that half "arrives with the first app that |
| 34 | serves one, and the fixtures get corrected by the second". memoria is the |
| 35 | waiting consumer. |
| 36 | |
| 37 | ## The design |
| 38 | |
| 39 | `docs/superpowers/specs/2026-09-19-fichas-design.md`. |
| 40 | |
| 41 | Read Β§1 first: half of its decisions table is marked **Proposed** and has |
| 42 | not been ruled on. A proposal read as a ruling is the failure this suite's |
| 43 | specs work hardest to prevent. |
| 44 | |
| 45 | Two things block slice 1, both in Β§10 β the seal-tier list (which card |
| 46 | fields leave the seal, and therefore what can be filtered, sorted and |
| 47 | grouped), and the reach credential ruling. |
| 48 | |
| 49 | ## Building it |
| 50 | |
| 51 | A [rastrillo](https://github.com/rastrilloorg/rastrillo) app. `make ci` is |
| 52 | the gate β vet, gofmt, tests, migration check β one definition for CI and |
| 53 | for you. AGENTS.md carries the working conventions. |
| 54 | |
| 55 | `internal/fichastest/browser_test.go` walks the app in a real Chromium and |
| 56 | is loud on any console error, failed request, or JS value that leaked to the |
| 57 | screen: |
| 58 | |
| 59 | ```sh |
| 60 | go test -tags browser ./... |
| 61 | ``` |
| 62 | |
| 63 | It needs a Chromium on PATH, via `RASTRILLO_CHROME`, or in a Playwright |
| 64 | cache. **A skip is not a pass:** with no browser it fails unless |
| 65 | `RASTRILLO_BROWSER_OPTIONAL=1` makes the skip a deliberate, visible choice. |
| 66 | `make ci` runs the plain suite only. |
| 67 | |
| 68 | ## Deploying, and the DEK |
| 69 | |
| 70 | The app is claimed on CARLOS as `fichas` in account `bds` |
| 71 | (`https://console.carloku.com/a/bds/apps/fichas`). It is **not deployed**, |
| 72 | and it should not be until sign-in lands β see the warning at the end. |
| 73 | |
| 74 | ### 1. Mint the DEK |
| 75 | |
| 76 | The DEK is 32 random bytes, base64. It is not `carlos secrets genkey`, |
| 77 | which mints the *secrets* keypair that seals config β a different thing at |
| 78 | a different layer. |
| 79 | |
| 80 | ```sh |
| 81 | head -c 32 /dev/urandom | base64 |
| 82 | ``` |
| 83 | |
| 84 | **Keep a copy somewhere you will still have it in a year.** Everything in |
| 85 | fichas β every card value, every call logged, every label β is sealed |
| 86 | under this key and under nothing else. Lose it and the database is |
| 87 | unreadable: there is no recovery path, by design, and no fallback key is |
| 88 | generated because a fallback would seal this boot's cards under a key the |
| 89 | next boot cannot derive and lose the data quietly instead of refusing |
| 90 | loudly. memoria keeps its copy at `memoriadrive/DEK-production.txt` |
| 91 | alongside `carlos secrets`; do the same here, or better. |
| 92 | |
| 93 | ### 2. Set it, with the origin |
| 94 | |
| 95 | ```sh |
| 96 | carlos secrets set --app fichas --account bds FICHAS_DEK='<the base64>' |
| 97 | carlos env set --app fichas --account bds FICHAS_ORIGIN='https://fichas.oficina.works' |
| 98 | ``` |
| 99 | |
| 100 | `FICHAS_ORIGIN` is the CSRF yardstick and the base of every link the app |
| 101 | emits, so it must be the host the browser is actually on. Unset, the app |
| 102 | warns and falls back to loopback. |
| 103 | |
| 104 | ### 3. Ship it |
| 105 | |
| 106 | ```sh |
| 107 | make release # refuses a dirty tree; stamps the version from git describe |
| 108 | carlos deploy --app fichas --account bds --channel edge --timeout 5m \ |
| 109 | releases/fichas-linux-arm64 |
| 110 | ``` |
| 111 | |
| 112 | **Mail submission.** Ship every build with `--mail submit`: it declares |
| 113 | that the build sends through CARLOS mail submission (`mail.FromCarlos`, |
| 114 | `internal/fichas/mailer.go`). Until `carlos email submission on --app |
| 115 | fichas` runs, fichas keeps sending over `CARLOS_SMTP_*`; after it the |
| 116 | agent sets `CARLOS_MAIL=submit`, fichas holds no SMTP credential, and |
| 117 | every instance must run a build shipped with the flag. `carlos deploy` |
| 118 | has no `--mail` flag yet (carlos main 9eec0236), so until it does ship |
| 119 | and promote instead: |
| 120 | |
| 121 | ```sh |
| 122 | carlos ship --app fichas --account bds --mail submit releases/fichas-linux-arm64 |
| 123 | carlos promote --app fichas --account bds <version> edge |
| 124 | ``` |
| 125 | |
| 126 | ### Sign-in |
| 127 | |
| 128 | Magic link through rastrillo's `auth`, with the owners list as the |
| 129 | admission gate β the **lone** shape of suite ruling 5. `FICHAS_SHAPE=suite` |
| 130 | is the intended default and **refuses to boot**: it needs the home's |
| 131 | identity bridge and roster pull, and booting into it before those exist |
| 132 | would mean an admission gate that is really the owners list while the |
| 133 | operator believes it is the home's roster. |
| 134 | |
| 135 | ```sh |
| 136 | carlos secrets set --app fichas --account bds \ |
| 137 | FICHAS_DEK='<32 random bytes, base64>' \ |
| 138 | FICHAS_INSTANCE_KEY='<any long random string>' |
| 139 | carlos env set --app fichas --account bds \ |
| 140 | FICHAS_ORIGIN='https://fichas.oficina.works' \ |
| 141 | FICHAS_OWNERS='paul@keymail.dev' |
| 142 | ``` |
| 143 | |
| 144 | `FICHAS_INSTANCE_KEY` seals the pending sign-in blob; `auth.New` refuses an |
| 145 | empty one, because an empty input hashes to a fixed value identical across |
| 146 | every deployment. `FICHAS_OWNERS` has no default: an empty admission gate |
| 147 | on a public hostname admits anyone who can receive mail, so the app refuses |
| 148 | to start without one. |
| 149 | |
| 150 | Mail goes through the platform's sender: |
| 151 | |
| 152 | ```sh |
| 153 | carlos email enable --app fichas --account bds --from noreply@fichas.bds.oncarlos.com |
| 154 | ``` |
| 155 | |
| 156 | **The app refuses to boot without it.** `mail.FromEnv` falls back to |
| 157 | `mail.Logged` on missing SMTP with nothing but a warning, and `mail.Logged` |
| 158 | writes the magic link β a live credential β into platform log storage we |
| 159 | cannot grep and cannot retract. The first deploy of this app ran in exactly |
| 160 | that state and nothing failed; a WARN scrolled past. `LoadConfig` now |
| 161 | refuses, and `FICHAS_ALLOW_LOGGED_MAIL=1` accepts it only on a loopback |
| 162 | origin. |
| 163 | |
| 164 | ## Live |
| 165 | |
| 166 | **https://fichas.oficina.works** β account `bds`, channel `edge`. Sign in |
| 167 | with an address in `FICHAS_OWNERS`. |
| 168 | |
| 169 | `fichas.bds.oncarlos.com` still answers. It is the platform route the |
| 170 | custom hostname sits in front of, not a second deployment, and signing in |
| 171 | there still *starts* β but `FICHAS_ORIGIN` is the base of every sign-in |
| 172 | link and the `client_id` keymail validates against, so the flow lands you |
| 173 | on `oficina.works` and the session is set for that host. Use the canonical |
| 174 | name. memoria made the same move, and its README says why being precise |
| 175 | about it matters. |
| 176 | |
| 177 | The hostname was attached on 2026-09-27 and the certificate took about 45 |
| 178 | minutes to issue, with `carlos domains list` reporting `issuing-cert` and |
| 179 | no guidance throughout. **Do not switch `FICHAS_ORIGIN` until HTTPS |
| 180 | actually answers on the new name**: until then every emailed link points at |
| 181 | a host that fails the TLS handshake. The list's STATE column also lags β |
| 182 | it still said `issuing-cert` after HTTPS was serving β so check with curl, |
| 183 | not with the list. |
| 184 | |