The owner accepted every proposed default of docs/plans/ntfy.md on 2026-12-01, keeping WebSockets first. Its open questions become numbered decisions, without the alternatives, and design.md's Planned next item 6 records them. The plan's acceptance edits are made: design.md gives the conditions under which ntfy replays a topic's whole history for a message ID; formatters.md's phase 5 loses its publish endpoint item, since there is none; templates.md's findings lose the open point on that endpoint. formatters.md is not yet folded into design.md: printers.md and job-store.md, not yet accepted, still plan edits to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.8 KiB
Markdown
61 lines
3.8 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: planned in docs/plans/templates.md.
|
|
- More blocks: planned in docs/plans/blocks.md.
|
|
- Queue.Cancel so message_delete can cancel a still-queued job.
|
|
- Webhook sources: planned in docs/plans/templates.md.
|
|
- 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.
|