Plan the printer choice in the JSON body
The printers plan named a request's printer with ?printer= on /print, /preview and the module routes. The owner's rule puts every API input in the JSON body, so the plan now takes printer in the body: beside elements and copies on /print and /preview, and in the module routes' body beside payload and copies, where it already sits. Decision 7 says so. The field belongs to the request, not the receipt, so receipt.Job gains none. An empty printer is the same as none, since JSON makes the two easy to confuse, and "default" names the default printer itself. Its Breaking item goes: every route already refuses a query string. route.by names a request's choice "request" in place of "query". Stage 1b, its tests, the compatibility notes and stage 2a follow. The templates plan's modules take the same body, and design.md's Planned next says printer goes in the body. The rule's list of plans that break it loses the printers plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6bfaee0bc8
commit
c60d7531b2
3 files changed
+52
-50
No files matched your search
+4
-7
@@ -510,11 +510,8 @@ client ─HTTPS─▶ Caddy ─▶ server ── validate ──▶ printqueue (
|
|||||||
`invalid_query`, after the token and its scope under `/api/v1`, so a
|
`invalid_query`, after the token and its scope under `/api/v1`, so a
|
||||||
caller that still sends one learns so instead of having it ignored. The
|
caller that still sends one learns so instead of having it ignored. The
|
||||||
module routes' body holds the module's payload, `copies` and `printer`.
|
module routes' body holds the module's payload, `copies` and `printer`.
|
||||||
Some of the plans break the rule today, and a later change makes them
|
One plan breaks the rule today, and a later change makes it follow:
|
||||||
follow:
|
the filters and paging that docs/plans/job-store.md's phase 2 puts in
|
||||||
- the `?printer=` that docs/plans/printers.md puts on `/print`,
|
|
||||||
`/preview` and the module routes;
|
|
||||||
- the filters and paging that docs/plans/job-store.md's phase 2 puts in
|
|
||||||
the query of `GET /api/v1/jobs` (its decision 16).
|
the query of `GET /api/v1/jobs` (its decision 16).
|
||||||
- **The OpenAPI document is generated (owner, 2026-11-30).** One route
|
- **The OpenAPI document is generated (owner, 2026-11-30).** One route
|
||||||
table drives both the server's routes and `docs/swagger.json`, so the
|
table drives both the server's routes and `docs/swagger.json`, so the
|
||||||
@@ -749,8 +746,8 @@ before anything is built. They come in this order.
|
|||||||
- One queue with a lane per printer: its own worker, renderer and
|
- One queue with a lane per printer: its own worker, renderer and
|
||||||
connection, and `queue.size` per lane. History, references and the
|
connection, and `queue.size` per lane. History, references and the
|
||||||
store stay shared.
|
store stay shared.
|
||||||
- `?printer=` on `/print`, `/preview` and the module routes is a direct
|
- A `printer` in the body of `/print`, `/preview` and the module
|
||||||
unicast; any other query parameter is refused (**Breaking**). Every
|
routes is a direct unicast; an empty one is the same as none. Every
|
||||||
job status gains `deliveries`. `/healthz` lists every printer, and
|
job status gains `deliveries`. `/healthz` lists every printer, and
|
||||||
its code follows the default printer alone.
|
its code follows the default printer alone.
|
||||||
- Routing is done by rules written in Expr
|
- Routing is done by rules written in Expr
|
||||||
|
|||||||
+45
-40
@@ -1,6 +1,6 @@
|
|||||||
# Plan: several printers, routed by Expr rules
|
# Plan: several printers, routed by Expr rules
|
||||||
|
|
||||||
Status: **planned; nothing is built.** The owner accepted every proposed default on 2026-12-01 (Decisions), and design.md's Planned next item 2 records them. This plan builds on docs/plans/job-store.md and does not redesign its store. Stages 1a to 3 need that plan's stage 1c: jobs with deliveries, the waiting list, `beforeWrite` and the memory store. None needs its durable store (job-store stage 1d). Where that has shipped, decision 5's restore rule applies to it, and stage 2a adds a schema step (decision 18). Each stage runs in its own session, briefed from its section:
|
Status: **planned; nothing is built.** The owner accepted every proposed default on 2026-12-01 (Decisions), and design.md's Planned next item 2 records them. By the owner's rule of 2026-12-01 that API inputs go in the JSON body (design.md, "Inputs go in the JSON body"), a request names its printer in its body, never in a query parameter (decision 7). This plan builds on docs/plans/job-store.md and does not redesign its store. Stages 1a to 3 need that plan's stage 1c: jobs with deliveries, the waiting list, `beforeWrite` and the memory store. None needs its durable store (job-store stage 1d). Where that has shipped, decision 5's restore rule applies to it, and stage 2a adds a schema step (decision 18). Each stage runs in its own session, briefed from its section:
|
||||||
- stage 1a follows decisions 1-6, and stage 1b decisions 7-9;
|
- stage 1a follows decisions 1-6, and stage 1b decisions 7-9;
|
||||||
- stage 2a follows decisions 10-19, stage 2b decision 20, and stage 2c decision 21;
|
- stage 2a follows decisions 10-19, stage 2b decision 20, and stage 2c decision 21;
|
||||||
- stage 3 follows decisions 22-26, after decision 23's paper check;
|
- stage 3 follows decisions 22-26, after decision 23's paper check;
|
||||||
@@ -35,7 +35,7 @@ The stages run in the order listed, except that stages 2b and 2c each need only
|
|||||||
model (its DELIVERIES AND SEVERAL PRINTERS section, decision 12 on a
|
model (its DELIVERIES AND SEVERAL PRINTERS section, decision 12 on a
|
||||||
job's status from its deliveries, and decision 23). This plan builds on
|
job's status from its deliveries, and decision 23). This plan builds on
|
||||||
it and does not redesign the store.
|
it and does not redesign the store.
|
||||||
- **An explicit `?printer=` on a request is a direct unicast.**
|
- **An explicit `printer` in a request's body is a direct unicast.**
|
||||||
- **A job that matches no rule goes to the default printer,** so today's
|
- **A job that matches no rule goes to the default printer,** so today's
|
||||||
single-printer config keeps working.
|
single-printer config keeps working.
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ The owner accepted the details below on 2026-12-01. They are numbered, so the re
|
|||||||
For stage 1a:
|
For stage 1a:
|
||||||
|
|
||||||
1. **Today's `[printer]` table stays,** and it is the printer named `default`. `[printers.<name>]` tables add the others. The name `default` is reserved, so `[printers.default]` is refused with a message that points to `[printer]`.
|
1. **Today's `[printer]` table stays,** and it is the printer named `default`. `[printers.<name>]` tables add the others. The name `default` is reserved, so `[printers.default]` is refused with a message that points to `[printer]`.
|
||||||
- Nothing needs migrating. install.sh writes `[printer] address` and keeps an existing config on a re-run. `UBERBRINGER_PRINTER_*` keep their meaning in Docker. `?printer=default` keeps working on the module routes. job-store.md's planned delivery rows name `default`. The CHANGELOG lists it under Added.
|
- Nothing needs migrating. install.sh writes `[printer] address` and keeps an existing config on a re-run. `UBERBRINGER_PRINTER_*` keep their meaning in Docker. `"printer": "default"` keeps working in the module routes' body. job-store.md's planned delivery rows name `default`. The CHANGELOG lists it under Added.
|
||||||
- docs/plans/remote-printers.md decision 16 builds on this: `[printer]` may be remote, through `agent` and `UBERBRINGER_PRINTER_AGENT`.
|
- docs/plans/remote-printers.md decision 16 builds on this: `[printer]` may be remote, through `agent` and `UBERBRINGER_PRINTER_AGENT`.
|
||||||
- Trade-off: two table shapes, and the default printer cannot be renamed.
|
- Trade-off: two table shapes, and the default printer cannot be renamed.
|
||||||
2. **Printer names, and no variables for named printers.** A name follows the subscriptions' rule, `^[a-z0-9][a-z0-9_-]{0,31}$`. It is checked on the raw TOML key, because Viper lowercases map keys: `[printers.Office]` would otherwise load silently as `office`. `[printers.*]` comes from the file only, as `[[ntfy.subscriptions]]` does. The default printer keeps its `UBERBRINGER_PRINTER_*` variables. No key reads a `UBERBRINGER_PRINTERS_*` variable, so at start one WARN line names any that is set, never its value; from stage 2a it names `UBERBRINGER_ROUTING_*` variables too. They are ours, and a Docker user could otherwise set one and never learn it does nothing.
|
2. **Printer names, and no variables for named printers.** A name follows the subscriptions' rule, `^[a-z0-9][a-z0-9_-]{0,31}$`. It is checked on the raw TOML key, because Viper lowercases map keys: `[printers.Office]` would otherwise load silently as `office`. `[printers.*]` comes from the file only, as `[[ntfy.subscriptions]]` does. The default printer keeps its `UBERBRINGER_PRINTER_*` variables. No key reads a `UBERBRINGER_PRINTERS_*` variable, so at start one WARN line names any that is set, never its value; from stage 2a it names `UBERBRINGER_ROUTING_*` variables too. They are ours, and a Docker user could otherwise set one and never learn it does nothing.
|
||||||
@@ -55,24 +55,26 @@ For stage 1a:
|
|||||||
- Two printers may not share an address and port, `[printer]` included; hosts are compared without regard to case. Each table gets its own client and connection slot, and a printer prints from one connection at a time. A second connection's data waits until the first closes, its writes stall until `write_timeout`, and its status reads time out (`503` if one of them is the default printer). Two names that resolve to one address cannot be caught. The rule covers local printers only, since main cannot see where a remote one is; the agent refuses two of its own printers at one address and port (remote-printers decision 16).
|
- Two printers may not share an address and port, `[printer]` included; hosts are compared without regard to case. Each table gets its own client and connection slot, and a printer prints from one connection at a time. A second connection's data waits until the first closes, its writes stall until `write_timeout`, and its status reads time out (`503` if one of them is the default printer). Two names that resolve to one address cannot be caught. The rule covers local printers only, since main cannot see where a remote one is; the agent refuses two of its own printers at one address and port (remote-printers decision 16).
|
||||||
- Trade-off: `format.max_lines` is global, so a multicast job that wraps into more lines on a narrower printer can fail there and print on the others. One image fetcher serves every printer.
|
- Trade-off: `format.max_lines` is global, so a multicast job that wraps into more lines on a narrower printer can fail there and print on the others. One image fetcher serves every printer.
|
||||||
4. **One queue with a lane per printer.** One `printqueue.Queue`. Each printer is a lane with its own waiting list, worker, renderer, sender, retries and retry delay. The submit lock, the status map, the history, the references of ntfy jobs and the store stay shared, so a job with several deliveries is one `Store.Add` commit, as job-store.md plans. `queue.size` bounds each lane, so a dead printer's backlog cannot refuse jobs for the others (decision 19 for multicast and broadcast). Order is first in, first out per printer. A Pool of independent queues would suit unicast only: a multicast job would have a status in each queue, capacity could not be checked across them at once, history would be evicted per queue, and anycast could not move a job between channels.
|
4. **One queue with a lane per printer.** One `printqueue.Queue`. Each printer is a lane with its own waiting list, worker, renderer, sender, retries and retry delay. The submit lock, the status map, the history, the references of ntfy jobs and the store stay shared, so a job with several deliveries is one `Store.Add` commit, as job-store.md plans. `queue.size` bounds each lane, so a dead printer's backlog cannot refuse jobs for the others (decision 19 for multicast and broadcast). Order is first in, first out per printer. A Pool of independent queues would suit unicast only: a multicast job would have a status in each queue, capacity could not be checked across them at once, history would be evicted per queue, and anycast could not move a job between channels.
|
||||||
- Trade-off: no global order; a broadcast prints at different times on each printer. A host with three printers can hold three times `queue.size` jobs. With a durable store, unfinished content can reach N × `queue.size` × 4 MiB: about 1.2 GiB for three printers at the defaults, where job-store decision 9 counts about 400 MiB for one. A unicast rule or a `?printer=` to a dead printer still refuses jobs once its lane is full, and an ntfy subscription whose jobs go there stops reading, as it does today when the one printer is dead.
|
- Trade-off: no global order; a broadcast prints at different times on each printer. A host with three printers can hold three times `queue.size` jobs. With a durable store, unfinished content can reach N × `queue.size` × 4 MiB: about 1.2 GiB for three printers at the defaults, where job-store decision 9 counts about 400 MiB for one. A unicast rule or a request's `printer` naming a dead printer still refuses jobs once its lane is full, and an ntfy subscription whose jobs go there stops reading, as it does today when the one printer is dead.
|
||||||
5. **A printer removed from the config while deliveries wait for it** (job-store.md, DELIVERIES AND SEVERAL PRINTERS). It matters once the store is durable. At restore, a queued delivery whose printer is no longer configured fails, in a synced commit, with an error naming the printer, and one WARN line by `job_id` and `printer`. Finished deliveries, `uncertain` ones included, stay as history. An anycast delivery drops the missing printers from its list and fails only when none is left (stage 3). Refusing to start would stop every printer over one, and the default printer is a room nobody chose.
|
5. **A printer removed from the config while deliveries wait for it** (job-store.md, DELIVERIES AND SEVERAL PRINTERS). It matters once the store is durable. At restore, a queued delivery whose printer is no longer configured fails, in a synced commit, with an error naming the printer, and one WARN line by `job_id` and `printer`. Finished deliveries, `uncertain` ones included, stay as history. An anycast delivery drops the missing printers from its list and fails only when none is left (stage 3). Refusing to start would stop every printer over one, and the default printer is a room nobody chose.
|
||||||
- Trade-off: renaming a printer fails what waits for it.
|
- Trade-off: renaming a printer fails what waits for it.
|
||||||
6. **The seam for remote printers.** docs/plans/remote-printers.md decision 16 makes a printer remote with a key of its own, `agent`: no `kind` key and no address scheme. Each printer is built by one constructor in internal/app, which returns what `printqueue.Sender` and `server.Printer` need; today that is a `*printer.Client`. The `agent` key is purely additive, since unknown keys are refused today. Architecture, THE SEAM FOR REMOTE PRINTERS, writes down the contract a remote printer keeps, printqueue's send contract (stage 3) included.
|
6. **The seam for remote printers.** docs/plans/remote-printers.md decision 16 makes a printer remote with a key of its own, `agent`: no `kind` key and no address scheme. Each printer is built by one constructor in internal/app, which returns what `printqueue.Sender` and `server.Printer` need; today that is a `*printer.Client`. The `agent` key is purely additive, since unknown keys are refused today. Architecture, THE SEAM FOR REMOTE PRINTERS, writes down the contract a remote printer keeps, printqueue's send contract (stage 3) included.
|
||||||
|
|
||||||
For stage 1b:
|
For stage 1b:
|
||||||
|
|
||||||
7. **`?printer=` on `/print` and `/preview`.** `POST /api/v1/print` and `POST /api/v1/preview` read `printer`, as the module routes already do. An empty value means the default printer, as on the module routes today. A name matches only as configured, so `Office` is not `office`. A name that is not a configured printer, a group's name included, answers `400` `unknown_printer`. A parameter given twice, or any other parameter, answers `400` `invalid_query`. A preview renders for the named printer, or for the default printer without one.
|
7. **`printer` in the body of every print and preview route.** The body of `POST /api/v1/print` and `POST /api/v1/preview` takes `printer` beside `elements` and `copies`, as the module routes' body already does beside `payload` and `copies`. A name matches only as configured, so `Office` is not `office`. A name that is not a configured printer, a group's name included, answers `400` `unknown_printer`. A preview renders for the named printer, or for the default printer without one.
|
||||||
- Refusing other parameters is **Breaking**: a client that sends `/print?x=1` gets `400`. It matches the module routes, where a typo must not be ignored; here a mistyped `printr=office` would print in the wrong room.
|
- An empty `printer` is the same as none: the job goes where the rules send it, which is the default printer until stage 2a and whenever no rule matches. `"printer": "default"` names the default printer itself. In JSON an empty string and a missing field are easily confused, so the two mean the same.
|
||||||
|
- `printer` belongs to the request, not to the receipt. The server decodes it strictly with the job's fields and passes it in `printqueue.Meta.Printer` (stage 1a); `receipt.Job` gains no field, so the renderer never sees it. A mistyped `printr` is refused as an unknown field, as any typo in the body is, so it cannot print in the wrong room.
|
||||||
|
- No route reads the name from a query string: every route already answers one with `400` `invalid_query`.
|
||||||
- Any token that may print may name any printer. A token claim that limits printers can come later.
|
- Any token that may print may name any printer. A token claim that limits printers can come later.
|
||||||
- Trade-off: the break above. A preview without `printer` lays the job out for the default printer, even when the rules would send it elsewhere; from stage 2c the JSON preview's `route` says where it would go.
|
- Trade-off: a preview without `printer` lays the job out for the default printer, even when the rules would send it elsewhere; from stage 2c the JSON preview's `route` says where it would go.
|
||||||
8. **A job's status with several deliveries.** From stage 1b, every status gains `deliveries`, whatever the number of printers configured, so a client's parsing does not depend on the config. Each entry gives a delivery's `printer`, `status`, `attempts`, `started_at`, `sent_at`, `finished_at` and `error`. The job's `status` follows job-store decision 12. Beside the array, the job's own fields read:
|
8. **A job's status with several deliveries.** From stage 1b, every status gains `deliveries`, whatever the number of printers configured, so a client's parsing does not depend on the config. Each entry gives a delivery's `printer`, `status`, `attempts`, `started_at`, `sent_at`, `finished_at` and `error`. The job's `status` follows job-store decision 12. Beside the array, the job's own fields read:
|
||||||
- `attempts`: the sum;
|
- `attempts`: the sum;
|
||||||
- `started_at` and `sent_at`: the earliest;
|
- `started_at` and `sent_at`: the earliest;
|
||||||
- `finished_at`: the latest, once every delivery has finished;
|
- `finished_at`: the latest, once every delivery has finished;
|
||||||
- `error`: that of the first failed or `uncertain` delivery, prefixed with its printer's name when the job has more than one.
|
- `error`: that of the first failed or `uncertain` delivery, prefixed with its printer's name when the job has more than one.
|
||||||
- Trade-off: one more field on every status.
|
- Trade-off: one more field on every status.
|
||||||
9. **`/healthz` per printer.** `status` and the HTTP code follow the default printer alone, as today, and `printer` stays the default printer's health. A new `printers` array lists every printer, the default first, then by name. Each entry has `name`, `default`, `model` as configured, the fields `printer` has, and its own `pending`. `queue.pending` is the total. No address appears, since the route is public. There is no `?printer=` on `/healthz`.
|
9. **`/healthz` per printer.** `status` and the HTTP code follow the default printer alone, as today, and `printer` stays the default printer's health. A new `printers` array lists every printer, the default first, then by name. Each entry has `name`, `default`, `model` as configured, the fields `printer` has, and its own `pending`. `queue.pending` is the total. No address appears, since the route is public. `/healthz` takes no printer: it is a `GET`, which takes no inputs beyond its path, and it lists every printer.
|
||||||
- The default printer is read once, and that one settled read fills both `printer` and the first entry. Two reads would queue on its one slot. With a second read 750 ms later for each, they could pass the 3-s bound, turning a `200` into a `503` `timeout`.
|
- The default printer is read once, and that one settled read fills both `printer` and the first entry. Two reads would queue on its one slot. With a second read 750 ms later for each, they could pass the 3-s bound, turning a `200` into a `503` `timeout`.
|
||||||
- The others are read in parallel, each within the same bound, so a slow one cannot make the others time out.
|
- The others are read in parallel, each within the same bound, so a slow one cannot make the others time out.
|
||||||
- A dial that times out reads as `timeout`, as today: Go's dial time-out error matches `context.DeadlineExceeded`. So a host that does not answer can show `timeout` rather than `unreachable`, since the 5-s dial outlasts the 3-s bound.
|
- A dial that times out reads as `timeout`, as today: Go's dial time-out error matches `context.DeadlineExceeded`. So a host that does not answer can show `timeout` rather than `unreachable`, since the 5-s dial outlasts the 3-s bound.
|
||||||
@@ -116,7 +118,7 @@ For stage 2a:
|
|||||||
17. **Compile options and the clock.** docs/plans/templates.md decision 6 shares these options through `rules.Options`: `expr.DisableBuiltin("now")`, `expr.DisableBuiltin("$env")`, Expr's default node limit (10,000) and memory budget (1,000,000 per run), and `expr.Timezone` with `format.timezone` once validation has loaded the zone, since it panics on an unknown name. A routing rule adds `expr.Env(routing.Env{})` and `expr.AsBool()`, as the owner's decision has it. The clock is injected: `now` is the job's acceptance time in `format.timezone`, so a dry-run with `--at` and the tests reproduce any decision.
|
17. **Compile options and the clock.** docs/plans/templates.md decision 6 shares these options through `rules.Options`: `expr.DisableBuiltin("now")`, `expr.DisableBuiltin("$env")`, Expr's default node limit (10,000) and memory budget (1,000,000 per run), and `expr.Timezone` with `format.timezone` once validation has loaded the zone, since it panics on an unknown name. A routing rule adds `expr.Env(routing.Env{})` and `expr.AsBool()`, as the owner's decision has it. The clock is injected: `now` is the job's acceptance time in `format.timezone`, so a dry-run with `--at` and the tests reproduce any decision.
|
||||||
- The shared options carry that decision's iteration guard, so routing rules have it too: a budget of 1,000,000 iterations per run, charged by a `Patch` visitor around every predicate builtin and the right side of `in`. Expr itself has no step limit: nested predicates over large literal ranges, such as `any(1..999, any(1..999, # < 0))`, took about 30 ms, and one more level would take seconds here and minutes on a Pi, on every job. With the guard, such a rule fails at run time, as decision 15 has it, instead.
|
- The shared options carry that decision's iteration guard, so routing rules have it too: a budget of 1,000,000 iterations per run, charged by a `Patch` visitor around every predicate builtin and the right side of `in`. Expr itself has no step limit: nested predicates over large literal ranges, such as `any(1..999, any(1..999, # < 0))`, took about 30 ms, and one more level would take seconds here and minutes on a Pi, on every job. With the guard, such a rule fails at run time, as decision 15 has it, instead.
|
||||||
- Trade-off: a guard of our own around Expr's AST charges every predicate, though only the owner writes routing rules and they see no print content.
|
- Trade-off: a guard of our own around Expr's AST charges every predicate, though only the owner writes routing rules and they see no print content.
|
||||||
18. **Storing the decision.** A route is decided once, at `Submit`, and stored; a restore never runs the rules again. The job keeps its `route`: `by` (`rule`; `query` for an explicit `?printer=`; or `default`), the rule's name and the mode, and job status shows it. An anycast delivery keeps its ordered list and the printers that got a `sending` mark (stage 3).
|
18. **Storing the decision.** A route is decided once, at `Submit`, and stored; a restore never runs the rules again. The job keeps its `route`: `by` (`rule`; `request` for a printer the request names; or `default`), the rule's name and the mode, and job status shows it. An anycast delivery keeps its ordered list and the printers that got a `sending` mark (stage 3).
|
||||||
- A restored anycast delivery's list is therefore not given again by the rules and the config: job-store's `jobs` row keeps no priority, tags or client, and the rules may have changed since. Evaluating stored facts again at restore would cost as many bytes, give another answer after a config change, and put topics on disk.
|
- A restored anycast delivery's list is therefore not given again by the rules and the config: job-store's `jobs` row keeps no priority, tags or client, and the rules may have changed since. Evaluating stored facts again at restore would cost as many bytes, give another answer after a config change, and put topics on disk.
|
||||||
- With SQLite, `jobs` gains `route_by`, `route_rule` and `route_mode`, and `deliveries` gains `candidates` and `sent_to`, names joined by commas, which a name cannot hold. If job-store stage 1d has not shipped when stage 2a starts, these columns join its first schema; otherwise stage 2a adds one schema step to `user_version` 2.
|
- With SQLite, `jobs` gains `route_by`, `route_rule` and `route_mode`, and `deliveries` gains `candidates` and `sent_to`, names joined by commas, which a name cannot hold. If job-store stage 1d has not shipped when stage 2a starts, these columns join its first schema; otherwise stage 2a adds one schema step to `user_version` 2.
|
||||||
- Trade-off: five columns; a job keeps the route it was given after the rules change.
|
- Trade-off: five columns; a job keeps the route it was given after the rules change.
|
||||||
@@ -269,9 +271,9 @@ THE CONFIG LOADER
|
|||||||
THE REPOSITORY TODAY
|
THE REPOSITORY TODAY
|
||||||
- serve.go builds one renderer, one `printer.Client`, one queue with one worker, and one `Printer` for `/healthz`. Its `listening` line gives the printer's address. `printqueue.Sender` and `server.Printer` are already the interfaces a printer needs.
|
- serve.go builds one renderer, one `printer.Client`, one queue with one worker, and one `Printer` for `/healthz`. Its `listening` line gives the printer's address. `printqueue.Sender` and `server.Printer` are already the interfaces a printer needs.
|
||||||
- `escpos.LookupProfile` folds `tm-t88iv` to `tm-t88vii` into `tm-t88`, and `tm-m50ii` into `tm-m50`, and TestLookupProfile pins it. Nothing after the lookup can tell a TM-T88VII from a TM-T88IV.
|
- `escpos.LookupProfile` folds `tm-t88iv` to `tm-t88vii` into `tm-t88`, and `tm-m50ii` into `tm-m50`, and TestLookupProfile pins it. Nothing after the lookup can tell a TM-T88VII from a TM-T88IV.
|
||||||
- `printqueue.Meta` holds the source and the reference only, and its doc comment says it is kept with the job's status and logged with it. The ntfy priority, topic and tags are in hand in ntfy.go but never reach `Submit`. `Module.Build` returns only a `receipt.Job`, so the facts of `/print/notify` and `/print/ntfy` stay inside the module. It is called at server/handlers_modules.go:90 and internal/app/uberbringer/preview.go:137 (`preview --module`); its fakes are `fakeModule` (server/handlers_modules_test.go) and `stubModule` (modules/registry_test.go). auth.go keeps only the token's scope, not its subject.
|
- `printqueue.Meta` holds the source and the reference only, and its doc comment says it is kept with the job's status and logged with it. The ntfy priority, topic and tags are in hand in ntfy.go but never reach `Submit`. `Module.Build` returns only a `receipt.Job`, so the facts of `/print/notify` and `/print/ntfy` stay inside the module. It is called at server/handlers_modules.go:105 and internal/app/uberbringer/preview.go:138 (`preview --module`); its fakes are `fakeModule` (server/handlers_modules_test.go) and `stubModule` (modules/registry_test.go). auth.go keeps only the token's scope, not its subject.
|
||||||
- An ntfy subscription offers a message again after any `Submit` error, `queue_full` included, and stops reading meanwhile (design.md, TCP backpressure).
|
- An ntfy subscription offers a message again after any `Submit` error, `queue_full` included, and stops reading meanwhile (design.md, TCP backpressure).
|
||||||
- `/print` and `/preview` read no query. Only the module routes parse one, and accept `printer=default` alone (`unknown_printer` otherwise); an empty `printer` means the default.
|
- No route takes a query string: each answers one with `invalid_query`. The body of `/print` and `/preview` holds the job's fields alone, decoded strictly into `receipt.Job`. The module routes' body holds `payload`, `copies` and `printer` (`decodeModuleRequest`), and accepts `"printer": "default"` alone (`unknown_printer` otherwise); an empty `printer` means the default.
|
||||||
- The worker retries every `Send` error alike, and `Send` discards the count `Write` returns, so a dial failure and a write cut short look the same.
|
- The worker retries every `Send` error alike, and `Send` discards the count `Write` returns, so a dial failure and a write cut short look the same.
|
||||||
- `Client.Status` takes the connection slot through `connect`, and `settledPrinterStatus` in server/handlers.go calls it twice. Run inside a send that holds the slot, it would wait on that slot until the job's bound ends.
|
- `Client.Status` takes the connection slot through `connect`, and `settledPrinterStatus` in server/handlers.go calls it twice. Run inside a send that holds the slot, it would wait on that slot until the job's bound ends.
|
||||||
- `/healthz` reads one printer, reading a not-ready answer again after 750 ms, within 3 s. A dial that times out returns Go's time-out error, which `errors.Is` matches to `context.DeadlineExceeded`, so `/healthz` maps it to `timeout`.
|
- `/healthz` reads one printer, reading a not-ready answer again after 750 ms, within 3 s. A dial that times out returns Go's time-out error, which `errors.Is` matches to `context.DeadlineExceeded`, so `/healthz` maps it to `timeout`.
|
||||||
@@ -376,17 +378,16 @@ SOURCES
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
WHAT SHIPS WHEN
|
WHAT SHIPS WHEN
|
||||||
1. Stage 1a: named printers beside the default, a lane each, `preview --printer`, and `config get` checking every printer. Every job still prints on the default printer. Stage 1b: `?printer=` on every print and preview route, `/healthz` per printer, and deliveries in job status.
|
1. Stage 1a: named printers beside the default, a lane each, `preview --printer`, and `config get` checking every printer. Every job still prints on the default printer. Stage 1b: `printer` in the body of every print and preview route, `/healthz` per printer, and deliveries in job status.
|
||||||
2. Stage 2a: Expr rules in unicast, multicast and broadcast, on a job's source, module, subscription, shape and clock; groups; the stored decision. Stage 2b: SIGHUP reloads the rules. Stage 2c: a notification's topic, priority and tags and the token's subject in rules; `uberbringer route` and the route in the JSON preview.
|
2. Stage 2a: Expr rules in unicast, multicast and broadcast, on a job's source, module, subscription, shape and clock; groups; the stored decision. Stage 2b: SIGHUP reloads the rules. Stage 2c: a notification's topic, priority and tags and the token's subject in rules; `uberbringer route` and the route in the JSON preview.
|
||||||
3. Stage 3: anycast, with failover down an ordered list.
|
3. Stage 3: anycast, with failover down an ordered list.
|
||||||
4. Stages 4a and 4b, as each printer arrives: the exact model in the profile, the TM-T88VII's near-end, and each model checked on paper.
|
4. Stages 4a and 4b, as each printer arrives: the exact model in the profile, the TM-T88VII's near-end, and each model checked on paper.
|
||||||
5. Next, in docs/plans/remote-printers.md: printers behind an agent, through the seam this plan leaves and does not build.
|
5. Next, in docs/plans/remote-printers.md: printers behind an agent, through the seam this plan leaves and does not build.
|
||||||
|
|
||||||
COMPATIBILITY
|
COMPATIBILITY
|
||||||
- A config with `[printer]` alone loads and prints as today: one lane, no rules, every job on `default`. install.sh, the Dockerfile and `UBERBRINGER_PRINTER_*` do not change. Two changes reach every config:
|
- A config with `[printer]` alone loads and prints as today: one lane, no rules, every job on `default`. install.sh, the Dockerfile and `UBERBRINGER_PRINTER_*` do not change. One change reaches every config: job status gains `deliveries` (decision 8), and from stage 2a `route` (decision 18). Its other fields keep their meaning.
|
||||||
- **Breaking:** `/print` and `/preview` refuse query parameters other than `printer` (decision 7).
|
- `"printer": "default"` keeps working in the module routes' body. An empty `printer` is the same as none, so it prints on the default printer unless a rule sends the job elsewhere (decision 7).
|
||||||
- Job status gains `deliveries` (decision 8), and from stage 2a `route` (decision 18). Its other fields keep their meaning.
|
- `/print` and `/preview` gain `printer`. A body without it prints on the default printer, as today, while no rule matches it.
|
||||||
- `?printer=default` keeps working on the module routes, and an empty `printer` still means the default printer.
|
|
||||||
- `/healthz` keeps `status`, `printer` and its code; it gains `printers`. `queue.pending` becomes the total across printers.
|
- `/healthz` keeps `status`, `printer` and its code; it gains `printers`. `queue.pending` becomes the total across printers.
|
||||||
- `queue.size` bounds each printer's queue, so a host with several printers can hold more jobs (decision 4).
|
- `queue.size` bounds each printer's queue, so a host with several printers can hold more jobs (decision 4).
|
||||||
- What prints does not change. TestRenderCompat and TestPaperReceipts keep passing; stage 4b changes bytes only for a model whose paper check sets a value.
|
- What prints does not change. TestRenderCompat and TestPaperReceipts keep passing; stage 4b changes bytes only for a model whose paper check sets a value.
|
||||||
@@ -455,13 +456,13 @@ DELIVERIES AND JOB STATUS (stages 1b-3)
|
|||||||
{"printer": "office", "status": "queued"}]}
|
{"printer": "office", "status": "queued"}]}
|
||||||
```
|
```
|
||||||
|
|
||||||
- `deliveries` from stage 1b (decision 8). `route` from stage 2a (decision 18), whose `by` is `rule`, `query` or `default`. An anycast delivery's `printers`, its ordered list, and `sent_to` from stage 3 (decisions 22 and 26).
|
- `deliveries` from stage 1b (decision 8). `route` from stage 2a (decision 18), whose `by` is `rule`, `request` or `default`. An anycast delivery's `printers`, its ordered list, and `sent_to` from stage 3 (decisions 22 and 26).
|
||||||
- The job's `status` derives from its deliveries by job-store decision 12; with one delivery it is that delivery's.
|
- The job's `status` derives from its deliveries by job-store decision 12; with one delivery it is that delivery's.
|
||||||
- Enums go into `jsonschema` tags, held by printqueue's and the server's schema tests.
|
- Enums go into `jsonschema` tags, held by printqueue's and the server's schema tests.
|
||||||
|
|
||||||
`?printer=` AND THE PREVIEW (stages 1b and 2c)
|
`printer` AND THE PREVIEW (stages 1b and 2c)
|
||||||
- `?printer=` is a direct unicast: the rules do not run, and `route.by` is `query`. It names a printer, never a group. An empty value means the default printer.
|
- A `printer` in the request's body is a direct unicast: the rules do not run, and `route.by` is `request`. It names a printer, never a group. An empty `printer` is the same as none (decision 7).
|
||||||
- Routes: the module routes, as today, and `POST /api/v1/print` and `POST /api/v1/preview` (decision 7). `unknown_printer` and `invalid_query` keep their codes; their api.md rows cover the new routes.
|
- Routes: the module routes, beside `payload` and `copies` as today, and `POST /api/v1/print` and `POST /api/v1/preview`, beside `elements` and `copies` (decision 7). `unknown_printer` keeps its code; its api.md row covers the new routes.
|
||||||
- A preview renders for the named printer, or the default printer. The JSON answer gains `printer` (stage 1b) and `route` (stage 2c): the decision without queueing (decision 21).
|
- A preview renders for the named printer, or the default printer. The JSON answer gains `printer` (stage 1b) and `route` (stage 2c): the decision without queueing (decision 21).
|
||||||
|
|
||||||
HEALTH (stage 1b)
|
HEALTH (stage 1b)
|
||||||
@@ -485,7 +486,7 @@ ROUTING RULES (stages 2a-2c)
|
|||||||
- `internal/pkg/routing` (new): `Env` and how it is built; the action (`Mode`, `To`) and its resolution against the printers and groups; the `printqueue.Router` it implements.
|
- `internal/pkg/routing` (new): `Env` and how it is built; the action (`Mode`, `To`) and its resolution against the printers and groups; the `printqueue.Router` it implements.
|
||||||
- printqueue defines `Route` and `Router`; it, the server and config never import Expr. Imports: routing → rules, printqueue, receipt; rules → Expr; internal/app → routing.
|
- printqueue defines `Route` and `Router`; it, the server and config never import Expr. Imports: routing → rules, printqueue, receipt; rules → Expr; internal/app → routing.
|
||||||
- config checks structure only: names, `order`, modes, `to`. The load helper in internal/app compiles the rules, so `config get` fails on a bad rule before install.sh restarts the daemon.
|
- config checks structure only: names, `order`, modes, `to`. The load helper in internal/app compiles the rules, so `config get` fails on a bad rule before install.sh restarts the daemon.
|
||||||
- At `Submit`: an explicit printer gives unicast, `by = "query"`. Otherwise the first match gives its action, with `to` expanded (decision 13). No match gives unicast to the default printer, `by = "default"`. A runtime error passes to the next rule (decision 15).
|
- At `Submit`: an explicit printer gives unicast, `by = "request"`. Otherwise the first match gives its action, with `to` expanded (decision 13). No match gives unicast to the default printer, `by = "default"`. A runtime error passes to the next rule (decision 15).
|
||||||
- `Submit` still refuses a printer with no lane (`ErrUnknownPrinter`, name assumed): a guard for a bug, once stage 2b checks reloads (decision 20). The server answers `500` and reports it, as any unexpected error. ntfy.go logs it at ERROR, reports it and does not offer the message again, as it does with a receipt that fails validation, so a subscription cannot stall on it.
|
- `Submit` still refuses a printer with no lane (`ErrUnknownPrinter`, name assumed): a guard for a bug, once stage 2b checks reloads (decision 20). The server answers `500` and reports it, as any unexpected error. ntfy.go logs it at ERROR, reports it and does not offer the message again, as it does with a receipt that fails validation, so a subscription cannot stall on it.
|
||||||
- Facts reach the router in `printqueue.Meta`. `Meta.Printer` comes in stage 1a. Stage 2a reads the module and the subscription from `Source`. Stage 2c adds `Meta.Facts`: client, topics, priority, tags and digest. The server fills them from the token's subject (auth.go keeps it beside the scope; never the token) and the module's built facts, since `Module.Build` returns the job with its topic, priority and tags. ntfy.go fills them from the message or the digest's rows. `Facts` are used at `Submit` only (decision 16). The job's size comes from encoding it once, which `Store.Add` also takes.
|
- Facts reach the router in `printqueue.Meta`. `Meta.Printer` comes in stage 1a. Stage 2a reads the module and the subscription from `Source`. Stage 2c adds `Meta.Facts`: client, topics, priority, tags and digest. The server fills them from the token's subject (auth.go keeps it beside the scope; never the token) and the module's built facts, since `Module.Build` returns the job with its topic, priority and tags. ntfy.go fills them from the message or the digest's rows. `Facts` are used at `Submit` only (decision 16). The job's size comes from encoding it once, which `Store.Add` also takes.
|
||||||
- A reload swaps the set and the groups as one value, checked against the running printers (decision 20, stage 2b).
|
- A reload swaps the set and the groups as one value, checked against the running printers (decision 20, stage 2b).
|
||||||
@@ -706,9 +707,9 @@ internal/app/uberbringer
|
|||||||
- The full gate passes.
|
- The full gate passes.
|
||||||
- Paper, with the owner's OK: with a second printer configured at an address that refuses the connection, such as a closed port on the workstation, one short receipt through the default printer, the TM-T88IV. Look at the line breaks, the characters and the cut: as before. Wait for his report.
|
- Paper, with the owner's OK: with a second printer configured at an address that refuses the connection, such as a closed port on the workstation, one short receipt through the default printer, the TM-T88IV. Look at the line breaks, the characters and the cut: as before. Wait for his report.
|
||||||
|
|
||||||
### Stage 1b: `?printer=`, `/healthz` per printer, and deliveries in job status
|
### Stage 1b: `printer` in the body, `/healthz` per printer, and deliveries in job status
|
||||||
|
|
||||||
**Goal.** `?printer=` sends a job to one printer on every print and preview route. `/healthz` lists every printer, and its code still follows the default printer. Job status gains `deliveries`. Needs stage 1a. Decisions 7-9.
|
**Goal.** `printer` in the body sends a job to one printer on every print and preview route. `/healthz` lists every printer, and its code still follows the default printer. Job status gains `deliveries`. Needs stage 1a. Decisions 7-9.
|
||||||
|
|
||||||
**Work.**
|
**Work.**
|
||||||
|
|
||||||
@@ -718,27 +719,29 @@ internal/pkg/printqueue
|
|||||||
|
|
||||||
internal/app/uberbringer/server
|
internal/app/uberbringer/server
|
||||||
- server.go: `Deps` takes the printers, the default first, each with its name, configured model, `Printer` and `Previewer`; the nil checks follow. `Jobs.Pending` per printer.
|
- server.go: `Deps` takes the printers, the default first, each with its name, configured model, `Printer` and `Previewer`; the nil checks follow. `Jobs.Pending` per printer.
|
||||||
- handlers.go: `handlePrint` reads the query (decision 7). `handleHealth`, `healthResponse` and `queueHealth` (decision 9): the default printer read once, filling `printer` and the first entry; the others read in parallel.
|
- handlers.go: `handlePrint` decodes `printer` with the job's fields and checks it (decision 7). `handleHealth`, `healthResponse` and `queueHealth` (decision 9): the default printer read once, filling `printer` and the first entry; the others read in parallel.
|
||||||
- handlers_modules.go: `moduleQuery` checks `printer` against the configured names; the `defaultPrinter` constant and its "the only printer is" message go.
|
- handlers_modules.go: `decodeModuleRequest` checks `printer` against the configured names; the `defaultPrinter` constant and its "the only printer is" message go, and `moduleRequest.Printer`'s doc comment, the schema's description, no longer calls it reserved.
|
||||||
- handlers_preview.go: `?printer=` on both preview routes; the JSON answer's `printer`.
|
- handlers_preview.go: `printer` on both preview routes; the JSON answer's `printer`.
|
||||||
- routes.go: query parameters for `/api/v1/print` and `/api/v1/preview`; `unknown_printer` and `invalid_query` in their error lists; the descriptions of the module routes' `printer` and of `/healthz` ("depends on the printer alone").
|
- routes.go: the request type of `/api/v1/print` and `/api/v1/preview`, the job's fields and `printer`; `unknown_printer` in their error lists; the description of `/healthz` ("depends on the printer alone").
|
||||||
- errors.go: no new code; the messages of `unknown_printer` and `invalid_query` fit the new routes.
|
- errors.go: no new code; the message of `unknown_printer` fits the new routes.
|
||||||
|
|
||||||
internal/app/uberbringer
|
internal/app/uberbringer
|
||||||
- serve.go: the server gets every printer.
|
- serve.go: the server gets every printer.
|
||||||
|
- preview.go: a job that `preview` reads may hold `printer`, as the `/print` body does, and is laid out for that printer; `--printer` wins over it. Today `receipt.DecodeJob` refuses the field as unknown.
|
||||||
|
|
||||||
Docs
|
Docs
|
||||||
- docs/api.md:
|
- docs/api.md:
|
||||||
- `?printer=` on print and preview, and the module routes' `printer`;
|
- `printer` in the body of print and preview, and the module routes' `printer`;
|
||||||
- the `unknown_printer` and `invalid_query` rows, the latter no longer "On a module route" only;
|
- the `unknown_printer` row, no longer "On a module route" only;
|
||||||
- Health, with `printers`; `queue.pending` as the total across printers, which changes its meaning for monitors that alert on it; the status code following the default printer;
|
- Health, with `printers`; `queue.pending` as the total across printers, which changes its meaning for monitors that alert on it; the status code following the default printer;
|
||||||
- Job status, with `deliveries` and the job's own fields.
|
- Job status, with `deliveries` and the job's own fields.
|
||||||
- docs/swagger.json regenerated.
|
- docs/swagger.json regenerated.
|
||||||
- docs/configuration.md § printers: a job reaches a named printer with `?printer=`.
|
- docs/configuration.md § printers: a job reaches a named printer with `printer` in the request's body.
|
||||||
- docs/security.md: any token that may print may name any printer.
|
- docs/security.md: any token that may print may name any printer.
|
||||||
|
- docs/cli.md § preview: a job's `printer`, and `--printer` winning over it.
|
||||||
- docs/docker.md § Health checks: `/healthz` answers `503` while the default printer is unreachable; the others show in its body.
|
- docs/docker.md § Health checks: `/healthz` answers `503` while the default printer is unreachable; the others show in its body.
|
||||||
- design.md: the diagram's `/healthz`; "Module routes take `copies` and the reserved `printer`"; "Health is for monitors" and the ntfy paragraph's "depends on the printer alone" name the default printer.
|
- design.md: the diagram's `/healthz`; the module routes' bullet on `copies` and the reserved `printer`; "Health is for monitors" and the ntfy paragraph's "depends on the printer alone" name the default printer.
|
||||||
- CHANGELOG: under Added, `?printer=` on print and preview, `printers` in `/healthz` and `deliveries` in job status; under **Breaking**, `/print` and `/preview` refuse other query parameters; under Changed, `queue.pending` is the total across printers.
|
- CHANGELOG: under Added, `printer` in the body of print and preview, `printers` in `/healthz` and `deliveries` in job status; under Changed, `queue.pending` is the total across printers.
|
||||||
|
|
||||||
**Tests.**
|
**Tests.**
|
||||||
|
|
||||||
@@ -746,10 +749,10 @@ internal/pkg/printqueue
|
|||||||
- Status: `deliveries` and the job's own fields, as a table test over one, two and three deliveries.
|
- Status: `deliveries` and the job's own fields, as a table test over one, two and three deliveries.
|
||||||
|
|
||||||
internal/app/uberbringer/server. The test helpers keep their `Printer` argument as the default printer and take more through an option, to limit the churn across their 50 callers (`newTestServer` 40, `newLoggedServer` 10).
|
internal/app/uberbringer/server. The test helpers keep their `Printer` argument as the default printer and take more through an option, to limit the churn across their 50 callers (`newTestServer` 40, `newLoggedServer` 10).
|
||||||
- `?printer=` on `/print`, `/preview`, `/preview/{module}` and `/print/{module}`:
|
- `printer` in the body of `/print`, `/preview`, `/preview/{module}` and `/print/{module}`:
|
||||||
- a configured name reaches its lane, and an empty value the default's;
|
- a configured name reaches its lane, and an empty value the default's;
|
||||||
- another name, `Office` for `office` included, gives `unknown_printer`;
|
- another name, `Office` for `office` included, gives `unknown_printer`;
|
||||||
- a parameter given twice, or another parameter, gives `invalid_query`.
|
- `?printer=office` gives `invalid_query`, and nothing is queued.
|
||||||
- The JSON preview names its printer and renders with that printer's options.
|
- The JSON preview names its printer and renders with that printer's options.
|
||||||
- `/healthz` with three printers:
|
- `/healthz` with three printers:
|
||||||
- the code follows the default printer only;
|
- the code follows the default printer only;
|
||||||
@@ -760,16 +763,17 @@ internal/app/uberbringer/server. The test helpers keep their `Printer` argument
|
|||||||
- TestHealthEnumsMatchHandler covers the entries. TestRoutesConform and TestRegisteredRoutesAreTheTable pass with no new route.
|
- TestHealthEnumsMatchHandler covers the entries. TestRoutesConform and TestRegisteredRoutesAreTheTable pass with no new route.
|
||||||
|
|
||||||
internal/app/uberbringer
|
internal/app/uberbringer
|
||||||
- A two-printer run against two fake printer listeners: `?printer=<name>` reaches only that listener; a job without it reaches only the default's.
|
- `preview` of a job that names a printer lays it out for that printer; with `--printer` as well, for the printer `--printer` names; an unknown name fails, naming it.
|
||||||
|
- A two-printer run against two fake printer listeners: a body whose `printer` names one reaches only that listener; a job without it reaches only the default's.
|
||||||
|
|
||||||
**Done when.**
|
**Done when.**
|
||||||
- The full gate passes.
|
- The full gate passes.
|
||||||
- With the owner's OK, a status read only: with a second printer configured at an address that refuses the connection, `/healthz` answers `200`, with that entry `unreachable`. An address with no host behind it may read `timeout` instead (decision 9).
|
- With the owner's OK, a status read only: with a second printer configured at an address that refuses the connection, `/healthz` answers `200`, with that entry `unreachable`. An address with no host behind it may read `timeout` instead (decision 9).
|
||||||
- Paper, with the owner's OK, once a second printer is on hand and its status sheet read (decision 31): one short receipt with `?printer=<name>`. It prints there only, with line breaks at 42 columns. Wait for his report. With one printer only, this check waits, and the stage is done on the fakes.
|
- Paper, with the owner's OK, once a second printer is on hand and its status sheet read (decision 31): one short receipt with `"printer": "<name>"`. It prints there only, with line breaks at 42 columns. Wait for his report. With one printer only, this check waits, and the stage is done on the fakes.
|
||||||
|
|
||||||
### Stage 2a: Expr rules on a job's source, shape and clock
|
### Stage 2a: Expr rules on a job's source, shape and clock
|
||||||
|
|
||||||
**Goal.** Expr rules route every job without `?printer=`, in unicast, multicast and broadcast. They see the job's source, module, subscription, shape and clock. The rule set is compiled once, ordered, and held as one value the engine can swap. The decision is stored with the job and shown in its status. Needs stage 1b. Decisions 10-19.
|
**Goal.** Expr rules route every job whose request names no printer, in unicast, multicast and broadcast. They see the job's source, module, subscription, shape and clock. The rule set is compiled once, ordered, and held as one value the engine can swap. The decision is stored with the job and shown in its status. Needs stage 1b. Decisions 10-19.
|
||||||
|
|
||||||
**Work.**
|
**Work.**
|
||||||
|
|
||||||
@@ -838,7 +842,7 @@ internal/pkg/rules
|
|||||||
internal/pkg/routing
|
internal/pkg/routing
|
||||||
- The env from each source: `/print`, a module route, an ntfy card, a digest.
|
- The env from each source: `/print`, a module route, an ntfy card, a digest.
|
||||||
- The clock in a zone with clock changes (Europe/London); `weekday` uses `quiet.days`' names; `clock` is zero-padded.
|
- The clock in a zone with clock changes (Europe/London); `weekday` uses `quiet.days`' names; `clock` is zero-padded.
|
||||||
- Decisions: an explicit printer (`query`; the rules not run); a match; no match (`default`); multicast expanded with repeats dropped; broadcast to every printer, the default first.
|
- Decisions: an explicit printer (`request`; the rules not run); a match; no match (`default`); multicast expanded with repeats dropped; broadcast to every printer, the default first.
|
||||||
- A rule failing at run time logs one WARN line with its name, the job's ID and the position and no message, and reports to Sentry once however many jobs it fails.
|
- A rule failing at run time logs one WARN line with its name, the job's ID and the position and no message, and reports to Sentry once however many jobs it fails.
|
||||||
- A panic while the env is built routes to the default printer, logged and reported once.
|
- A panic while the env is built routes to the default printer, logged and reported once.
|
||||||
- A test holds the variable table in docs/configuration.md to `Env`'s `expr` tags.
|
- A test holds the variable table in docs/configuration.md to `Env`'s `expr` tags.
|
||||||
@@ -863,7 +867,8 @@ internal/app/uberbringer
|
|||||||
- ntfy: an `ErrUnknownPrinter` is logged and reported, and the message is not offered again.
|
- ntfy: an `ErrUnknownPrinter` is logged and reported, and the message is not offered again.
|
||||||
|
|
||||||
internal/app/uberbringer/server
|
internal/app/uberbringer/server
|
||||||
- A group's name in `?printer=` gives `unknown_printer`.
|
- A group's name in `printer` gives `unknown_printer`.
|
||||||
|
- An empty `printer` lets the rules decide, as a missing one does; `"printer": "default"` reaches the default printer with `by` `request`.
|
||||||
- schema_test: the `route` enums.
|
- schema_test: the `route` enums.
|
||||||
|
|
||||||
**Done when.**
|
**Done when.**
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ For stage 1:
|
|||||||
- The sample needs only the fields the template reads, so a payload of many kilobytes can be cut down to a few lines.
|
- The sample needs only the fields the template reads, so a payload of many kilobytes can be cut down to a few lines.
|
||||||
- No variable sets `[[templates]]`, nor, from later stages, `[[ntfy.rules]]` or `[webhooks]`. At start one WARN line names any `UBERBRINGER_TEMPLATES_*` or `UBERBRINGER_WEBHOOKS_*` variable, never its value, as printers.md decision 2 does for its sections.
|
- No variable sets `[[templates]]`, nor, from later stages, `[[ntfy.rules]]` or `[webhooks]`. At start one WARN line names any `UBERBRINGER_TEMPLATES_*` or `UBERBRINGER_WEBHOOKS_*` variable, never its value, as printers.md decision 2 does for its sections.
|
||||||
- Trade-off: long templates make the config long, and the config holds `api.secret`, so whoever edits templates can read it.
|
- Trade-off: long templates make the config long, and the config holds `api.secret`, so whoever edits templates can read it.
|
||||||
4. **Templates and the existing modules.** Every template is also a module. It appears in `GET /api/v1/modules` with its description, prints at `POST /api/v1/print/<name>` and previews at `POST /api/v1/preview/<name>`, with the same query (`copies`, `printer`), answers and token scopes as `note`, `notify` and `ntfy`. A `json` template takes a JSON object as its body, as the module routes document it (server/handlers_modules.go:21-23); an `ntfy` template takes one ntfy message object, decoded leniently as the `ntfy` module does.
|
4. **Templates and the existing modules.** Every template is also a module. It appears in `GET /api/v1/modules` with its description, prints at `POST /api/v1/print/<name>` and previews at `POST /api/v1/preview/<name>`, with the same body (`payload`, `copies`, `printer`), answers and token scopes as `note`, `notify` and `ntfy`. A `json` template takes a JSON object as its payload, as the module routes document it (`moduleRequest`, server/handlers_modules.go); an `ntfy` template takes one ntfy message object, decoded leniently as the `ntfy` module does.
|
||||||
- Template names share the modules' namespace and pattern, `^[a-z][a-z0-9-]{0,31}$` (modules/registry.go:96). A template named like a built-in module is a config error.
|
- Template names share the modules' namespace and pattern, `^[a-z][a-z0-9-]{0,31}$` (modules/registry.go:112). A template named like a built-in module is a config error.
|
||||||
- So a script that can send a bearer token uses a template without a webhook, a token from `uberbringer token --modules <name>` limits it to that template, and the preview route is the dry-run over HTTP (decision 10). `uberbringer token` reads the config before it checks the names, which today it checks against the built-in modules only (internal/app/uberbringer/cli.go:156-161).
|
- So a script that can send a bearer token uses a template without a webhook, a token from `uberbringer token --modules <name>` limits it to that template, and the preview route is the dry-run over HTTP (decision 10). `uberbringer token` reads the config before it checks the names, which today it checks against the built-in modules only (internal/app/uberbringer/cli.go:156-161).
|
||||||
- Emoji are removed from the text fields of what a template returns (`text`, `title`, `footer`, `key`, `value`, list items and the card's fields), as on the notification path (design.md:134-138), rather than printed as `?`. `url`, `data` and `base64` are left as they are. The `note` module keeps printing them as `?`.
|
- Emoji are removed from the text fields of what a template returns (`text`, `title`, `footer`, `key`, `value`, list items and the card's fields), as on the notification path (design.md:134-138), rather than printed as `?`. `url`, `data` and `base64` are left as they are. The `note` module keeps printing them as `?`.
|
||||||
- `GET /api/v1/modules` lists every template's name and description to any token, those limited to other modules included. docs/security.md says so.
|
- `GET /api/v1/modules` lists every template's name and description to any token, those limited to other modules included. docs/security.md says so.
|
||||||
@@ -165,7 +165,7 @@ KANRISHA
|
|||||||
- The engine itself is as printers.md's findings describe. Its runtime error log quotes Expr's message (engine.go:236-245), which this plan does not copy.
|
- The engine itself is as printers.md's findings describe. Its runtime error log quotes Expr's message (engine.go:236-245), which this plan does not copy.
|
||||||
|
|
||||||
THE REPOSITORY
|
THE REPOSITORY
|
||||||
- A module turns a body into a `receipt.Job` (modules/registry.go:72-87). The module routes answer `204` for `ErrSkip` and `422` `module_failed` for an invalid built job, with the problems' text (server/handlers_modules.go:90-118). They never call `checkRaw`, which only `/print` does.
|
- A module turns a body into a `receipt.Job` (modules/registry.go:88-103). The module routes answer `204` for `ErrSkip` and `422` `module_failed` for an invalid built job, with the problems' text (server/handlers_modules.go:105-133). They never call `checkRaw`, which only `/print` does.
|
||||||
- The subscriber's order (ntfy/subscriber.go:497-534): skip by `min_priority`; skip an update if `updates = "skip"`; quiet hours drop or hold; the budget holds unless `bypass_priority`, and so does a digest already waiting (line 518); then `Handler.Message`. An error from the handler stops reading and offers the message again. Held messages print as soon as the budget has room, or when quiet hours end (ntfy/subscriber.go:616-628). A digest row is a message's title, or its text's first line cut to 256 bytes (ntfy/ratelimit.go:113-139).
|
- The subscriber's order (ntfy/subscriber.go:497-534): skip by `min_priority`; skip an update if `updates = "skip"`; quiet hours drop or hold; the budget holds unless `bypass_priority`, and so does a digest already waiting (line 518); then `Handler.Message`. An error from the handler stops reading and offers the message again. Held messages print as soon as the budget has room, or when quiet hours end (ntfy/subscriber.go:616-628). A digest row is a message's title, or its text's first line cut to 256 bytes (ntfy/ratelimit.go:113-139).
|
||||||
- internal/app turns a message into a card and submits it; a card that fails validation is logged, reported and dropped (internal/app/uberbringer/ntfy.go:165-206).
|
- internal/app turns a message into a card and submits it; a card that fails validation is logged, reported and dropped (internal/app/uberbringer/ntfy.go:165-206).
|
||||||
- `checkRaw` walks top-level elements only (server/auth.go:135-150), so a job built elsewhere must refuse `raw` itself.
|
- `checkRaw` walks top-level elements only (server/auth.go:135-150), so a job built elsewhere must refuse `raw` itself.
|
||||||
|
|||||||
Reference in new issue
Block a user