Record the owner's acceptance of the templates plan
Security / Vulnerability check (push) Successful in 41s
Test / Lint and test (push) Successful in 2m12s

The owner accepted every proposed default of docs/plans/templates.md on
2026-12-01. Its open questions become numbered decisions, without the
alternatives, and design.md's Planned next item 5 records them.

The plan's acceptance edits are made: formatters.md's phase 5 points to
the plan for user templates and webhook sources; printers.md's rules
package also exports the shared compile options, its environment gains
template and the source hook:<name>, and its rule-visibility and reload
questions name the templates plan; blocks.md says templates do not need
the group; job-store.md's duplicate check takes webhook deliveries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 09:30:08 -06:00
1 parent 4012018e96
commit c778c3f983
6 files changed
+111 -129

No files matched your search

+5 -2
View File
@@ -121,6 +121,7 @@ Before stage 2a:
- A digest's `priority` is its highest row's, and its `topics` and `tags` the union of its rows'.
- `topic`, `topics` and `tags` also print on a card, and a topic can be a secret. They are in the env because routing notifications by them is the main use. The facts are used at `Submit` only: they are never kept in the job's status, logged, stored or sent to Sentry, and neither is the env or an Expr run-time message (question 15).
- Printer readiness stays out. Reading it at `Submit` would wait for each printer's connection slot, and flap with the passing states Epson printers report while cutting. It would come at the wrong moment, since the job prints later, and give another answer in a dry-run or after a restart. Only anycast acts on it, when it sends (questions 23 and 24).
- 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.
@@ -149,6 +150,7 @@ Before stage 2b:
- Deliveries already queued keep their routes.
- 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).
- 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").
@@ -501,7 +503,7 @@ HEALTH (stage 1b)
ROUTING RULES (stages 2a-2c)
- Packages:
- `internal/pkg/rules` (new): a generic engine, importing only Expr. `Rule[A]` (`Name`, `Order`, `When`, `Enabled`, `Action`). `Compile[E, A]` compiles every rule against `E`'s zero value with question 17's options and joins every error, each naming its rule and position. `Set.Match(env)` returns the first enabled rule in `order` whose `when` is true, with the runtime errors of the rules before it. `Set.Explain(env)` gives every rule's result, error or "disabled", for the dry-run. `Engine` holds the current set behind an `atomic.Pointer`, with `Swap`, `Match` and `Explain`. Templates share it later (design.md, Planned next item 5).
- `internal/pkg/rules` (new): a generic engine, importing only Expr. `Rule[A]` (`Name`, `Order`, `When`, `Enabled`, `Action`). `Compile[E, A]` compiles every rule against `E`'s zero value with question 17's options and joins every error, each naming its rule and position. `Set.Match(env)` returns the first enabled rule in `order` whose `when` is true, with the runtime errors of the rules before it. `Set.Explain(env)` gives every rule's result, error or "disabled", for the dry-run. `Engine` holds the current set behind an `atomic.Pointer`, with `Swap`, `Match` and `Explain`. It also exports `Options`, the compile options and the iteration guard that docs/plans/templates.md shares; whichever of this stage and that plan's stages comes first builds what it needs of the package (its decision 1).
- `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.
- 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.
@@ -567,7 +569,7 @@ THE ENVIRONMENT (stages 2a and 2c; question 16)
| Variable | Type | Stage | Value |
|---|---|---|---|
| `source` | string | 2a | `print`, `module:<name>` or `ntfy:<subscription>`, as job status shows it |
| `source` | string | 2a | `print`, `module:<name>`, `ntfy:<subscription>` or, from docs/plans/templates.md stage 4, `hook:<name>`, as job status shows it |
| `module` | string | 2a | the module's name on a module route; else empty |
| `subscription` | string | 2a | the subscription's name for its jobs; else empty |
| `copies` | int | 2a | the copies the job prints, 1-5 |
@@ -584,6 +586,7 @@ THE ENVIRONMENT (stages 2a and 2c; question 16)
| `priority` | int | 2c | 1-5 for a notification (3 when it gives none); a digest's highest row's; 0 for other jobs |
| `tags` | list | 2c | a notification's tags; the tags of a digest's rows; else empty |
| `digest` | bool | 2c | true for a digest |
| `template` | string | 2c | the template the job was built through, by its module route, an ntfy rule or a webhook, once docs/plans/templates.md stage 1 has shipped (its decision 13); else empty |
Rules the probe compiled and ran against this env: `source == "ntfy:alerts"`; `source startsWith "ntfy:" && priority >= 4`; `"urgent" in tags || priority == 5`; `weekday in ["sat", "sun"] || clock >= "22:00" || clock < "07:00"`; `"image" in types && bytes > 100000`; `now.Hour() >= 22`; `any(tags, # startsWith "kitchen")`; `topic matches "^alerts-"`; `module == "note" && copies > 1`.