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>
66 lines
4.4 KiB
Markdown
66 lines
4.4 KiB
Markdown
# Plan: CP437 blocks, modules and ntfy printing
|
|
|
|
Status: **phases 1-4 are done**: the blocks and the preview; the list block, the module layer and the note module; the notify and ntfy modules, their cards and scoped tokens; and the ntfy subscriptions, with their digest, paper budget and quiet hours. All four are built and checked on paper, and docs/api.md, README.md and design.md describe them. Phase 5 is a list of items built one at a time, each when a real need appears, in its own session briefed from its item.
|
|
|
|
## Open questions
|
|
|
|
When the second printer arrives:
|
|
|
|
1. Which jobs and ntfy subscriptions go to which printer, and should urgent messages print on both?
|
|
|
|
## Rules for phase 5
|
|
|
|
BACKWARD COMPATIBILITY
|
|
- Every existing element, field and response keeps its meaning, and /print stays strictly decoded.
|
|
- TestRenderCompat (receipt/testdata/compat) and TestPaperReceipts pin the bytes of existing jobs; later work keeps them passing.
|
|
- Emoji are removed only on the module and ntfy paths; /print prints an emoji sequence as one '?'.
|
|
|
|
DEFERRED UNTIL A NEED APPEARS
|
|
- nested boxes and goldmark.
|
|
- Geometry checks in the HTTP handler (Renderer.Check) stay rejected: layout never fails on a valid job, preview shows the result and line count synchronously, and each module caps its own length.
|
|
|
|
INVARIANTS (all match the current code)
|
|
1. receipt.Job stays printer-neutral. Blocks are sized at render time from Options.Columns or Profile.Columns(font). The same job therefore prints correctly on a TM-T88IV, TM-T88VII or TM-m50II, and on several printers later.
|
|
2. Job.Validate stays structural and independent of geometry, so handlePrint keeps its Validate-then-Submit flow.
|
|
3. Layout never fails on a valid job. Widths clamp, titles are cut with "...", and over-long words split the way wrap() already splits them. The only render-time failure is the [format].max_lines backstop (default 2000).
|
|
4. Renderer.Render is the only path to printer bytes, and is all-or-nothing.
|
|
5. New code never emits raw ESC/POS. Payload text only ever lands in string fields of elements. The raw element stays available on /print only, to tokens issued with --raw.
|
|
6. /print stays strictly decoded (DisallowUnknownFields). A byte-compatibility test pins today's bytes.
|
|
7. Layers call only downward: server -> modules -> receipt -> escpos. ntfy never imports modules; internal/app connects the subscriptions to modules.
|
|
|
|
## Phases
|
|
|
|
### Phase 5: Later, on demand (1-3 days each; build only when a real need appears)
|
|
|
|
**Goal.** Keep the core small. Each item below is independent and waits for real demand or an owner decision.
|
|
|
|
**Work.**
|
|
|
|
- Second printer, for the TM-T88VII and TM-m50II:
|
|
- a printqueue Pool with one Queue and worker per printer
|
|
- [printers.<name>] config, each table decoded through Viper onto the printer defaults, with the old [printer] table becoming "default" and strict unknown-key checks kept
|
|
- ?printer= on print, preview and modules; printer = "name" per subscription; optional priority routes
|
|
- /healthz per printer, with the status still following the default printer
|
|
- Jobs stay printer-neutral, so nothing in the block or module code changes.
|
|
- User templates (Design 2's safety model):
|
|
- JSON files with a typed payload schema
|
|
- text/template only inside string values; if and each keys
|
|
- element keys checked by reflection; templated hex rejected; output capped per field and per job
|
|
- every template's example run through Format and Validate at startup
|
|
- An ntfy-compatible publish endpoint, POST /ntfy/{topic} and POST /ntfy, outside /api/v1. Auth is a Bearer JWT, or Basic with an empty user and the JWT as password. Tools that send to an ntfy server URL could then print directly.
|
|
- More blocks: planned in docs/plans/blocks.md.
|
|
- Queue.Cancel so message_delete can cancel a still-queued job.
|
|
- Webhook sources: /hooks/{name}, with auth always required, HMAC compared with hmac.Equal, and an unknown name rejected with 404 before the body is read.
|
|
- Default line spacing per model in escpos.Profile, once calibrated on each model.
|
|
|
|
**Tests.**
|
|
|
|
Each item ships with its own goldens and table tests in the phase 1-4 style. For the printer pool, also:
|
|
- a config migration test from [printer] to printers.default
|
|
- unknown keys inside [printers.x] still rejected
|
|
- two queues printing in parallel
|
|
|
|
**Done when.**
|
|
|
|
Each item is done when its feature has golden or preview coverage, README docs, and a real-paper check where layout changes. Nothing here blocks phases 1-4.
|