# fichas

A [rastrillo](https://github.com/rastrilloorg/rastrillo) app. Read the
framework's own SKILL.md (repo root, or in the module cache) before
writing app code — it is the whole app story in ~15KB. The conventions
below are load-bearing; the framework enforces most of them
mechanically.

## Layout

- `internal/<app>/` — the app: `models.go` (plain GORM structs
  + Models), `migrations.go` + `migrations/` (Schema, BootSchema),
  `app.go` (migrate.Apply + chi router), `handlers.go`,
  `render.go` + `templates/`. This is SKILL.md's five-file shape.
- `manifest/` — the declarative path, optional and equal: TOML or .go
  Resource manifests, each generating a full screen set under `gen/`
  (see manifest/README.md for the mounting recipe). A hand-written
  action file at a generated path (carrying `//go:build rastrillo_actions`)
  takes that one screen over, by existence.
- `gen/` — generated when manifests are used; never edit. Regenerate
  with `rastrillo generate`.

## Rules the family holds hard

- Every query touching user-owned rows goes through `scope.Owned` —
  reads AND writes, transactions included. A row that isn't yours 404s,
  never 403s.
- Never bind a request body onto a GORM model: explicit
  `map[string]any` + `.Select` allowlist.
- Migrations apply at boot, once each, and are never re-run or reversed.
- Schema changes: edit models.go, then run `rastrillo migration generate`
  and read the SQL it writes — it may be a full table rebuild, not just
  an `ADD COLUMN`. Never edit a migration that has shipped.
  Renames are hand-written (`rastrillo migration new rename_x`) because
  a rename is indistinguishable from a drop plus an add.
- Money is integer cents. A float never touches a value a person will
  be held to.
- Screens work with JavaScript disabled; destructive actions get their
  own confirm-page URL.
- The gate is `make ci` (vet + gofmt + tests) — the same definition
  CI runs. Run it before every push. `CGO_ENABLED=0` throughout: the
  stack is cgo-free by design.
- **rastrillo is `amadan.net/rastrillo/rastrillo`.** The old path,
  `github.com/carlosframework/rastrillo`, stops at v0.23.0: code importing
  it gets no fix, and its own checks cannot tell (Fichas zoomed iOS on
  every tap that way until it carried a copy of the fix).
  `TestNoPreMoveRastrillo` forbids every import of it. It stays in go.mod
  only as an indirect requirement of estilo. The CLI is pinned as a
  `tool` in go.mod: run it as `go tool rastrillo …`, never a `rastrillo`
  from PATH.
- **Run `go tool rastrillo doctor` on every rastrillo upgrade**, and
  `--fix` to re-copy what drifted. Never `--force`: `rastrillo.js` is
  estilo's shim (the library's still carries the old busy rule, which
  fights busy.js; `TestNoOldBusyRuleIsServed` reads what is served), and
  `calendar.js` is left out on purpose (datetime.js falls back to the
  browser's picker without it). Both are recorded in `vendoredIsMine`.
  Doctor's Templates step still lists every template as pending and
  refuses `card_edit`, `history`, `index` and `partials`: Fichas threads
  its localizer as `.L` (`$L := .L`) rather than through the
  `localizer` prelude, which doctor reads as another meaning of `$L`.
  Leave it unwritten; the render and browser tests are the check. Run
  doctor on the pinned toolchain (`GOTOOLCHAIN=go1.26.11`): a newer Go's
  export data fails its type check.
- **The sign-in door is the suite's smart door** (Home spec
  `2026-11-19-smart-door.md`, step 6): rastrillo's screen, one way in
  (`SigninScreen`, `SigninOneWay`), inside estilo's door (`signin.go`).
  Fichas has no Home, so email is the one way and `/signin/local` and
  `/signin/oficina` are 404s. The door probes `requireSession` before
  treating a session as signed in (`signin_admission.go`), and the
  return memory is rastrillo's with Fichas' guards (`beginReturn`).
  Bump estilo and rastrillo together (estilo's AGENTS.md); `frame.css`
  draws the rail on `--rst-bg`, not Calma's `--rst-rail-bg`.
- **Spacing is the scale's** (Paul, 2026-11-22: no ad-hoc spacing).
  Page, card and form content sits in Fiesta's `rst-stack` (with
  `rst-section` and `rst-actions`), never hand margins; every other
  margin, padding and gap is `var(--rst-sp-N)` or carries a
  `/* spacing-allow: why */`. `make spacing` (in `make ci`) checks the
  stylesheets; `TestTheScreensKeepTheRhythm` (in `make browser`) runs
  Fiesta's rhythm audit over every screen at 1440 and 390px (the
  contract's last two phases excepted: they need a signed release). A
  new screen joins its list. A hidden input between two of a stack's
  blocks hides the first from the stack's rule (the second falls to its
  8px floor): write hidden inputs first, as the edit form does.

## Serving

`rastrillo.Resolve` + `Serve` speak the CARLOS activation contract
(socket/addr/db argv, LISTEN_FDS, $STATE_DIRECTORY, `sidecar run`) —
the golden deployment target, not a requirement: `./app -addr :8080`
serves anywhere. `GET /healthz` and `GET /api/version` are answered
by the framework, outside app middleware.

## UX conventions (seeded from profile: considered)

Accessible by construction, progressively enhanced, and never dependent on JavaScript to be usable.

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.

- [x] Icons — lucide, inline — `internal/<app>/icons`
- [x] Fields — label, hint, help and error in one envelope, wired with aria-describedby — `ui/field, ui/field-select, ui/field-text`
- [x] Destructive actions — their own confirm-page URL, never a modal — `ui/confirm-form`
- [x] State — never colour alone — always a text label too — `ui/status-pill, ui/badge`
- [ ] Dates — relative, with the absolute date in a title attribute
- [ ] Errors — server-rendered beside the field, in plain language
- [x] Empty states — say what the screen is for, not just that it is empty — `ui/empty-state`

`[x]` is enforced by a vendored component: use it, do not hand-roll an
equivalent. `[ ]` is guidance to apply by hand. A convention absent from
this list is one rastrillo has no opinion about.

Edit any line. **This file is the source of truth, not the profile name.**
The profile only seeded this list at scaffold time; nothing re-reads it, so
changing a line here changes what the app does. A convention deleted from
this file is not a convention to reinstate.
