: asapien/signet

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
# 05: Facsimile enrolment

**What to build:** A signer who has never signed before is asked, at their
first zone sign-off, to sign in the browser — draw on a signature pad or
upload a PNG. The image becomes their enrolled facsimile and is reused on
every later document. An admin can enrol a facsimile on someone's behalf. The
API handles the image only in that one request and hands it to the worker
through an inbox; only the worker ever writes to or reads the facsimile store.
Until a signer is enrolled, their zone sign-off is refused with a message that
says so.

See `docs/REBUILD.md` §2 (`facsimiles`), §3 (`sig_inbox`), §5 (`/me`,
`/me/facsimile`, `/facsimiles`, the enrolment check in `/decide`), §6 (`enrol`
job), §8 (enrolment dialog).

**Blocked by:** 04 (parties, zones, decisions).

**Status:** ready-for-agent

- [ ] `facsimiles` table with `enrolled_at`, `enrolled_by`, `width`, `height`; dev seeding enrols `ceo` and `manager` to match the seeded files
- [ ] Inbox directory owned by the worker's user, creatable-but-not-listable by the API user, created by install and by the dev entrypoint
- [ ] Self and admin enrolment endpoints accept one PNG (≤ 1 MB, signature bytes checked), write it to the inbox, upsert the row with `enrolled_at = NULL`, enqueue an `enrol` job
- [ ] Worker validates the PNG with libpng, copies it into the facsimile store (worker-owned, 0600), removes the inbox file, sets `enrolled_at`, `width`, `height`, logs `ENROLLED`; a bad file is discarded and the row stays un-enrolled
- [ ] `GET /me` reports `enrolled` and the image size; `GET /docs/<id>` reports `needs_enrolment`
- [ ] Zone sign-off by an un-enrolled signer → 409 "enrol your signature first"
- [ ] Client: enrolment dialog (canvas pad with pointer events exporting a transparent PNG, or file input), posts, polls `/me` until enrolled, then continues to the placement step
- [ ] e2e: decide before enrolment → 409; enrol with the fixture PNG; poll; decide succeeds; admin enrolment for another user; ends with "all passed"