Fold the formatters plan into design.md
Security / Vulnerability check (push) Successful in 43s
Test / Lint and test (push) Successful in 2m6s

Phases 1-4 of docs/plans/formatters.md are built and described in
design.md, and every phase 5 item now has a plan of its own, under
Planned next. So the plan goes, and what still matters moves into
design.md.

A new decision says that existing jobs keep their meaning and their
bytes: /print stays strictly decoded, TestRenderCompat and
TestPaperReceipts pin the bytes, and Renderer.Render is the only path
to printer bytes. The labels and footer settings join "Modules build
ordinary jobs". Deferred gains nested boxes and goldmark, and the
geometry checks in the HTTP handler that stay rejected. The plan's
other invariants were already design.md decisions.

The plans that cited formatters.md now cite design.md, or drop the
reference: job-store.md, printers.md, blocks.md and templates.md.
job-store.md's phase 5 list moves to design.md's Deferred section once
its other phases are done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 11:09:30 -06:00
1 parent 68bce4db59
commit 709e7904e9
6 files changed
+25 -71

No files matched your search

+2 -2
View File
@@ -48,7 +48,7 @@ For stage 1:
- Trade-off: a template over a very large body can fail where it would only have been slow, and the guard is code of our own around Expr's AST.
7. **What a template's output may hold.**
- The result is encoded as JSON and decoded by the strict job decoder (`receipt.DecodeJob`, receipt/job.go:205), so an unknown key or a value of the wrong type is an error, then validated. A `card` result is decoded strictly into the notification's fields. A decoding error becomes a fixed message, `the result is not a job`, with at most a path we work out ourselves: Expr allows computed keys, such as `{(body.x): 1}`, and the decoder's own message, `unknown field "…"`, would quote the payload.
- The checks run on the decoded job, not on Expr's maps, since the decoder matches names in any letter case: a `HEX` key fills `hex`. `raw` is refused wherever it stands, at the top, in a box or, once blocks.md stage 5 has shipped, in a group, and so is a `hex` field on any element, whatever the token. formatters.md's invariant 5 holds: payload text only lands in string fields.
- The checks run on the decoded job, not on Expr's maps, since the decoder matches names in any letter case: a `HEX` key fills `hex`. `raw` is refused wherever it stands, at the top, in a box or, once blocks.md stage 5 has shipped, in a group, and so is a `hex` field on any element, whatever the token. design.md's "Modules build ordinary jobs" holds: payload text only lands in string fields.
- One walker visits every string field of the decoded job by reflection, with a list of the fields it leaves alone (`url`, `data`, `base64`, `hex`); a test fails when `Element` gains a string field the walker does not place. Each text field is at most 4,096 bytes, ntfy's message limit, and the encoded result at most 256 KiB. Over either, the run fails; `cut` keeps a string inside the limit. `data` keeps validation's limits, and `base64` the 256 KiB. A `card` result is cut to the card's caps instead, as an ntfy card is.
- Every `image` a template builds is `optional`, as a card's are (modules/card.go:233). Its `url` may come from the payload. It is fetched by the worker through `safehttp`, like every image, so it cannot reach the host's own network unless `images.*` allows it, and a broken one prints `[image unavailable]` rather than failing the job.
- Each built job is laid out by the text preview, which fetches nothing, before it is queued, so a job over `format.max_lines` fails as a template's run fails, not later in the worker.
@@ -105,7 +105,7 @@ For stage 4:
19. **The route, and its rate limit.** The route is `POST /hooks/{name}`, outside `/api/v1`, since a webhook sender sends no bearer token. It is an entry in the route table like any other, with a new flag beside `Auth` and `NoStore` (server/routes.go:34-38; `Hook`, name assumed): no bearer token and `Cache-Control: no-store`. It has its own case in `TestRoutesConform`. Hooks are `[[webhooks.hooks]]`, a list of tables read from the file only, each with a `name` by the subscriptions' rule, `^[a-z0-9][a-z0-9_-]{0,31}$`, unique.
- No per-client limit stands in front of a delivery whose signature passes. GitHub and gitlab.com send every customer's hooks from shared addresses, and `/api/v1`'s limiter counts a request before its token is read (server/server.go:177-187). With it, anyone could point their own hook at `/hooks/forge` and spend the owner's budget with refused deliveries; GitHub never retries the real ones it then refuses.
- Refused requests (`401`, `404` and `415`) count per client in a limiter of their own, at `webserver.rate_limit` per `rate_window` (60 a minute by default, config.go:363-364). A client over it gets `429` before any hashing, which bounds the HMAC work and the log lines.
- An unknown name answers `404` with a new code, `hook_not_found`, before the body is parsed or hashed. It cannot come before the body is read, as formatters.md's item asked: fasthttp reads the whole body, up to `webserver.body_limit`, before any handler runs (Investigation findings, THE REPOSITORY).
- An unknown name answers `404` with a new code, `hook_not_found`, before the body is parsed or hashed. It cannot come before the body is read: fasthttp reads the whole body, up to `webserver.body_limit`, before any handler runs (Investigation findings, THE REPOSITORY).
- Caddy, as install.sh sets it up, already proxies every path and drops query strings from its log (install.sh:381-421). An operator's own proxy in front of the Docker image must pass `/hooks/` too.
- Trade-off: `404` and `401` tell a stranger which names exist. A name is not a secret; the hook's secret is. Valid deliveries have no rate limit (decision 28).
20. **Authentication.** Every hook has a secret, `secret` or `secret_file`, exactly one, read as the subscriptions' credential files are; a hook without one is a config error. Its `preset` says how the sender proves it holds the secret (Architecture, WEBHOOKS, gives the table): `github`, `gitea` and `forgejo` sign the body with HMAC-SHA256 in hex; `gitlab` and `standard` sign the message ID, a timestamp and the body, in base64, as the Standard Webhooks specification has it; `header` compares a header with the secret.