Plan the job store and record the features planned next
Security / Vulnerability check (push) Successful in 42s
Test / Lint and test (push) Successful in 2m2s

docs/plans/job-store.md plans a persistent job store and image
previews. It answers the owner's investigation of SQLite in WAL mode
against GORM, bbolt, BadgerDB and a journal, with measurements. It
covers a job state machine that never prints a receipt twice after a
crash, jobs made of one delivery per printer, cancelling a waiting job,
and the image preview. Its open questions each carry an assumed default.

design.md gains a "Planned next" section with the owner's decisions so
far: several printers routed by Expr rules (unicast, multicast,
broadcast and anycast with failover), remote printers through an agent
over Fiber WebSockets and msgp, more blocks, Expr templates and rules,
and the ntfy subscriber's WebSocket transport, replay limits and
publish endpoint. The planned job store and printer items leave the
Deferred list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-11-30 22:13:15 -06:00
1 parent 0c88b4ffd5
commit 80a65f6083
2 files changed
+1101 -28

No files matched your search

+64 -28
View File
@@ -1,8 +1,9 @@
# Überbringer: design
Status: version 0.2.0, checked on paper on the TM-T88IV. Next is the
formatters work in `docs/plans/formatters.md`. This page records why the
daemon is shaped as it is. README.md and docs/api.md describe how to use it.
Status: version 0.2.0, checked on paper on the TM-T88IV. Next is the work
under Planned next, each feature in its own plan in `docs/plans/`. This
page records why the daemon is shaped as it is. README.md and docs/api.md
describe how to use it.
## Why
@@ -433,33 +434,68 @@ the ntfy subscriptions. What is left, phase 5, is built only when a need
appears. Labels are in English, and the footer's time zone and date format
come from the config (owner, 2026-11-29).
## Planned next (owner, 2026-11-30)
Formatters phase 5 is split into features of their own, each planned in
`docs/plans/<feature>.md` before anything is built, in this order. A plan
not yet written is described here until it is.
1. **Job store and print previews**: `docs/plans/job-store.md` (written;
its open questions await the owner). It includes cancelling a waiting
job, `Queue.Cancel`, so that an ntfy `message_delete` can cancel one,
and a job made of one delivery per printer.
2. **Several printers**: `docs/plans/printers.md` (being planned).
- Printers are named TOML tables, with named groups.
- Routing is done by rules written in Expr
(`github.com/expr-lang/expr`), modelled on Kanrisha's policy engine:
compiled once against a typed environment, ordered, reloaded
atomically, with a dry-run.
- A rule sends a job unicast (one printer), multicast (each printer of
a set), broadcast (every printer) or anycast (one printer of an
ordered list).
- Anycast is a priority list with failover: the first printer, on
failure the second, then the third.
- A multicast or broadcast job is one job with several deliveries, one
per printer, each tracked on its own.
- `?printer=` on a request is a direct unicast. A job no rule matches
goes to the default printer, so a single-printer config keeps
working.
- Also covered: `/healthz` per printer, a printer per ntfy subscription
through rules, per-model line spacing, and the TM-T88VII's paper
near-end (`GS r 1`).
3. **Remote printers**: `docs/plans/remote-printers.md` (not yet written).
Printers on other networks are reached through an Überbringer agent
next to them. The agent dials out to the main instance over HTTPS and
WebSockets, using Fiber, and speaks MessagePack through
`github.com/tinylib/msgp`, whose generator is pinned in `go.mod` and
run as `go tool msgp`. NATS JetStream, embedded etcd and VPN tunnels
are not used for this.
4. **More blocks**: `docs/plans/blocks.md` (not yet written): table (with
`╤╪╧` junctions), banner, group, inline spans and a custom rule
character, each built when needed.
5. **Templates and rules for webhooks and ntfy subscriptions**:
`docs/plans/templates.md` (not yet written). Templates and rule actions
use Expr, as in Kanrisha, sharing the routing engine. Webhooks come
after templates, since a webhook needs a template to become a receipt.
6. **ntfy**: `docs/plans/ntfy.md` (not yet written).
- The subscriber prefers ntfy's WebSocket endpoint (`/<topics>/ws`),
falls back to the JSON stream, and the transport is chosen per
subscription in the config.
- It handles ntfy's replay limits: `X-Messages-Truncated: 1` on a
replay cut at 10 MB, and `429` with error code `42905` when the daily
bandwidth budget is spent.
- Resuming by `since=<message ID>` is checked in ntfy's source first,
including what ntfy does once that ID has expired from its cache.
- The README advises, for ntfy behind Caddy, `behind-proxy: true` in
ntfy, and a `stream_close_delay` so that Caddy's reloads do not drop
streams.
- Also covered: an ntfy-compatible publish endpoint.
Once every phase 5 item has its plan, `docs/plans/formatters.md` folds
into this page and goes.
## Deferred
- **Paper near-end on the TM-T88VII**, which `GS r 1` reports. Add it when
that printer arrives.
- **Several printers from one instance**, through routing or a pool. Until
then, run one instance per printer.
- **A persistent job store and print previews** (requested by the owner on
2026-11-30; to be planned in full in `docs/plans/` before any of it is
built):
- Jobs stored on disk, so queued jobs, statuses and history survive a
restart. The owner's first choice is GORM on SQLite. Before anything
is built, the plan investigates SQLite in WAL mode, through GORM or a
lighter layer (owner, 2026-11-30): its disk writes per job, what each
`synchronous` setting and checkpoint costs and guarantees, and whether
it can record a job as printed durably at the moment its bytes are
sent. The plan weighs it against key-value stores such as bbolt and
BadgerDB on the same terms, and the choice is recorded here. Release
builds use `CGO_ENABLED=0`, so any store must be pure Go (for SQLite,
for example `github.com/glebarez/sqlite`), and its files belong in the
unit's `StateDirectory`, `/var/lib/uberbringer`, the only directory it
may write. The plan must also say how to tell which receipts printed
before a crash, so a restart never prints a receipt twice.
- A print preview as an image: a digital test print of a job that shows
what the paper would look like, without printing. Formatters phase 1 adds
a text preview (`POST /api/v1/preview`); this goes further, rendering
text, boxes, barcodes, QR codes and images to a picture.
- Previews of submitted jobs, read back from the store by job ID.
- **Printer alerts sent out to ntfy** (paper out, cover open). They have not
been requested. Printing incoming ntfy messages is part of the formatters
plan.