9e829bfce70d1ce9c486dd41e52547fcfb1d1aa8
15
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cee528aa83 |
Record that a person, not the daemon, reprints a job
The owner decided that the daemon never reprints a job by itself. It
cannot tell a receipt that printed from one that is missing: an
uncertain job may have printed, and in two narrow cases a job reads
done before it has printed. A reprint when the cover closes would not
reach the second of those, whose job reads done, and it would print
duplicates, since the printer resumes its own buffer when the cover
closes, as stage 1d's third paper check showed; after a cut-short image
the printer can also still be inside the image command. So those cases
stay as they are, by design.
A person reprints instead, through the API, by ID or by category.
POST /api/v1/jobs/{id}/reprint reprints one stored job, as often as
asked. In place of the ID, last reprints the last completed job, one
that read done and never one still waiting or printing; failed retries
the last failed print; and uncertain reprints every uncertain job. A
job a category reprints is marked, so no category takes it again, and
each answer names the new job, so a person can print it again by its
ID. A reprint takes a job from any source: a print or module route, an
ntfy card or digest, and later a webhook. The routes take no query
parameters: every input goes in the JSON body, an empty body or none
means the defaults, and the printer, with several, is a body field. No
message a source receives, an ntfy message included, makes the daemon
print a job again.
design.md records the decision beside the confirmation and rewords the
open cases as accepted choices; its Planned next item 1 names the
routes and says their questions await the owner. docs/plans/job-store.md
gains decision 24 in phase 2 and open questions 25-39 on its details,
each with an assumed default and its trade-off: last after a reprint,
which failed jobs failed takes, the order of uncertain reprints, when a
job is marked, an age limit for uncertain, several printers, an empty
category, the answer, which jobs an ID may name, the tokens, pruned
content, repeats and the duplicate check, a REPRINT mark, a CLI command
and clearing the printer first. The Status line, the overview and phase
2, its tests and paper check included, take them in, and phase 5 no
longer lists a reprint route. docs/plans/templates.md says that a
webhook replay is the sender's resend, not a reprint command. No code,
route or API document changes until phase 2 builds the routes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
bdda410deb |
Close stage 1d of the job-store plan
Stage 1d is done: jobs survive a restart in the SQLite store, and a restart never prints a receipt twice. Its paper checks passed on the TM-T88IV, with the owner's OK for each: - A receipt printed once, read done, and still read done after restarts. - With the printer off, a receipt was sent and the daemon stopped gracefully while it retried; with the printer on again, the restart printed it once. - With the cover open, the daemon was killed while a 128 KB receipt waited for the printer; after the restart it read uncertain, was never sent again, and printed once, cut short, when the cover closed. The printer then needed switching off and on. - With confirmation, a receipt read done on the printer's answer, and one sent with the cover open waited, with nothing sent, and printed once when the cover closed. - With GS a 0 and DLE EOT 1, a receipt printed once with nothing extra and read done on the printer's answer; 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 when the cover closed. - With each connection opened by DLE EOT 1, GS a 0 and GS r 1, and everything before the DLE EOT answer dropped, a receipt printed once with nothing extra and read done on the printer's answer. The plan's status says so, and stage 1d records the confirmation the owner had built after the first try at the third check. The Investigation findings are folded into design.md, apart from Epson's acknowledgement and its sources, which phase 5 still needs and which stay under Findings for phase 5. The references to them point to design.md. The job states, which receipts printed, decision 16's count of uncertain jobs, decision 21 and phase 5's config key now match the confirmation, and the Architecture says the connector runs the pragmas in order and that Idle checkpoints once 64 commits have gathered. The RECORDS schema keeps refs in the order they were kept, by kept, as the store does, since job IDs need not sort in that order. docs/plans/printers.md notes that confirmation takes only a GS r 1 answer with bits 4 and 7 clear, which stage 4a checks on the TM-T88VII. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9376653e1a |
Let the printer client wait for the printer to confirm a job
A write to the printer's socket returns once the operating system holds the bytes, not once the printer has them. On the TM-T88IV with its cover open, Windows took all of a 128 KB receipt into its send buffer at once, so the job read done; once the cover closed, only its first third printed, without its cut, and the printer was left inside the image command, waiting for the rest. With the new option printer.Confirm(true), Send asks for status with GS r 1, which the printer answers only once it has run every byte before it, and, on the TM-T88IV, only while it can print: - Before beforeWrite, it sends DLE EOT 1, GS a 0 and GS r 1 in one write. The printer answers DLE EOT on receipt, ahead of anything it receives after it, so the answer is a fence: every byte before it left the printer before the request reached it, and Send drops it. That takes care of answers owed to requests the printer ran on an earlier connection or for an earlier run of the daemon, of the last bytes of a status block whose header went to an earlier connection, and of late DLE EOT answers, however long a lost segment holds the request back. Send waits for the fence until the write timeout or the context's deadline, then for an answer to GS r 1 after it. Without them, as with the cover open, no paper, or a printer stuck inside an earlier job, Send returns a plain error with nothing of the job written, as after a failed dial. Requests still queued in the printer ahead of this one are answered after the fence too, and answers carry nothing that tells them apart, so the wait reads every answer until 100 ms have passed since the last and drops them all, and none can be taken for a later job's confirmation. Each job waits those 100 ms. Only answers keep the wait open, so status blocks cannot, and a wait that the deadline or the connection's end cuts short counts as not ready, as one without an answer does. A printer may run GS r 1 while offline, so Send then asks DLE EOT 1 again, for up to 2 s, and writes the job only if the printer answers that it is online. Last, it reads on for 100 ms. Once the answers have settled none is owed, so an answer to GS r 1 during the online check or after it means one taken for the ready answer was not, as when a late DLE EOT answer from an earlier connection stood in for the fence and an owed answer followed it; Send then returns a plain error with nothing written, and the job is tried again. A cancellation stops the wait at once: it sets a flag that every reset of the read deadline checks, and the wait returns only once a cancellation that raced its end has finished with the connection. - After the job, it sends GS a 0 and GS r 1 again and returns once the answer arrives. If it does not arrive before the write deadline, or the connection fails or closes after the job was written in full, Send returns an *UnconfirmedError: the job may have printed in full, in part or not at all. The error has an Unconfirmed method, so the queue can tell it apart without importing the package. Automatic status blocks are what GS a 0 is for. The UB-E02 and UB-E03 boards turn them on at power-on, and a job's own ESC @ does not turn them off on a TM-T88VII with DIP switch 2-1 on. A block's last three bytes have an answer's fixed bits (bits 4 and 7 clear), and the board can send them on the next connection, where they would stand for the ready answer. The printer runs GS a 0 in order, so no block follows the answer to a GS r 1 sent after it. Blocks that come before it are passed over by their header's fixed bits: each connection keeps its place in a block across reads, and once Send has the confirmation it reads on for up to 100 ms for the rest of a block it ended inside. A block cut short ends with its connection, and last bytes that still begin a connection, before the first job after a power-on has turned blocks off, come before the fence's answer and are dropped. Status sends no GS a 0, which the printer does not run while it is offline. It passes over blocks, answers to DLE EOT n that a job's own bytes hold, and a late answer to GS r 1, and before it closes it reads what has come, to the end of any block, so that the next connection gets none of it. It returns ErrStatusUnsupported at once on a byte that fits no answer, and within 100 ms when a byte like an answer to GS r is not followed by an answer to DLE EOT, rather than after its 2 s. The printers plan and the job-store plan say so. The TM-T88IV answered GS r 1 with 0x00 within 4 ms when asked on its own. Nothing turns the option on yet. Tests pin the bytes Send sends with the option on, refuse a printer that answers DLE EOT 1 as offline, put an owed answer, a block's last bytes or both before the fence and delay the ready answer behind it, as after a lost segment or while the printer feeds and cuts at cover close, answer the ready request after an answer owed to an earlier run, and after one owed since a job's own GS r 1, split a status block across reads and across a confirmation and the 50 ms after it, and put owed answers around a block; in each, Send waits for the job's own answer. Others cut a block short and find the next jobs and Status unharmed, send a cover-open block in place of the ready answer, start a connection with the last bytes of a block whose header came after a confirmation, before the confirmation's deadline, with the confirmation at the write deadline, before the ready deadline or after Status's last answer, and find nothing written to a printer with its cover open. Others cut the ready wait short by its deadline and find nothing written, send status blocks every 50 ms and find the job sent and confirmed, and answer DLE EOT with bytes that are not DLE EOT answers and find Status unsupported within 100 ms. Others flood the online check with bytes like answers and Status with status blocks, and find both bounded, and turn the option off and find the job's bytes sent alone. Others put a late DLE EOT answer and an owed answer ahead of a held-back request, or an answer during the online check, and find nothing written; cancel during a steady stream and a flood of answers and find the wait stops at once; and play two cases the client leaves open, a long pause between queued answers and a fence answer between a block's last bytes, logging how they end. Part of stage 1d of docs/plans/job-store.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
64a72903d8 |
Give each ntfy digest a reference of its own
Every digest went to the print queue under the fixed reference "digest", so after a crash the queue could not tell a digest it had queued from a new one. Once queued jobs survive a restart, a crash in the second between queueing a digest and saving the subscription's state would print it twice; the same window exists today for a digest that printed in that second. A digest now gets a reference of its own when it is made, "digest_" and a TypeID, and is saved with it in the subscription's state, apart from the held messages. It is offered to the queue only once that save has succeeded, and dropped once the queue takes it; while the state file cannot be written, digests wait. A restart with a saved digest offers that digest again first, with the same rows and reference, and the queue's duplicate check answers with the earlier job while it holds it. Messages held after a digest is made wait for the next one, also while quiet hours delay the saved digest after a restart: added to a digest the queue already holds, they would never print. The digest is submitted as unique, like a card. A digest can cost one more state save, two fsyncs. The reference shows in the log lines and Sentry reports where "digest" did. This completes stage 1c of docs/plans/job-store.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
66531e7314 |
Replace ntfy.state_dir with a top-level [state] dir
The job store is to keep its database in the directory that holds the ntfy subscriptions' state files, so the directory moves to a section of its own: [state] dir, or UBERBRINGER_STATE_DIR, in place of [ntfy] state_dir. For now only the subscriptions use it. It still has no default and is still required with a subscription, and the checks at start name state.dir in their errors. install.sh writes [state] dir into new configs, and the Docker image sets UBERBRINGER_STATE_DIR. ntfy.state_dir has never been in a release, so its CHANGELOG entry changes in place and there is no fallback: a config that still sets it fails to load with an unknown key until the line moves to [state]. The image itself was not built, since the workstation has no Docker. Part of stage 1b of docs/plans/job-store.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c548833656 |
Record the job store's measurements on leil-rig
The owner has no ARM boards and no Pi-class host, so stage 1a ran its probe on leil-test-1, an x86_64 AlmaLinux VM on leil-rig with a virtual disk, on his word. Decision 2 now says so: no build of the store runs on ARM hardware, and the CHANGELOG will say that the ARM builds ship it untested. Stage 1d, and the remote-printers plan, which counted on stage 1a measuring an SD card, say the same. On that disk, with the schema under RECORDS and 1000 jobs of history, a text job cost 1.04 flushes, 53.8 KiB of device writes and 11.46 WAL frames, and its synced commit took 5.0 ms, or 2.9 ms with fdatasync. Every call the store makes passed the unit's syscall filter, with SELinux enforcing. The numbers are at or below the earlier estimates, so none of them argues against decision 1. An SD card, ext4 and ARM remain unmeasured. The probe was built on modernc.org/sqlite v1.64.0, released on 2026-12-01, with the same SQLite and libc pin as v1.63.0. It lives outside the repository, and the rig was left as it was found. Part of stage 1a of docs/plans/job-store.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
709e7904e9 |
Fold the formatters plan into design.md
Phases 1-4 of docs/plans/formatters.md are built and described in design.md, and every phase 5 item now has a plan of its own, under Planned next. So the plan goes, and what still matters moves into design.md. A new decision says that existing jobs keep their meaning and their bytes: /print stays strictly decoded, TestRenderCompat and TestPaperReceipts pin the bytes, and Renderer.Render is the only path to printer bytes. The labels and footer settings join "Modules build ordinary jobs". Deferred gains nested boxes and goldmark, and the geometry checks in the HTTP handler that stay rejected. The plan's other invariants were already design.md decisions. The plans that cited formatters.md now cite design.md, or drop the reference: job-store.md, printers.md, blocks.md and templates.md. job-store.md's phase 5 list moves to design.md's Deferred section once its other phases are done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
68bce4db59 |
Record the owner's acceptance of the printers plan
The owner accepted every proposed default of docs/plans/printers.md on 2026-12-01. Its open questions become numbered decisions, without the alternatives, and design.md's Planned next item 2 records them. Decisions 6, 10 and 17 keep the wording that the remote-printers and templates plans had already settled. Decision 14 amends the owner's earlier wording: a rule that fails to compile stops the start rather than being skipped. The plan's acceptance edits are made, and its list of them goes. formatters.md loses its open question, which the routing example answers, and points to this plan for a second printer and per-model line spacing, without the printer pool's tests. job-store.md points to these decisions for the deliveries array, the stored route, failover after a sending mark, the lanes and their content bound, and a printer removed from the config. Its invariant 2 speaks of the job's bytes, since an anycast check sends DLE EOT before the mark. Its findings confirm the TM-m50II's command list and the power-on part of the automatic-status side finding. Phase 2b, phases 3c and 4 and phase 5 say how they meet several printers. The other plans cite printers decisions in place of questions, and templates decision 1 now follows printers decisions 12, 14, 15 and 17 rather than leaning on assumed defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f302b76ef4 |
Record the owner's acceptance of the job-store plan
The owner accepted every proposed default of docs/plans/job-store.md on 2026-12-01. Its open questions become numbered decisions, without the alternatives, and design.md's Planned next item 1 records them. Decisions 7 and 21 keep the wording that the remote-printers plan had already settled. Each stage now follows its decisions, and the "(assumed)" marks on the plan's own defaults go. The other plans cite job-store decisions in place of questions: printers.md, remote-printers.md, templates.md and ntfy.md. Templates decision 22 now follows job-store decision 10 rather than leaning on an assumed default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
aaeeba8eb4 |
Bring the job-store questions in line with the accepted plans
The owner has accepted the remote-printers, templates and ntfy plans with every default since docs/plans/job-store.md was written. They settle two of its questions and lean on the defaults of several more. Questions 7 and 21 now say they are settled: remote-printers decision 17 ends an unknown remote send as uncertain, never sent again, and its decision 24 builds Epson's acknowledgement only with phase 5, on the owner's word. Both keep their numbers, since other plans cite them. In the questions still open, no default changes. Question 1's GORM comparison now counts Expr, which templates decision 1 links in. Question 18 follows ntfy decisions 2 and 8: the cursor moves as during any replay, and both transports drop priority= through one query builder. Question 22 counts the larger state saves of ntfy decision 12. Question 23 points to printers question 22 and to the byte count that printers stage 3 adds. Questions 6, 10, 18 and 23 name the accepted decisions that lean on them, and a rule's digest from templates decision 18 gets the same reference and delete handling as a budget digest. The Status line and stages 1d and 4 named a Deferred item in design.md that is now Planned next item 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c778c3f983 |
Record the owner's acceptance of the templates plan
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> |
||
|
|
8b9e838675 |
Record the owner's acceptance of the blocks plan
The owner accepted every proposed default of docs/plans/blocks.md on 2026-12-01. Its open questions become numbered decisions, without the alternatives, and design.md's Planned next item 4 records them. The plan's acceptance edits are made: formatters.md's phase 5 points to the plan for more blocks, and its deferred list keeps only nested boxes and goldmark; job-store.md's phase 3a draws each block that has shipped in its golden PNGs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
10b6c57afb |
Record the owner's acceptance of the remote-printers plan
The owner accepted every proposed default of docs/plans/remote-printers.md on 2026-11-30. Its open questions become numbered decisions, without the alternatives, and design.md's Planned next item 3 records them. The plan's acceptance edits are made: printers.md's seam, question 6, question 24 and stage 3 point to it, and job-store.md notes that a remote attempt whose outcome stays unknown turns uncertain during a run and that the acknowledgement runs at the agent for remote printers. 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> |
||
|
|
80a65f6083 |
Plan the job store and record the features planned next
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> |