Branch CI no longer runs the GoReleaser snapshot build. test.yml lints, tests and runs `goreleaser check`, which validates the release config without compiling; release.yml stays the only workflow that builds, and only for v* tags whose commit is on main. `make check` mirrors this with a release-check target, and `make snapshot` remains for local packaging checks. 0.2.0 is not yet released, so its notes now say it ships under EUPL-1.2: the licence entry moves into the 0.2.0 section, dated 2026-11-30, and README states that releases up to 0.1.2 were published under AGPL-3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7.0 KiB
7.0 KiB
Ü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 describes how to use it.
Why
Scripts and services on the owner's network send short JSON jobs, and one
Epson receipt printer prints them. The daemon replaces the 0.1 one on the
same endpoint, POST /api/v1/print behind nginx, and 0.1 installs are
deployed. It is one static binary with no database, sized for receipt rates
on one printer.
client ─HTTPS─▶ nginx ─▶ server ── validate ──▶ printqueue (memory, 1 worker)
│ │ receipt.Render: whole job
│ │ to bytes, images via safehttp
│ ▼
└─ /healthz ──────▶ printer.Client ─TCP 9100─▶ printer
(one connection at a time)
Decisions
- One printer per instance. The config names one printer, and its client holds one connection to it at a time, shared by sends and status reads. A second printer means a second instance with its own config and port. The planned TM-T88VII and TM-m50II (owner, 2026-11-29) have the same geometry as the TM-T88IV, so a single profile default covers all three.
- The queue lives in memory, on purpose. ESC/POS gives no
acknowledgement of what has printed. A queue replayed after a crash could
therefore print a receipt twice. A lost job, by contrast, shows as failed
or unknown, and the client can send it again. Waiting jobs are marked
failed at shutdown. After a crash their IDs answer
job_not_found. One worker keeps jobs in submission order, and the history is capped byqueue.history. - Render, then send. The handler validates the whole job, and a
400lists every problem. The worker then renders the complete receipt, images included, to one byte stream that starts with a printer reset (ESC @). It sends that stream over one connection. A failure before the send, such as a broken image, costs no paper and leaves no half-printed receipt. A retry resends the same bytes and does not render again. A send that fails part-way can print part of a receipt twice. That is accepted, because retries are what let a job survive a printer that is briefly offline. - Text in, code page out. Clients send UTF-8, which is transcoded to
printer.codepage. The default is CP437, for the box drawing and shading the owner prints (owner, 2026-11-29). Control characters are stripped, so data can never become a printer command. Only therawelement sends bytes as given. - Profiles set the layout, and the default is the narrower one. Columns
are the profile's dots per line divided by the glyph width; nothing
hard-codes 42 or 512. The first paper test ran the 576-dot
tm-t20profile on the TM-T88IV, which has 512 dots, and the printer broke words at its own edge (seve/ral). A profile wider than the printer breaks words, while a narrower one only shortens lines. Sotm-t88(512 dots, 42 columns) is the default. - Status is read in a way that tolerates a busy printer.
/healthzsends DLE EOT 1 to 4 over the same connection slot that sends use.- The DLE EOT 2 bits (cover open, paper-end stop) are cleared while DLE EOT 1 says online. Epson printers go offline for both causes, and a TM-T88IV reported a stale cover-open bit while cutting.
- A not-ready reading is re-read 750 ms later.
- A read cut short by our own deadline is
timeoutwith503. It never counts as "status unsupported", because an unknown state must not look healthy. - A printer that never answers status gets
200unknown. - The TM-T88VII does not report paper near-end through DLE EOT 4.
- Health is for monitors.
/healthzanswers200when the printer is ready, or when it cannot report status. It answers503when a job could not print now: the printer is unreachable, not ready or timed out. A503from it is a refusal: it is logged at WARN by the request line and never sent to Sentry. - Images are fetched by the worker, through an SSRF guard. A slow or
broken image URL holds no HTTP request and shows up as a
failedjob.safehttpchecks the resolved address at connect time, so DNS rebinding and redirects cannot reach loopback, private, link-local or cloud metadata addresses. Exceptions are configured explicitly (images.*). Time, size, pixel and height limits bound each image. - Errors are flat JSON with a stable code. The shape is
{"error", "code", "details"}.codeis the contract with clients, anderroris for people. A refusal is answered and never logged as a failure. An unexpected error or panic is logged once and reported to Sentry once, without the body or theAuthorizationheader. - What stays compatible with 0.1. The endpoint, the HS256 tokens and the
config keys stay as they were. The 0.1 body and its plain-text answer do
not. A 0.1 body gets a
400that points to the migration table, instead of being translated. Tokens are read only from the header, because tokens in query strings end up in proxy logs. - Stack choices (owner, 2026-11-29):
- Fiber v3 instead of Echo.
- TypeID (UUIDv7) job and request IDs instead of snowflakes. They sort by time and need no node configuration.
- An Alpine Docker image.
- Packaging. The release tarballs are built for linux amd64, armv6, armv7
and arm64.
install.shsets up nginx (TLS,X-Real-IP), acme.sh and the sandboxed unit frompackaging/. The daemon binds 127.0.0.1 by default and serves no TLS itself.
Planned: formatters
Layout blocks and modules, ntfy among them, that turn plain input into
receipts. The plan is docs/plans/formatters.md. Decided so far (owner,
2026-11-29):
- ntfy is an input: its notifications are printed. The server is self-hosted at a public URL, the subscriber authenticates with a token, and attachments come from a public host, so image fetches need no private-network exception.
- Which priorities print is configurable per subscription. By default every priority prints, and priorities 1 and 2 print in a compact form.
- On
/print, characters the code page lacks fold to ASCII look-alikes (smart quotes, dashes, the ellipsis), and an emoji sequence prints as one?. Today each such character prints as?. - Labels are in English. The footer's time zone and date format come from the config.
Deferred
- Paper near-end on the TM-T88VII, which
GS r 1reports. Add it when that printer arrives. - Several printers from one instance, through routing or a pool. Until then, run one instance per printer.
- A durable queue. It needs a way to tell which receipts printed before a crash.
- 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.