| 1 | # fichas |
| 2 | |
| 3 | A [rastrillo](https://github.com/rastrilloorg/rastrillo) app. Read the |
| 4 | framework's own SKILL.md (repo root, or in the module cache) before |
| 5 | writing app code — it is the whole app story in ~15KB. The conventions |
| 6 | below are load-bearing; the framework enforces most of them |
| 7 | mechanically. |
| 8 | |
| 9 | ## Layout |
| 10 | |
| 11 | - `internal/<app>/` — the app: `models.go` (plain GORM structs |
| 12 | + Models), `migrations.go` + `migrations/` (Schema, BootSchema), |
| 13 | `app.go` (migrate.Apply + chi router), `handlers.go`, |
| 14 | `render.go` + `templates/`. This is SKILL.md's five-file shape. |
| 15 | - `manifest/` — the declarative path, optional and equal: TOML or .go |
| 16 | Resource manifests, each generating a full screen set under `gen/` |
| 17 | (see manifest/README.md for the mounting recipe). A hand-written |
| 18 | action file at a generated path (carrying `//go:build rastrillo_actions`) |
| 19 | takes that one screen over, by existence. |
| 20 | - `gen/` — generated when manifests are used; never edit. Regenerate |
| 21 | with `rastrillo generate`. |
| 22 | |
| 23 | ## Rules the family holds hard |
| 24 | |
| 25 | - Every query touching user-owned rows goes through `scope.Owned` — |
| 26 | reads AND writes, transactions included. A row that isn't yours 404s, |
| 27 | never 403s. |
| 28 | - Never bind a request body onto a GORM model: explicit |
| 29 | `map[string]any` + `.Select` allowlist. |
| 30 | - Migrations apply at boot, once each, and are never re-run or reversed. |
| 31 | - Schema changes: edit models.go, then run `rastrillo migration generate` |
| 32 | and read the SQL it writes — it may be a full table rebuild, not just |
| 33 | an `ADD COLUMN`. Never edit a migration that has shipped. |
| 34 | Renames are hand-written (`rastrillo migration new rename_x`) because |
| 35 | a rename is indistinguishable from a drop plus an add. |
| 36 | - Money is integer cents. A float never touches a value a person will |
| 37 | be held to. |
| 38 | - Screens work with JavaScript disabled; destructive actions get their |
| 39 | own confirm-page URL. |
| 40 | - The gate is `make ci` (vet + gofmt + tests) — the same definition |
| 41 | CI runs. Run it before every push. `CGO_ENABLED=0` throughout: the |
| 42 | stack is cgo-free by design. |
| 43 | - **rastrillo is `amadan.net/rastrillo/rastrillo`.** The old path, |
| 44 | `github.com/carlosframework/rastrillo`, stops at v0.23.0: code importing |
| 45 | it gets no fix, and its own checks cannot tell (Fichas zoomed iOS on |
| 46 | every tap that way until it carried a copy of the fix). |
| 47 | `TestNoPreMoveRastrillo` forbids every import of it. It stays in go.mod |
| 48 | only as an indirect requirement of estilo. The CLI is pinned as a |
| 49 | `tool` in go.mod: run it as `go tool rastrillo …`, never a `rastrillo` |
| 50 | from PATH. |
| 51 | - **Run `go tool rastrillo doctor` on every rastrillo upgrade**, and |
| 52 | `--fix` to re-copy what drifted. Never `--force`: `rastrillo.js` is |
| 53 | estilo's shim (the library's still carries the old busy rule, which |
| 54 | fights busy.js; `TestNoOldBusyRuleIsServed` reads what is served), and |
| 55 | `calendar.js` is left out on purpose (datetime.js falls back to the |
| 56 | browser's picker without it). Both are recorded in `vendoredIsMine`. |
| 57 | Doctor's Templates step still lists every template as pending and |
| 58 | refuses `card_edit`, `history`, `index` and `partials`: Fichas threads |
| 59 | its localizer as `.L` (`$L := .L`) rather than through the |
| 60 | `localizer` prelude, which doctor reads as another meaning of `$L`. |
| 61 | Leave it unwritten; the render and browser tests are the check. Run |
| 62 | doctor on the pinned toolchain (`GOTOOLCHAIN=go1.26.11`): a newer Go's |
| 63 | export data fails its type check. |
| 64 | - **The sign-in door is the suite's smart door** (Home spec |
| 65 | `2026-11-19-smart-door.md`, step 6): rastrillo's screen, one way in |
| 66 | (`SigninScreen`, `SigninOneWay`), inside estilo's door (`signin.go`). |
| 67 | Fichas has no Home, so email is the one way and `/signin/local` and |
| 68 | `/signin/oficina` are 404s. The door probes `requireSession` before |
| 69 | treating a session as signed in (`signin_admission.go`), and the |
| 70 | return memory is rastrillo's with Fichas' guards (`beginReturn`). |
| 71 | Bump estilo and rastrillo together (estilo's AGENTS.md); `frame.css` |
| 72 | draws the rail on `--rst-bg`, not Calma's `--rst-rail-bg`. |
| 73 | - **Spacing is the scale's** (Paul, 2026-11-22: no ad-hoc spacing). |
| 74 | Page, card and form content sits in Fiesta's `rst-stack` (with |
| 75 | `rst-section` and `rst-actions`), never hand margins; every other |
| 76 | margin, padding and gap is `var(--rst-sp-N)` or carries a |
| 77 | `/* spacing-allow: why */`. `make spacing` (in `make ci`) checks the |
| 78 | stylesheets; `TestTheScreensKeepTheRhythm` (in `make browser`) runs |
| 79 | Fiesta's rhythm audit over every screen at 1440 and 390px (the |
| 80 | contract's last two phases excepted: they need a signed release). A |
| 81 | new screen joins its list. A hidden input between two of a stack's |
| 82 | blocks hides the first from the stack's rule (the second falls to its |
| 83 | 8px floor): write hidden inputs first, as the edit form does. |
| 84 | |
| 85 | ## Serving |
| 86 | |
| 87 | `rastrillo.Resolve` + `Serve` speak the CARLOS activation contract |
| 88 | (socket/addr/db argv, LISTEN_FDS, $STATE_DIRECTORY, `sidecar run`) — |
| 89 | the golden deployment target, not a requirement: `./app -addr :8080` |
| 90 | serves anywhere. `GET /healthz` and `GET /api/version` are answered |
| 91 | by the framework, outside app middleware. |
| 92 | |
| 93 | ## UX conventions (seeded from profile: considered) |
| 94 | |
| 95 | Accessible by construction, progressively enhanced, and never dependent on JavaScript to be usable. |
| 96 | |
| 97 | These are rastrillo's own conventions, and the profile is named for what it does rather than after anyone else's work. For wider reading on interface quality, impeccable.style, the WAI-ARIA Authoring Practices and Inclusive Components are all worth your time — none of them is endorsed by, or authoritative for, this framework. |
| 98 | |
| 99 | - [x] Icons — lucide, inline — `internal/<app>/icons` |
| 100 | - [x] Fields — label, hint, help and error in one envelope, wired with aria-describedby — `ui/field, ui/field-select, ui/field-text` |
| 101 | - [x] Destructive actions — their own confirm-page URL, never a modal — `ui/confirm-form` |
| 102 | - [x] State — never colour alone — always a text label too — `ui/status-pill, ui/badge` |
| 103 | - [ ] Dates — relative, with the absolute date in a title attribute |
| 104 | - [ ] Errors — server-rendered beside the field, in plain language |
| 105 | - [x] Empty states — say what the screen is for, not just that it is empty — `ui/empty-state` |
| 106 | |
| 107 | `[x]` is enforced by a vendored component: use it, do not hand-roll an |
| 108 | equivalent. `[ ]` is guidance to apply by hand. A convention absent from |
| 109 | this list is one rastrillo has no opinion about. |
| 110 | |
| 111 | Edit any line. **This file is the source of truth, not the profile name.** |
| 112 | The profile only seeded this list at scaffold time; nothing re-reads it, so |
| 113 | changing a line here changes what the app does. A convention deleted from |
| 114 | this file is not a convention to reinstate. |
| 115 | |