c60d7531b2102e6aa1c18dadbceeaac458fc600e
18
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2e291817d3 |
Record that API inputs go in the JSON body
The owner decided that across the whole API an input goes in the request's JSON body, never in a query parameter. The path holds only a resource's ID, or a fixed word that names the route, as last, failed and uncertain do for the reprint routes, and a GET takes no inputs beyond its path. design.md records the decision beside the error shape and lists what breaks it today, for a later change to fix: the module routes' copies and printer query parameters and the invalid_query code that refuses them, the printers plan's ?printer=, and the filters and paging the job-store plan's phase 2 puts in the job list's query. CLAUDE.md's route rule says the same, on the owner's word. The code, the printers plan, api.md and swagger.json are unchanged here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d3c3025e64 |
Record a job done only once the printer confirms it
Breaking: a job reads done only once the printer has confirmed that it ran it, and holds the printer's connection until then. A job written in full that the printer does not confirm within printer.write_timeout now reads uncertain and is not sent again; before, it read done. Before each job, nothing is sent until the printer answers that it can print, so with its cover open or no paper a job is retried and fails, with no sent_at, as when the printer is unreachable, where before it read done. Receipts that take longer than write_timeout to print need a larger one. With confirmation the daemon also turns the printer's automatic status off (GS a 0) before each job and before its confirmation, so another client that relies on automatic status from the same printer stops getting it. printer.confirm = false keeps the old meaning of done and sends none of this. The third paper check of the job store showed why: with the TM-T88IV's cover open, Windows took all of a 128 KB receipt into its send buffer, so the job read done; the daemon stopped, and once the cover closed only the first third printed, without its cut. The printer was then left inside the image command, waiting for the rest, until it was switched off and on. The daemon now turns on the printer client's confirmation. The queue treats an unconfirmed send as written but unknown: it records the delivery uncertain, with an error that says the printer did not confirm it and that it may have printed in full, in part or not at all, logs it at WARN with the printer, and neither retries it nor reports it as a failure. Its commit is not synced: lost, it rolls back to sending, which the next start turns uncertain too. A printer that is not ready gives a plain error before the sending mark, which the queue retries as a failed dial. The new key printer.confirm, on by default, turns confirmation off for a printer that does not answer GS r with bits 4 and 7 clear, or does not answer DLE EOT on receipt; only the TM-T88IV is checked. The key's comments in config.go and the example config say what it sends and needs. docs/api.md warns that raw bytes which make the printer answer can be taken for the confirmation, and says that /healthz answers 503 timeout while a job holds the connection. It and design.md say that each job waits about 200 ms for answers still owed, for DLE EOT 1 to say that the printer is online, and for no answer to come late. design.md says why each connection opens with DLE EOT 1, GS a 0 and GS r 1, and names what stays open: a raw job holding a command answered with bits 4 and 7 clear, such as GS r, GS I, ESC v or ESC u 0, with printing after it, and an answer taken for the ready answer that is not it, one still queued when the fence arrived or one owed from before a late DLE EOT answer that stood in for the fence, followed by a pause of more than 100 ms while the printer reads online, as might happen during the TM-m50II's feed and cut at cover close. It relies on the printer answering DLE EOT on receipt and running GS a 0 in order, unverified beyond the TM-T88IV until stage 4a's raw-byte probe, and now says a send that fails part-way can print a whole receipt twice. The unit and install.md give the stop timeout with and without state.dir: without it the job being sent runs on from its rendering, image fetches included, up to the job's 2-minute cap, so such hosts keep systemd's default or set state.dir. configuration.md says the online check can add 2 s to write_timeout. The printers plan says what Send now does before a job, and its table of what a failed send can mean gains the ready wait and the confirmation. The tests' fake printers answer DLE EOT 1 and GS r 1 as an online printer with paper does; a test runs the daemon against one that answers that it is ready but never confirms the job. On paper, a receipt read done 884 ms after it was written, when the printer answered, and a receipt whose daemon was killed while it waited, with the cover open, read uncertain after the restart and printed once, cut short. With GS a 0 and DLE EOT 1, a receipt printed once with nothing extra and read done 888 ms after it was written; after a power cycle, with /healthz polled every 250 ms, one sent with the cover open waited 15.7 s with nothing sent and printed once, cut once, when the cover closed. With the fence, a receipt printed once with nothing extra and read done 921 ms after it was written. Part of stage 1d of docs/plans/job-store.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5cc4614ad7 |
Keep print jobs on disk in state.dir
Breaking: with state.dir set, jobs still waiting when the daemon stops or crashes print after the next start, in order and however old, instead of being marked failed or forgotten; a client that resends such jobs must stop. The Docker image sets state.dir, so a container keeps its jobs in /var/lib/uberbringer, and loses them with the container unless a volume is mounted there. The owner decided that jobs survive a restart and that a restart never prints a receipt twice. When state.dir is set, the daemon now opens the SQLite job store there, jobs.db, and the queue restores it before the subscriptions are made and before anything is served, so restored jobs go ahead of new ones and a second daemon on the directory stops before it reads the subscriptions' state. Without state.dir the queue keeps its jobs in memory, as before. The store closes once the queue has stopped. A job's sending mark is synced before its first byte, so one caught mid write reads uncertain after the restart and is never sent again; a job that had not reached the printer prints once. A store that cannot be opened stops the start with an error naming the file, rather than starting empty and forgetting which receipts are in doubt. The unit gains UMask=0077, so the store's files are its user's alone, and says why systemd's 90 s stop timeout is enough; the Dockerfile and docs/docker.md ask for --stop-timeout 40. design.md replaces "The queue lives in memory" with the store, the state machine, the sync policy, store failures, stage 1a's numbers, and that the ARM builds ship the store untested on ARM hardware. install.md and docker.md say how to set aside a store that will not open; configuration.md, api.md, cli.md and ntfy.md say what survives a restart. The license notices gain the driver's modules. TestServeRestart runs the daemon twice on one directory: jobs queued when the first run stops, its printer refusing connections, print in order after the restart, ahead of a new job, and a job seeded in sending between the runs reads uncertain and never reaches the printer. Part of stage 1d of docs/plans/job-store.md (decisions 14 and 15). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2926a69598 |
Check that libc stays at the version the SQLite driver requires
modernc.org/sqlite is C transpiled to Go against one version of modernc.org/libc, and its go.mod names that version exactly: v1.80.1 for v1.64.0, while libc's latest is v1.82.14. A newer libc breaks the driver without a compile error, and a routine go get -u would move it. The owner accepted holding libc there as the one exception to taking each dependency at its latest stable release; it moves only with the driver. tools/libcpin compares the libc that go list -m selects with the one go mod graph shows the selected modernc.org/sqlite requiring, and fails with the go get that restores it. It runs as go run ./tools/libcpin, so it works from PowerShell and in CI alike. test.yml and make check run it after go mod tidy -diff, CLAUDE.md lists it in the gate and records the exception beside the dependency rule, and design.md records it under the stack choices. Moving libc to v1.82.14 with go get made the check fail as it should; the change was not kept. Part of stage 1d of docs/plans/job-store.md (decision 13). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f6323aa854 |
Keep print jobs in the SQLite job store
The job store now implements printqueue.Store on its one connection, so the queue can keep jobs on disk. A mutex serialises every call, since a transaction and the synchronous setting belong to the connection. - Add inserts the job, its deliveries and its content in one transaction. - Sending updates the delivery's row alone, at synchronous FULL, so the mark is on disk before the first byte goes to the printer. - Finish updates the delivery's row and drops exactly the jobs, deliveries and contents the queue names, in one transaction, synced when the queue asks, as it does for a failure. - Load turns every delivery in sending into uncertain and reads the jobs and deliveries, in one commit. It reads each content's length, not the content, and refuses a delivery whose job is gone or whose state this binary does not know; its errors name the file. - Job reads one job's content. - Idle runs a passive checkpoint while the queue has nothing to do, once 64 commits, about 20 jobs, have gathered since the last. The queue is idle after nearly every job when receipts come one at a time, and a checkpoint syncs the log and the database, and the next commit the log's header: checkpointing each time would turn a job's one sync into four. A synced commit sets synchronous FULL, commits, and returns to NORMAL even when the commit failed. Times are stored as Unix nanoseconds, so they read back to the nanosecond in UTC. Errors name the operation and the job's or delivery's sequence number, never a value. A test hook runs inside each commit and reads PRAGMA synchronous and total_changes(), so the tests see which commits are synced, the schema step included, and that Sending, and a Finish that drops nothing, change one row. With automatic checkpoints off, a job of 2 KB appended 8.6 WAL frames on the workstation; the test holds it to at most 16. Unique jobs' references are kept in the next commit. Nothing uses the store yet. Part of stage 1d of docs/plans/job-store.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6e47cb713e |
Add a SQLite job store that opens, checks and locks its file
Jobs are to survive a restart in a SQLite database, jobs.db in the state directory, through modernc.org/sqlite v1.64.0 (SQLite 3.54.1), the latest release, which is pure Go and builds with CGO_ENABLED=0. It requires modernc.org/libc at exactly v1.80.1, older than libc's latest; the owner accepted that pin as the one exception to taking dependencies at their latest stable release, and CLAUDE.md and design.md record it here. The other modules it brings are mathutil, memory, go-humanize, go-strftime and bigfft, at the versions it asks for; bigfft has no tagged release. The new package internal/pkg/jobstore opens the database in this order: - It creates the file 0600 if it is missing, since SQLite gives its log the database's mode. An existing file is never opened outside SQLite, since closing any descriptor of it would drop the locks the process holds. - The connection runs its pragmas, in this order: exclusive locking before the first read, so the log's index stays in memory and no -shm file is made; auto_vacuum NONE; WAL; synchronous NORMAL; temporary tables in memory; a 4 MiB journal_size_limit; secure_delete FAST. A connector runs them, since the driver's own _pragma list sorts them by name and would set the locking mode only after the first read, leaving a mapped -shm file on every open but the first. - PRAGMA quick_check reads every page, so a damaged file fails at start rather than when a statement meets the page mid-run. - A user_version newer than the binary's is refused, naming both. - Each schema step runs in one synced transaction that also sets user_version. Version 1 creates jobs, deliveries, content and refs. - It writes once, so a store that cannot be written fails at start and the file stays locked; a second Open of the directory, from any process, fails at once with SQLITE_BUSY. Every error from Open names the file. The URI escapes the path, so a directory with a space, "#", "?" or "%" in its name works. The store syncs with fdatasync where the platform has it, as on Linux. The lock test runs the second Open in a child process, the test binary run again, so the lock tested is the file system's. A test reopens the store three times and finds no -shm file and exclusive locking each time. Nothing uses the store yet. Part of stage 1d of docs/plans/job-store.md (decisions 1, 3 and 13). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
60baa843ef |
Cross-compile the ARM targets in CI and the gate
Releases ship linux/arm (ARMv6 and ARMv7) and linux/arm64 binaries built without cgo, but until now nothing compiled those targets before a tag was pushed. The job store's SQLite driver is Go transpiled from C, with code of its own for each architecture, so a build that works on amd64 can fail for ARM. test.yml and make check now build the daemon for linux/arm with GOARM=6 and for linux/arm64, with CGO_ENABLED=0, and discard the binaries. The ARMv6 build stands for ARMv7 as well. CLAUDE.md lists the two builds in the gate, run from Git Bash, since PowerShell cannot set variables for one command. Part of stage 1d of docs/plans/job-store.md (decision 15). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0a513cb9b1 |
Let agents commit on a topic branch as they work
The owner-wide commit standards have agents commit each step of an approved series on a topic branch as it is done, so a feature lands as a series of reviewable commits. This file allowed no commit until the owner asked, which blocked that. Committing on main, landing a branch, pushing, tagging and releasing still wait for the owner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3d451eb0b7 |
Split the README into focused docs under docs/
The README had grown to 658 lines. It is now a short overview: what Überbringer is, a quick start, a table of the docs and the licence. Each topic it held has a document of its own: - docs/install.md: install.sh, what it leaves behind, and upgrading. - docs/docker.md: the image behind a reverse proxy, the env file, health checks, and the ntfy state volume and token file. - docs/configuration.md: loading, environment variables, a table of every key in every section, and what is logged. The list of log messages becomes a summary of what is logged and reported. - docs/security.md: the API secret, issuing tokens and their scopes, the header-file recipe that keeps tokens off command lines (moved from docs/api.md), the reverse proxy, image URLs, and what is never logged. - docs/ntfy.md: the ntfy subscriptions, securing the topics and the printer's token, with the token scripts unchanged. - docs/cli.md: the command line. - docs/development.md: running from source, the Go version, make targets, the gate, generated files, the layout, CI and releases. CLAUDE.md names the new docs: a config key is now documented in docs/configuration.md, and the layout and Go version in docs/development.md. docs/api.md, design.md and the job-store plan point to the docs that now hold what they referred to in the README. The release archives also carry the docs on running the daemon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0c88b4ffd5 |
Add third-party license notices, generated and embedded in the binary
THIRD-PARTY-LICENSES.md holds the license and notice files of the Go distribution and of the 35 modules that ./cmd/uberbringer links on linux amd64, armv6, armv7 and arm64, as each distribution ships them. tools/genlicenses writes it on go generate from go list -deps, so modules only the tools and tests use stay out. Beside each module's root license it takes NOTICE files and the license files in its linked packages' directories, which cover vendored code in gofiber/utils, klauspost/compress and fasthttp. Each module is listed with its version, so any dependency change needs the file regenerated. The generator fails on a module with no license file or a license it does not recognize. The same text goes to internal/app/uberbringer/licenses_embed.md, which the binary embeds and the new `uberbringer licenses` command prints. The release archives carry the file, and the Docker image keeps it with LICENSE.txt in /usr/share/licenses/uberbringer/. The Makefile's openapi and openapi-check targets become generate and generate-check. They, the CI step and the gate in CLAUDE.md check docs/swagger.json and both license files, and a test fails when a committed copy is out of date. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1335ed0687 |
Add the notify and ntfy modules and scoped tokens
Breaking: a job with a raw element prints only with a token issued with uberbringer token --raw. Every other token, every existing one included, gets 403 token_scope for it, with the raw elements in details, and keeps every other route. The notify module prints a notification card from a title, message, priority and tags, with topic, click, up to three actions, image, markdown and time as options; it decodes strictly and refuses a payload over its length caps. The ntfy module takes one ntfy message as ntfy sends it, such as the ntfy client's $NTFY_RAW, ignores fields it does not know, cuts text over the caps, and answers 204 for other events and binary bodies. Both print every message plain: one message cannot tell the first of a sequence from a replacement, since a publisher may choose the sequence ID. internal/pkg/ntfy holds ntfy's message types. Both print the same card. The priority picks the form: a dark URGENT rule and a double box, a double box headed HIGH, a single box with the title in its border, or a rule with no box. Tags print as markers in front of the title, the rest on a Tags row; links print as QR codes with their labels; attached PNG, JPEG, GIF and WebP images print after the card. A line-level markdown subset is laid out without a dependency, keeping marks inside code spans and URLs, and emoji are removed after a few typed ones become markers. A card that cannot be laid out prints as a plain receipt, and the server logs the fault once at ERROR and reports it to Sentry once. [ntfy.format] and [ntfy.markers] shape the cards; the markers table is a setting with the user's own keys, also settable as UBERBRINGER_NTFY_MARKERS=name=value,... uberbringer token --modules issues a token limited to those modules' print and preview routes, job status and the module list; each route in the table says which tokens it takes, and a scope claim that could read as absent makes the token invalid. image elements take optional, which also shrinks a too-wide image to the paper; a QR code that could be too wide for the paper prints with smaller modules; box takes title_bold. Submit takes a Meta whose source shows in job status and, with a copy of the request ID, in every worker log line of the job. The four ntfy cards passed on the TM-T88IV, posted as the client recipe posts them, and their bytes are pinned in TestPaperReceipts. docs/api.md describes the modules, the card and the client recipe, with tokens read from a header file; docs/swagger.json is regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3e9779f71a |
Add the list block and the module layer with the note module
The list block prints items with a dot, dash, number or checkbox bullet,
wrapping a long item with a hanging indent; a checkbox list ticks its
done items as [√], or [x] on code pages without √. It stands alone or
inside a box, and its items, bullet and done fields carry their enums
and limits as jsonschema tags.
internal/pkg/modules holds modules that build ordinary jobs from their
own payloads: a registry by name, an Env with the clock, time zone and
time layout, strict payload decoding that reports every problem, ErrSkip
and PayloadError. The note module prints a boxed note with an optional
checklist and a time stamp in the footer.
Three routes join the route table: POST /api/v1/print/{module} and
POST /api/v1/preview/{module}, which take ?copies and a reserved
?printer, and GET /api/v1/modules. Print and the module route share one
submit path, and preview shares one too. New error codes:
invalid_payload, invalid_query, unknown_printer, module_not_found and
module_failed; a module that builds an invalid receipt is logged and
reported to Sentry once. [format] gains timezone and time_layout, the
binary embeds the time zone database, and uberbringer preview takes
--module.
The note receipt passed on the TM-T88IV, and its bytes are pinned in
TestPaperReceipts. docs/api.md describes the list block, the module
routes and the note payload; docs/swagger.json is regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
bdd337e2dc |
Generate the OpenAPI document from a route table
The server registers its routes from one table in server/routes.go, and tools/genopenapi (run by go generate) writes docs/swagger.json, an OpenAPI 3.1 document, from the same table and the Go types it names. Schemas are reflected with invopop/jsonschema: descriptions from the first paragraph of the doc comments, enums and limits from jsonschema tags. Request schemas are strict, as the decoder is; response schemas allow fields added later. The daemon serves the embedded document at GET /openapi.json without a token, internal/app passes it to the server in its config, and release archives and the Docker build include it. Tests keep it honest: a golden test and a CI step fail when the document is stale, every registered route must be in the table, and the tags are held to validation, to the Go constants and to the values the handlers send. receipt.Element and printqueue.Status gain field doc comments for the descriptions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9f7c5db923 |
Move the API reference from the README to docs/api.md
docs/api.md holds the routes, elements, blocks, glyphs and error codes. README keeps the overview, installing, configuration, the command line and development, with a pointer to the API reference. The 0.1 migration section is dropped; the changelog's Breaking entries cover the 0.1 changes. Release archives include docs/api.md, and the 400 for a 0.1 job body points to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
eacd0bfd27 |
Read the config with Viper and environment variables, on Go 1.27.4
The config loader uses Viper instead of BurntSushi/toml. Every setting can also come from UBERBRINGER_<SECTION>_<KEY>, which wins over the file, and UBERBRINGER_CONFIG sets the default of --config; set empty, no file is read, so a container can run from the environment alone. Each setting is bound to its own variable, so a variable named after a section changes nothing. The file is parsed with go-toml and checked as written: unknown keys, empty tables and keys that differ only in case are errors, a UTF-8 BOM is skipped and a UTF-16 file is refused. Values are decoded strictly: durations are strings, numbers decimal, flags true or false, and a fraction for a whole number is refused. Errors name the file, the line of a syntax error and the variables that were set, never their values. `uberbringer config get <key>` prints one setting as the daemon would use it. install.sh reads body_limit, bind_ip and port through it, so the config is checked before the service restarts and Caddy proxies to the configured address. The script then waits for the daemon to answer, downloads Caddy's key and source list before replacing them, requires Caddy's own repository, keeps the Caddyfile during dpkg upgrades, detects an existing import loosely, logs Caddy's other errors, drops query strings from the access log and validates the domain and printer address more tightly. go.mod names Go 1.27.4 with no toolchain line, and the workflows check against the go line. The changelog folds the unreleased entries into 0.2.0, which is not tagged yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
92dcacb3b9 |
Install behind Caddy instead of nginx and acme.sh
install.sh sets up a fresh Debian or Ubuntu host behind Caddy, installed from Caddy's apt repository, which obtains and renews the certificate itself. The site goes to /etc/caddy/uberbringer.caddy and the Caddyfile imports it; an edited Caddyfile only gains the import line. The result is validated as the caddy user, and both files are put back if Caddy rejects it. Caddy's body limit follows webserver.body_limit, and a larger body gets the daemon's 413 body_too_large JSON. A re-run upgrades the binary, the unit and Caddy and restarts the service. The script does not migrate hosts set up by the 0.1 script. The Docker image stays a proxy-free microservice behind the operator's own reverse proxy. The README credits the pre-refactor code, written without AI, and design.md records the persistent job store and image previews as deferred work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
853e8a9910 |
Build binaries only for release tags on main
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> |
||
|
|
9b91109550 |
Adopt norn's CI, release, API and docs practices; bare module path
Test / Lint, test and build (push) Successful in 3m17s
Module
- The module path is now the bare "uberbringer"; imports read
uberbringer/internal/... The banner keeps the Gitea URL.
CI and releases
- Workflows move to .gitea/workflows: test.yml (every branch push:
gofmt, goimports, tidy, vet, staticcheck, race tests, goreleaser
snapshot), security.yml (govulncheck weekly and on main) and a hardened
release.yml (v* tags on main only, tags fetched, goreleaser pinned to
2.20.3). The broken labeler workflow is removed.
- go.mod pins toolchain go1.27.4, which fixes GO-2026-6859; workflows
check that the running Go matches it.
- .goreleaser.yaml: tidy check that never writes, reproducible file times,
prerelease: auto, a release header linking CHANGELOG.md, and archives
that ship CHANGELOG.md, the example config and the systemd unit.
- Makefile mirrors the CI gate; .dockerignore is an allowlist.
API and tests
- Every error answers {"error", "code", "details"} with a stable code from
server/errors.go; the framework's own error text is never sent.
- Panics and unexpected errors are logged and reported to Sentry once;
refusals are not logged as failures. /healthz sends no-store.
- TestRoutesConform requires auth, rate limiting and the body limit on
every /api/v1 route.
- Race-prone tests no longer rely on freed ports or sleeps; serve takes
an injected listener.
- The test config uses a placeholder secret instead of a real one.
Install and packaging
- install.sh resolves the latest release through the Gitea API, verifies
checksums, requests a certificate only when none exists, installs the
hardened packaging/uberbringer.service and writes the first token to a
0600 file instead of printing it. It is now executable in git.
Docs
- CLAUDE.md, CHANGELOG.md (0.2.0 with breaking changes and upgrade
steps), docs/design.md, and docs/plans/formatters.md for the planned
CP437 blocks, modules and ntfy printing. README updated throughout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|