Bring the printers questions in line with the accepted plans
The owner has accepted the remote-printers and templates plans with every default since docs/plans/printers.md was written. They settle three of its questions and lean on the defaults of many more. Questions 6, 10 and 17 now say they are settled, and keep their numbers, since other plans cite them. Remote-printers decision 16 makes a printer remote with an agent key, so no kind key is reserved. Templates decision 1 adds Expr at its latest stable release in whichever plan's stage comes first, and with remote-printers decision 4 accepts the size it adds. Templates decision 6 gives the compile options of question 17 to both plans through rules.Options. Two defaults change to match. Routing rules now carry the iteration guard of templates decision 6, which the shared options hold; the question assumed no guard, and printers.md's own Architecture already said the guard was shared. A SIGHUP reload now also applies an agent's tokens_since, as remote-printers decision 6 expects; the question applied routing and the templates' sections only. Questions 1-3, 9, 11, 12, 14, 15, 22 and 23 name the accepted decisions that lean on them, and question 3 says the address rule covers local printers only. Stage 2a adds Expr, rules.Options and the engine only if templates has not. The acceptance edits drop the two to job-store.md that its own update has made, and design.md's Planned next item 2 will record the decisions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aaeeba8eb4
commit
a06c12a202
1 file changed
+34
-26
+34
-26
@@ -1,12 +1,12 @@
|
||||
# Plan: several printers, routed by Expr rules
|
||||
|
||||
Status: **planning; nothing is built.** 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, question 5's restore rule applies to it, and stage 2a adds a schema step (question 18). Each stage runs in its own session, briefed from its section, once the owner has answered the questions listed for it or accepted their assumed defaults:
|
||||
- stage 1a needs questions 1-6, and stage 1b needs 7-9;
|
||||
- stage 2a needs 10-19, stage 2b needs 20, and stage 2c needs 21;
|
||||
- stage 1a needs questions 1-5, and stage 1b needs 7-9;
|
||||
- stage 2a needs 11-16, 18 and 19, stage 2b needs 20, and stage 2c needs 21;
|
||||
- stage 3 needs 22-26, and question 23's paper check;
|
||||
- stage 4a needs 27-29, and stage 4b needs 30 and 31. Question 31 is also needed before the first receipt on a new printer.
|
||||
|
||||
Each answer goes into design.md at once and leaves this list. The stages run in the order listed, except that stages 2b and 2c each need only 2a. Stage 4a needs only the TM-T88VII on hand, which can be the default printer until stage 1a ships. Stage 4b runs once for each new model as it arrives; it needs 4a only when a value differs between models of one family. Every check on a real printer, of its paper or of its status, needs the owner's OK. When the owner accepts the plan, the edits under Overview, ON ACCEPTANCE, are made. Whichever stage finishes last deletes this plan, its findings with it, and design.md's Planned next item 2.
|
||||
Questions 6, 10 and 17 are settled by plans the owner has accepted since, and say so where they stand, so that the numbers other plans cite still hold. Each answer goes into design.md at once and leaves this list. The stages run in the order listed, except that stages 2b and 2c each need only 2a. Stage 4a needs only the TM-T88VII on hand, which can be the default printer until stage 1a ships. Stage 4b runs once for each new model as it arrives; it needs 4a only when a value differs between models of one family. Every check on a real printer, of its paper or of its status, needs the owner's OK. When the owner accepts the plan, the edits under Overview, ON ACCEPTANCE, are made. Whichever stage finishes last deletes this plan, its findings with it, and design.md's Planned next item 2.
|
||||
|
||||
## Decisions (owner, 2026-11-30)
|
||||
|
||||
@@ -47,14 +47,16 @@ Before stage 1a:
|
||||
|
||||
1. **Today's `[printer]` table.** Assumed: it 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.
|
||||
- docs/plans/remote-printers.md decision 16 builds on this default: `[printer]` may be remote, through `agent` and `UBERBRINGER_PRINTER_AGENT`.
|
||||
- Trade-off: two table shapes, and the default printer cannot be renamed.
|
||||
- Alternatives: move it into `[printers.default]`, as formatters phase 5 sketched. That is **Breaking** for every deployed config: `[printer]` becomes an unknown key, the daemon stops at start after an upgrade, and install.sh parses no TOML to migrate it. Or accept both and refuse a config with both: a shim, and unclear which variables win. Or `[printer]` as defaults the others inherit: inheriting an address makes no sense, and inheritance hides which values a printer uses.
|
||||
2. **Printer names, and no variables for named printers.** Assumed: 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.
|
||||
- The accepted plans follow this default: docs/plans/remote-printers.md decisions 6 and 11 read `[agents.<name>]` and the agent's printer tables from the file only, and docs/plans/templates.md decision 3 gives its sections the same WARN.
|
||||
- Trade-off: a container with several printers needs a mounted config, as one with subscriptions does, and a named printer's address cannot come from a variable.
|
||||
- Alternatives: bind `UBERBRINGER_PRINTERS_<NAME>_<KEY>` after the file is read, for the printers it names (the probe shows this works; a name with `-` gives a variable no POSIX shell can set). Or declare printers by scanning the environment, which rules out `-` in names and needs a test that no printer key ends another after an `_`. The module names' rule, `^[a-z][a-z0-9-]{0,31}$`, is the other candidate pattern.
|
||||
3. **Which keys belong to each printer.** Assumed: every key of today's `[printer]`: `address`, `port`, `model`, `codepage`, `paper_width`, `columns`, `box_line_spacing`, `cut_feed`, `dial_timeout`, `write_timeout`, `retries` and `retry_delay`. A `[printers.<name>]` table starts from the same defaults as `[printer]`, not from `[printer]`'s values, and only `address` is required. `format.*`, `images.*`, `queue.*` and `ntfy.*` stay global.
|
||||
3. **Which keys belong to each printer.** Assumed: every key of today's `[printer]`: `address`, `port`, `model`, `codepage`, `paper_width`, `columns`, `box_line_spacing`, `cut_feed`, `dial_timeout`, `write_timeout`, `retries` and `retry_delay`. A `[printers.<name>]` table starts from the same defaults as `[printer]`, not from `[printer]`'s values, and only `address` is required. `format.*`, `images.*`, `queue.*` and `ntfy.*` stay global. docs/plans/remote-printers.md decision 16 adds `agent`: a remote printer names its agent in place of `address` and `port`, and keeps the other keys.
|
||||
- `model` and `codepage` are checked when the config loads, by one helper in internal/app that the start, `config get` and `preview` share. Today they are checked only at start, so `config get` passes a bad model and install.sh restarts the daemon into the error.
|
||||
- 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.
|
||||
- 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.
|
||||
- Alternatives: per-printer `format.*`, which nothing asks for; for a repeated address, one client shared by both lanes.
|
||||
4. **One queue with a lane per printer.** Assumed: 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 (question 19 for multicast and broadcast). Order is first in, first out per printer.
|
||||
@@ -63,9 +65,7 @@ Before stage 1a:
|
||||
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. Assumed: 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).
|
||||
- Trade-off: renaming a printer fails what waits for it.
|
||||
- Alternatives: refuse to start until the printer is back, which stops every printer over one; or send them to the default printer, a room nobody chose.
|
||||
6. **The seam for remote printers.** Assumed: no `kind` key and no address scheme now. 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 remote-printers plan adds its own key, which 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.
|
||||
- Trade-off: none known. docs/plans/remote-printers.md names the key, `agent` (its decision 16).
|
||||
- Alternative: reserve `kind = "tcp"` now, as the only value accepted.
|
||||
6. **The seam for remote printers. Settled** by docs/plans/remote-printers.md decision 16, which 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.
|
||||
|
||||
Before stage 1b:
|
||||
|
||||
@@ -85,21 +85,23 @@ Before stage 1b:
|
||||
- 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.
|
||||
- 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.
|
||||
- docs/plans/remote-printers.md decision 10 builds on this default: `/healthz` gains `agents`, a remote printer's entry gains `agent`, and the code still follows the default printer alone.
|
||||
- Trade-off: a monitor alerts on another printer only by reading the body. A health read takes that printer's connection slot for up to 3 s and delays only its own lane. The public route now shows printer names, often room names, and models.
|
||||
- Alternative: `/healthz?printer=<name>`, whose code follows that printer, with an error for an unknown name. It goes beyond what was asked.
|
||||
|
||||
Before stage 2a:
|
||||
|
||||
10. **Expr's version, and the size it adds.** Assumed: `github.com/expr-lang/expr` at its latest stable release, v1.18.1 (2026-11-22) at the time of writing. v1.18.0 and v1.18.1 fixed five advisories rated High that affect v1.17.8, Kanrisha's pin. Assumed too: the binary may grow by about 5.3-5.8 MB (+36-37%) on every target, armv6 included.
|
||||
10. **Expr's version, and the size it adds. Settled** by docs/plans/templates.md decision 1: `github.com/expr-lang/expr` comes in at its latest stable release, v1.18.1 (2026-11-22) at the time of writing, with govulncheck, in whichever of this plan's stage 2a and that plan's stage 1 comes first. v1.18.0 and v1.18.1 fixed five advisories rated High that affect v1.17.8, Kanrisha's pin. The binary grows by about 5.3-5.8 MB (+36-37%) on every target, armv6 included, which that decision and docs/plans/remote-printers.md decision 4 accept.
|
||||
- About half is Expr itself. The rest is other packages' methods that the linker can no longer drop, because Expr calls `reflect.Value.MethodByName` with a name that is not a constant. GORM has the same effect (job-store question 1). It applies once per binary, so with Expr linked, GORM's extra cost over plain SQL falls to about its own code.
|
||||
- The size was measured with v1.17.8 from the module cache. Stage 2a records the size with the version it pins, from the snapshot build.
|
||||
- The size was measured with v1.17.8 from the module cache. The stage that first links Expr into the binary records the size with the version it pins, from the snapshot build.
|
||||
- Trade-off: a larger tarball and image, and more to load on a Pi.
|
||||
- Alternative: a match table in TOML with no expressions, which goes against the owner's decision.
|
||||
11. **The config's shape.** Assumed: a `[routing]` section. `[routing.groups]` maps a group's name to its printers. Each `[[routing.rules]]` has `name`, `order`, `when`, `mode`, `to` and `enabled`. A rule's name follows the printer names' rule and is unique, so logs and `route` name one rule. `to` takes a name or a list, as list keys do. `when` is best written as a TOML literal string, so Expr's double quotes need no escaping. Both come from the file only: a list of tables has no variable, and a table of lists does not fit the `name=value` form, as the probe showed.
|
||||
- Not `[[routes]]` and a top-level `[groups]`: "route" already means an HTTP route in server/routes.go, CLAUDE.md and api.md. A `[routing]` section also gives later keys a home.
|
||||
- docs/plans/templates.md decisions 12 and 23 shape their rules on this default: `[[ntfy.rules]]`, and `[[webhooks.rules]]` beside the hooks in `[webhooks]`, as these sit in `[routing]` beside the groups.
|
||||
- Trade-off: one more level in the file.
|
||||
- Alternatives: `[[routes]]` and `[groups]`, which load the same way; or a key per mode (`printer`, `printers`, `group`) in place of `to`.
|
||||
12. **Rule order.** Assumed: `order` is a required integer, unique across all rules, disabled ones included, lower first, as Kanrisha's priority; the first match wins. A disabled rule's `order` is unique too, so enabling it cannot break a start. It is not called `priority`, which a rule's `when` already uses for the ntfy priority. A unique `order` avoids Kanrisha's `sort.Slice`, which is not stable, so there rules of equal priority run in no fixed order.
|
||||
- docs/plans/templates.md decisions 1 and 12 lean on this default: its ntfy and webhook rules take the same `order` through the shared engine.
|
||||
- Trade-off: inserting a rule can mean renumbering; gaps of 10 help.
|
||||
- Alternatives: an optional `order`, sorted stably, ties broken by position in the file. Or the order in which the rules are written, with no number, which departs from the owner's decision that rules are ordered by priority.
|
||||
13. **Groups, and what `to` takes.** Assumed: groups hold printers, never other groups, so no cycle can form. Groups and printers share one namespace, since `to` can name either; a group named like a printer, or `default`, is an error. A group is not empty, repeats no member and names configured printers. `to` by mode:
|
||||
@@ -110,9 +112,11 @@ Before stage 2a:
|
||||
- Trade-off: lists repeat where nested groups would not. Nesting needs a cycle check whose error names the cycle.
|
||||
14. **A rule that fails to compile.** Assumed: a config error. The start fails, and so does `config get`, listing every problem with the rule's name, Expr's position and its message, for example `routing.rules[1] ("alerts").when: unknown name sorce (1:1)`. The source line Expr adds under its message is left out, since it could quote a topic. Expr's message itself can still quote a name or a constant pattern from the rule. Disabled rules are compiled too, so enabling one cannot break a start. On a reload (question 20), the new set is refused whole and the old one kept.
|
||||
- This departs from the owner's decision as worded, which takes Kanrisha's "skips and logs a rule that fails to compile"; accepting this default amends it. Kanrisha's rules are database rows that must not stop the archiver. Here they sit in a file whose unknown keys already stop the start, and a skipped rule would send its jobs to the default printer without a word: paper in the wrong room.
|
||||
- docs/plans/templates.md decision 1 leans on this default, and its decision 9 makes a template that fails at load a config error too.
|
||||
- Trade-off: one broken rule stops the daemon at start.
|
||||
- Alternative: Kanrisha's skip and log, as the decision words it.
|
||||
15. **A rule that fails at run time.** Assumed: as in Kanrisha, the rule counts as not matched and the next rule is tried. One WARN line gives the `job_id`, the rule's name, and the line and column from Expr's `*file.Error`. It never calls `Error()`, whose text carries the rule's source and quotes values from the env: the probe's `int(topic)` gave `invalid operation: int(alerts-door)`, and a topic can be a secret. An error of any other type logs the rule's name only. It is reported to Sentry once per rule per run, without the message. A panic while the env is built is recovered: logged at ERROR, reported once, and the job goes to the default printer, since on the ntfy path a panic would end the daemon.
|
||||
- docs/plans/templates.md decisions 1, 8 and 14 lean on this default: a template's or an ntfy rule's failure is logged and reported the same way.
|
||||
- Trade-off: the log does not say what went wrong; `uberbringer route` shows the whole message on the terminal.
|
||||
- Alternatives: refuse the job, which is louder but loses jobs. Or list the rules that failed, by name, in the job's `route`, so that a job sent to `default` because a rule broke shows without the logs; that needs one more stored column, or a field a restart loses.
|
||||
16. **What a rule sees.** Assumed: the variables under Architecture, THE ENVIRONMENT: routing facts only. No print content, no token or secret, no `ref`, no client address and no printer state. Stage 2a gives the job's source, shape and clock; stage 2c adds a notification's topic, priority and tags and the token's subject. In particular:
|
||||
@@ -124,9 +128,9 @@ Before stage 2a:
|
||||
- The rules of docs/plans/templates.md, for ntfy messages and webhooks, see print contents (its decision 14). A routing rule still sees routing facts only.
|
||||
- Trade-off: no rule can say "multicast when the kitchen is out of paper".
|
||||
- Alternative: content in the env too, for routing by what a job says. Expr's messages and a dry-run would then quote it, and a 4 MiB body in a string builtin can exceed Expr's memory budget, so the same rule would fail only on big jobs.
|
||||
17. **Compile options and the clock.** Assumed: `expr.Env(routing.Env{})`, `expr.AsBool()`, `expr.DisableBuiltin("now")`, `expr.DisableBuiltin("$env")` and the default node limit. `expr.Timezone` takes `format.timezone` once validation has loaded the zone, since it panics on an unknown name. 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. No guard against literal ranges, since rules are trusted config.
|
||||
- Trade-off: Expr 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. Only the owner writes rules.
|
||||
- Alternative: a `Patch` visitor that refuses `..` ranges.
|
||||
17. **Compile options and the clock. Settled** by docs/plans/templates.md decision 6, whose options are this question's, shared 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 question 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.
|
||||
18. **Storing the decision.** Assumed: 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).
|
||||
- This replaces job-store.md's assumption that a restored anycast delivery's list is "given again" by the rules and the config. Its `jobs` row keeps no priority, tags or client, and the rules may have changed since.
|
||||
- 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.
|
||||
@@ -151,6 +155,7 @@ Before stage 2b:
|
||||
- The unit gains `ExecReload`, so `systemctl reload uberbringer` works; a container takes `docker kill --signal HUP`; Windows, for development only, has no reload. Viper's `WatchConfig` is not used: it fires on an editor's partial saves.
|
||||
- With these checks, `Submit`'s guard for a printer with no lane cannot fire; it stays for a bug (Architecture, ROUTING RULES).
|
||||
- The reload also swaps docs/plans/templates.md's templates, ntfy rules and webhooks, in one snapshot with `[routing]` (its decision 17).
|
||||
- It also applies `[agents]`' `tokens_since`, so a revoked agent is refused without a restart, as docs/plans/remote-printers.md decision 6 expects; whichever of stage 2b and remote-printers stage 2 lands second wires it.
|
||||
- Trade-off: more code and tests than a restart. A new printer, and a rule for it, need a restart. Until job-store stage 1d, a restart fails the waiting jobs, which a reload does not.
|
||||
- Alternative: no reload, which goes against the owner's decision ("swaps the rule set atomically on reload").
|
||||
|
||||
@@ -168,6 +173,7 @@ Before stage 3:
|
||||
- `attempts` counts every attempt on every printer, and each mark's attempt number goes on from the last.
|
||||
- The risk: the next printer prints the whole receipt. A first printer that took all of it before the error, or buffered it and prints it once its fault clears, prints it too.
|
||||
- Some sends that will not print show no error at all. `Write` returns once the kernel holds the bytes, so a printer that goes offline after taking them, or one that another host holds, takes the receipt without a word, and no failover happens (Investigation findings, WHAT "THE PRINTER FAILED" CAN MEAN).
|
||||
- docs/plans/remote-printers.md decision 17 leans on this default: a remote `partial` outcome is today's write error, and `nothing` matches `NothingWritten`.
|
||||
- Alternatives: (a) no failover after a `sending` mark: the delivery retries on that printer, then fails, and a person checks the paper; (b) failover at once after a mark, without retries: faster, with the same risk; (c) once job-store phase 5's confirmed send exists, a partial write makes the delivery `uncertain` and never resent.
|
||||
23. **A status check before an anycast send.** Assumed: after the dial and before the `sending` mark, on the same connection and inside the printer's slot, anycast reads `DLE EOT`. It reads a not-ready answer again 750 ms later, as `/healthz` does.
|
||||
- The read runs over the connection already open, so it never waits on its own slot.
|
||||
@@ -176,6 +182,7 @@ Before stage 3:
|
||||
- A timeout or no answer sends anyway: a timeout is never a printer fault, and a printer busy with an earlier job may answer late.
|
||||
- Unicast and multicast do not check, as today. The check and `/healthz` share one settle function, moved from the server to `printer`, which takes the read to use.
|
||||
- Without the check, a printer out of paper most likely still takes the connection and the bytes, so the main anycast case would fall into question 22's path. That is an inference, and a paper check tests it before stage 3 starts. With the owner's OK, one short receipt goes unicast to the TM-T88IV with its paper out (or its cover open). Does the printer take the connection and the bytes, and print the receipt once the paper is loaded?
|
||||
- docs/plans/remote-printers.md decision 19 reads a remote printer's status through the same settle function at the agent, and this paper check decides the anycast check there too.
|
||||
- Trade-off: one status round trip per attempt, and up to 0.75 s more in the slot. An auto-recoverable error, such as a print head that is too hot, clears by itself, so waiting for it may beat failing over.
|
||||
- Alternatives: no check; or a check on every send, unicast included, which changes today's behaviour of buffering a job for a printer that is briefly offline.
|
||||
24. **A printer marked down.** An anycast delivery joins the lane of its first printer. When that printer is dead, the delivery waits behind every earlier delivery on that lane, and each of those retries before it fails. That is about 27 s each at the defaults when dials time out (four dials of 5 s, plus waits of 1, 2 and 4 s), or about 7 s when they are refused. Ten unicast jobs for a dead `office` would delay an `alerts` job by 4-5 minutes while `default` sits idle. Once the dead lane is full, `Submit` would refuse the anycast job. Anycast would fail in the very case it exists for. Assumed:
|
||||
@@ -416,14 +423,12 @@ INVARIANTS
|
||||
|
||||
ON ACCEPTANCE
|
||||
When the owner accepts this plan, these edits are made:
|
||||
- design.md: Planned next item 2 says the plan is written and its questions await the owner.
|
||||
- design.md: Planned next item 2 records the decisions.
|
||||
- docs/plans/formatters.md: its open question goes, answered by the example under Architecture, ROUTING RULES. Its phase 5 items for a second printer and for per-model line spacing go, and so do the phase 5 Tests for the printer pool (the migration test from `[printer]` to `printers.default`, unknown keys in `[printers.x]`, two queues in parallel). Each points here.
|
||||
- docs/plans/job-store.md:
|
||||
- COMPATIBILITY's "Job status keeps its shape until there are several printers", and the DELIVERIES AND SEVERAL PRINTERS bullet that gives the `deliveries` array and leaves the job's own fields to this plan: point to question 8, under which every status gains `deliveries` from stage 1b.
|
||||
- DELIVERIES AND SEVERAL PRINTERS: the bullet on a row that stores nothing of its route, and the anycast bullet's restored list, point to question 18; the anycast bullet's failover after a mark, to question 22; "one store, with one queue and worker per printer", to question 4; a printer removed from the config, to question 5.
|
||||
- Invariant 3's "which the printers plan settles (question 23)": point to question 22. Invariant 2 reads "No byte of the job goes to the printer before its delivery's `sending` mark", since an anycast check sends `DLE EOT` before the mark.
|
||||
- Question 23: point to question 22 here.
|
||||
- Question 1's size comparison with GORM: with Expr linked, GORM's extra cost over plain SQL falls to about its own code (question 10).
|
||||
- Question 9: point to question 4's bound with several lanes.
|
||||
- Phase 2b, in case it ships after stage 3: a delivery with any `sending` mark is not cancellable, even while it waits on the next printer of an anycast list; a move takes the delivery lock (question 26).
|
||||
- PRINT ACKNOWLEDGEMENT: the TM-m50II's command list includes `GS ( H` fn 48, still unverified over port 9100. The side finding's power-on part is confirmed in Epson's guides; whether the frames reach a port 9100 client is still unverified.
|
||||
@@ -612,7 +617,7 @@ PROFILES AND STATUS PER MODEL (stages 4a and 4b)
|
||||
- `escpos.Profile` keeps `Name`, the layout family, and gains `Model` and the status capabilities (question 27). Layout fields stay shared by the three printers. `LineSpacing` comes with job-store phase 3a; `BoxLineSpacing` comes only if a paper check needs it (question 30).
|
||||
- Status: `printer.Client.Status` keeps `DLE EOT 1-4`, one request at a time. On a profile whose near-end comes from `GS r 1`, it sends that last, only when online and ready, with its own deadline and decoder, and closes the connection after a missed answer (question 28). The anycast check never sends it. `Ready()` and `Normalized()` gain question 29's bits.
|
||||
|
||||
THE SEAM FOR REMOTE PRINTERS (named, not built; question 6)
|
||||
THE SEAM FOR REMOTE PRINTERS (named, not built; question 6, settled)
|
||||
- Each printer is one value built by one constructor in internal/app from its table. It implements `printqueue.Sender` (`Send` with `beforeWrite`, and stage 3's checked send) and `server.Printer` (`Status`). Today it is a `*printer.Client`; docs/plans/remote-printers.md adds one backed by an agent's link, chosen by its `agent` key (its decision 16).
|
||||
- The contract a remote printer keeps is printqueue's send contract (stage 3):
|
||||
- `beforeWrite` runs only once a connection to the printer itself is open, wherever that is, so the `sending` mark and "nothing sent" stay true across the agent.
|
||||
@@ -641,7 +646,7 @@ CONFIG, PACKAGING, DOCKER
|
||||
|
||||
### Stage 1a: Named printers, a lane each
|
||||
|
||||
**Goal.** `[printers.<name>]` tables add printers beside `[printer]`, the printer `default`. Each printer has its own client, renderer and lane, and `preview --printer` lays a job out for any of them. No route reaches a named printer yet: every job still prints on the default printer, and a config with `[printer]` alone prints as today. Needs job-store stage 1c. Questions 1-6.
|
||||
**Goal.** `[printers.<name>]` tables add printers beside `[printer]`, the printer `default`. Each printer has its own client, renderer and lane, and `preview --printer` lays a job out for any of them. No route reaches a named printer yet: every job still prints on the default printer, and a config with `[printer]` alone prints as today. Needs job-store stage 1c. Questions 1-5, and 6, settled.
|
||||
|
||||
**Work.**
|
||||
|
||||
@@ -791,15 +796,16 @@ internal/app/uberbringer
|
||||
|
||||
### 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. Questions 10-19.
|
||||
**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. Questions 11-16, 18 and 19, and 10 and 17, settled.
|
||||
|
||||
**Work.**
|
||||
|
||||
go.mod
|
||||
- `github.com/expr-lang/expr` at its latest stable release. Run govulncheck. `go generate` regenerates THIRD-PARTY-LICENSES.md and internal/app/uberbringer/licenses_embed.md.
|
||||
- `github.com/expr-lang/expr` at its latest stable release, unless docs/plans/templates.md stage 1 has added it (question 10). Run govulncheck. `go generate` regenerates THIRD-PARTY-LICENSES.md and internal/app/uberbringer/licenses_embed.md, in the commit that first links Expr into the binary.
|
||||
|
||||
internal/pkg/rules (new)
|
||||
- rules.go: the generic engine (Architecture, ROUTING RULES).
|
||||
internal/pkg/rules (new, unless docs/plans/templates.md has added it; its decision 1)
|
||||
- options.go: `Options(zone)` and the iteration guard (question 17), unless templates stage 1 has added them.
|
||||
- rules.go: the generic engine (Architecture, ROUTING RULES), unless templates stage 2 has built it.
|
||||
|
||||
internal/pkg/routing (new)
|
||||
- env.go: `Env` with stage 2a's variables and their `expr` tags (Architecture, THE ENVIRONMENT), built from the job, `Meta.Source`, the job's size, the acceptance time and the zone.
|
||||
@@ -843,7 +849,7 @@ Docs
|
||||
- docs/development.md § Package layout: `internal/pkg/rules` and `internal/pkg/routing`.
|
||||
- docs/api.md: job status `route`; `queue_full` only when every printer of the route is full; a delivery `failed` with "printer's queue is full".
|
||||
- docs/swagger.json regenerated.
|
||||
- design.md: "Jobs remember their source", which now names the route; the stack choices, with Expr's version, the size it adds, and no variable for `[routing]`.
|
||||
- design.md: "Jobs remember their source", which now names the route; the stack choices, with no variable for `[routing]`, and Expr's version and the size it adds unless templates stage 1 has recorded them.
|
||||
- CLAUDE.md: the layout and the imports (routing → rules, printqueue, receipt; rules → Expr; internal/app → routing).
|
||||
- docs/plans/job-store.md, while it is open: DELIVERIES AND SEVERAL PRINTERS and stage 1d's RECORDS name the route columns (question 18).
|
||||
- CHANGELOG: under Added, routing rules and groups, and `route` in job status; under Changed, a multicast job is refused only when every printer's queue is full.
|
||||
@@ -888,7 +894,7 @@ internal/app/uberbringer/server
|
||||
- schema_test: the `route` enums.
|
||||
|
||||
**Done when.**
|
||||
- The full gate passes; govulncheck is clean; the snapshot builds every target, and design.md records the size Expr adds.
|
||||
- The full gate passes; govulncheck is clean; the snapshot builds every target, and design.md records the size Expr adds, if this stage linked it first.
|
||||
- Paper, with the owner's OK, once a second printer is on hand, one short receipt at a time, waiting for his report after each: a multicast rule prints one receipt on both printers, each with its own cut; then a unicast rule sends a note to the second printer only. With one printer only, this check waits, and the stage is done on the fakes.
|
||||
|
||||
### Stage 2b: Reloading the rules
|
||||
@@ -902,7 +908,8 @@ internal/app/uberbringer
|
||||
- the load helper, compiling the rules with the running `format.timezone`; a file that fails is logged at ERROR and changes nothing;
|
||||
- every rule's `to` and every group member must name a printer that has a lane, or the whole reload is refused at ERROR and the old set kept; `broadcast` resolves to the printers that have lanes;
|
||||
- each other section that changed is logged at WARN by its name only, as needing a restart;
|
||||
- then the rule set and the groups are swapped as one value, and one INFO line gives the number of rules.
|
||||
- then the rule set and the groups are swapped as one value, and one INFO line gives the number of rules;
|
||||
- if docs/plans/remote-printers.md stage 2 has shipped, `[agents]`' `tokens_since` takes effect too (question 20).
|
||||
|
||||
internal/pkg/config
|
||||
- A comparison of two configs that leaves `[routing]` out and names the sections that differ (name assumed).
|
||||
@@ -922,6 +929,7 @@ Docs
|
||||
- a new rule set routes the next job; queued deliveries keep their routes;
|
||||
- a file with a bad rule keeps the old set and logs ERROR;
|
||||
- a changed printer is logged as needing a restart and not applied;
|
||||
- a later `tokens_since` refuses that agent's older tokens at once, if remote-printers stage 2 has shipped;
|
||||
- a reload that adds `[printers.new]` with a rule `to = "new"` is refused, and so is a group naming a printer with no lane;
|
||||
- a changed `format.timezone` is not applied, and the rules compile with the running zone;
|
||||
- the WARN names the changed sections, such as `api` and `ntfy`, and holds no secret, credential or topic.
|
||||
|
||||
Reference in new issue
Block a user