Record that every install is fresh until v1

The owner decided on 2026-12-01: "No active installs, don't concern
self with upgrade paths, we assume until v1 that every install is
new/fresh/breaking". The releases plan records it as decision 19 and
applies it:

- Until v1 any release may break callers, configs, installs and
  stores, and the CHANGELOG says so once at its top. Entries list what
  each version has, with no upgrade or migration steps and no Breaking
  heading.
- The release checklist tests fresh installs only: install.sh in Debian
  and Ubuntu containers, and the Docker image. The upgrade test, the
  0.1 config check and the open question about 0.1 hosts go.
- No data is migrated. jobstore's schema steps give way to one schema
  and its version, and a binary refuses a jobs.db of any other version,
  naming the file and saying to move it aside or remove it. v0.2.0
  gains that commit and one that rewrites the docs for fresh installs.

The job-store and printers plans now raise the schema version and
refuse an earlier store where they planned schema steps, and drop their
downgrade notes. Phase 2b's cancelled status goes under Changed.
design.md's Why no longer says 0.1 installs are deployed, its 0.1
compatibility bullet becomes the decision, and install.sh migrates
nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 23:06:27 -06:00
1 parent 515d5ae699
commit 2497157b36
4 files changed
+89 -83

No files matched your search

+13 -9
View File
@@ -201,7 +201,7 @@ COMPATIBILITY
- Job status gains the `deliveries` array with docs/plans/printers.md stage 1b, for every job, whatever the number of printers (its decision 8).
- What prints does not change. TestRenderCompat and TestPaperReceipts keep passing.
- The Docker image keeps a job store in `/var/lib/uberbringer`, so a container that cannot write there stops at start (decision 14, **Breaking**).
- A downgrade: an older binary refuses `[state] dir` and `queue.content_bytes` as unknown keys and ignores `jobs.db`. The CHANGELOG and docs/configuration.md say so.
- No release promises an upgrade or a downgrade until v1, and no data is migrated (docs/plans/releases.md decision 19). A binary refuses a `jobs.db` of another schema version, older or newer, naming the file and saying to move it aside or remove it.
INVARIANTS
1. Nothing reaches the printer unless the whole receipt rendered.
@@ -347,7 +347,7 @@ type Store interface {
RECORDS (SQLite, decision 1)
```sql
-- PRAGMA user_version = 1 marks this schema; a later schema steps from it.
-- PRAGMA user_version = 1 marks this schema; a binary refuses a file of any other version.
CREATE TABLE jobs ( -- written once, at insert
seq INTEGER PRIMARY KEY, -- submission order
id TEXT NOT NULL, -- the job_ TypeID
@@ -385,7 +385,7 @@ CREATE TABLE refs ( -- unique jobs, for the duplicate check
- IO: the split costs one more small row per job at insert, in the same commit. `deliveries` is a b-tree of its own, so an insert can change one page more than with one table. On leil-test-1 this schema appended 11.46 WAL frames per text job, against 14.35 in the SQLite track's runs with one table.
- Statuses are looked up in memory, so neither table needs an index on `id`, `state` or `job_seq`, and updates go by a delivery's `seq`. Each index left out is a b-tree fewer per insert. Pruning deletes a job's row and its deliveries' rows by their `seq`s, which the queue passes to `Finish`.
- `Load` reads `deliveries` in `seq` order and attaches each row to its job by `job_seq` in memory.
- `sequence` lets an ntfy `message_delete` find a waiting job after a restart too (phase 2b). It holds the topic and the sequence ID as `<topic>/<sequence ID>`, since ntfy's sequence IDs are per topic (`DELETE /<topic>/<sequence_id>`) and one subscription reads several topics; a topic name cannot hold `/`. It is written from stage 1d, so phase 2b needs no schema step and can cancel a job stored before it.
- `sequence` lets an ntfy `message_delete` find a waiting job after a restart too (phase 2b). It holds the topic and the sequence ID as `<topic>/<sequence ID>`, since ntfy's sequence IDs are per topic (`DELETE /<topic>/<sequence_id>`) and one subscription reads several topics; a topic name cannot hold `/`. It is written from stage 1d, so phase 2b changes no schema and can cancel a job stored before it.
- Content has its own table, so a status update never rewrites a body. `Load` reads each content's length, not the content.
- `refs` is pruned to the newest 512 per source in the order they were kept, by `kept`, as the queue forgets them, apart from `jobs`, so pruning statuses never drops a reference. Job IDs do not give that order: one minted after the clock was set back, as on a board whose clock does not run while it is off, sorts before those kept. A reference kept for an earlier job is dropped and kept again as the newest. `refs` is written only for unique jobs, and its unique index on `source` and `ref` is the only index in the store.
- Times are Unix nanoseconds, so a status reads the same after a restart as before it.
@@ -395,7 +395,7 @@ CREATE TABLE refs ( -- unique jobs, for the duplicate check
- The DSN is built through the connector API, or escaped, since `state.dir` may hold spaces, `#` or `?`.
- Pragmas at open: `journal_mode=WAL`, `locking_mode=EXCLUSIVE` (decision 3), `synchronous=NORMAL`, `temp_store=MEMORY`, `journal_size_limit` of 4 MiB, `secure_delete=FAST`, and `auto_vacuum=NONE` before the tables exist. `wal_autocheckpoint` stays at 1000.
- A synced commit runs `PRAGMA synchronous=FULL`, commits, and restores NORMAL in a defer, so a failed statement never leaves the connection at FULL. `Sending`, `failed`, inserts of unique jobs and, from phase 2b, `cancelled` commit this way.
- Open, in order: create the file 0600 if it is missing; set the pragmas; run `PRAGMA quick_check`, which only reads (the whole file, about 2 MiB with text jobs and up to about 48 MiB with images, as the research measured), since SQLite otherwise finds a damaged page only when a statement reads it, mid-run; refuse a `user_version` newer than the binary knows, naming both; run each schema step in one synced transaction that also sets `user_version`; write once, so a second instance fails at once.
- Open, in order: create the file 0600 if it is missing; set the pragmas; run `PRAGMA quick_check`, which only reads (the whole file, about 2 MiB with text jobs and up to about 48 MiB with images, as the research measured), since SQLite otherwise finds a damaged page only when a statement reads it, mid-run; give a new file the schema and its `user_version` in one synced transaction, and refuse a file of any other `user_version`, older or newer, naming the file and both versions and saying to move it aside or remove it (docs/plans/releases.md decision 19); write once, so a second instance fails at once.
- `Idle` runs `PRAGMA wal_checkpoint(PASSIVE)` once 64 commits, about 20 jobs, have gathered since its last checkpoint. The queue is idle after nearly every job when receipts come one at a time, and a checkpoint costs three syncs (the log, the database, and the log's header at the next commit), so one each time would make a job cost four.
- `sqlite.Fdatasync(true)` on Linux. The unit's syscall filter allows `fdatasync`, and on leil-test-1 it cut a synced commit's median from 5.0 to 2.9 ms with the same device writes and flushes (stage 1a).
- Nothing else in the process opens the file, since any close drops SQLite's locks.
@@ -411,7 +411,7 @@ API
- Stage 1c: `status` gains `uncertain`, in the `State` enum's `jsonschema` tag, printqueue's schema test, docs/api.md, swagger.json and the CHANGELOG under **Breaking**. Status gains `sent_at` (name assumed), set once an attempt was about to write to the printer. A store failure in `Submit` is an unexpected error: `500` `internal_error`, logged and reported once, the job not accepted, and the daemon stops (decision 11).
- Stage 1d: a job kept in the store answers its status after a restart instead of `job_not_found`.
- Phase 2 (decision 16): `POST /api/v1/jobs/list` with `status`, `source`, `before` and `limit` in the JSON body. It answers `{"jobs": [...], "next": "job_..."}`, newest first by sequence number. Bad values answer the new code `400` `invalid_body`. The body is a Go type whose `jsonschema` tags give `status`'s enum and `limit`'s bounds, as every request body's tags do, so the generator needs no change. Job status gains `ref`. `/healthz`'s `queue` gains `uncertain`; the status code still depends on the printer alone.
- Phase 2b (decision 17): `DELETE /api/v1/jobs/{id}`, for full tokens, answers `200` with the status, or `409` with the new code `job_started` when no delivery is left to cancel and none is cancelled. `status` gains `cancelled`, a new enum value, so the CHANGELOG lists it under **Breaking**, as it does `uncertain`. `DELETE /api/v1/print` still answers `405`, api.md's example for `method_not_allowed`.
- Phase 2b (decision 17): `DELETE /api/v1/jobs/{id}`, for full tokens, answers `200` with the status, or `409` with the new code `job_started` when no delivery is left to cancel and none is cancelled. `status` gains `cancelled`, a new enum value clients may meet, which the CHANGELOG lists under Changed (docs/plans/releases.md decision 19). `DELETE /api/v1/print` still answers `405`, api.md's example for `method_not_allowed`.
- Phase 3c (decision 19): `Accept: image/png` on `POST /api/v1/preview` and `POST /api/v1/preview/{module}`. Text stays the answer to `*/*`. A picture over the height cap answers `422` `preview_too_long`. The generator needs a PNG body schema (`contentMediaType: image/png`). The compress middleware sits in front of these routes; phase 3c checks that it leaves PNG alone.
- Phase 4 (decision 20): `GET /api/v1/jobs/{id}/preview`, as text, JSON or PNG by `Accept`, as the POST preview answers, with the new code `410` `job_content_expired`.
- Every route is an entry in the table in `server/routes.go`, written there in OpenAPI form (`{id}`; api.md writes `:id`), with its case in TestRoutesConform. Every code goes into `server/errors.go`, the table in docs/api.md and the regenerated swagger.json.
@@ -439,7 +439,7 @@ DELIVERIES AND SEVERAL PRINTERS
- broadcast: to every printer;
- anycast: to one printer of an ordered list, as a priority list with failover: the first, on failure the second, then the third.
- A job has one or more deliveries, one per printer it goes to, each tracked on its own. A multicast or broadcast job is one job with several deliveries; a unicast or anycast job has one. The state machine under JOB STATES applies to each delivery. The `Store` interface carries deliveries from stage 1c, and the database keeps them in a table of their own from stage 1d (RECORDS), so several deliveries per job need new rows, not new tables. Until the printers plan lands, every job has exactly one delivery, for the printer `default`.
- docs/plans/printers.md decision 18 stores the route: `route_by`, `route_rule` and `route_mode` on `jobs`, and `candidates` and `sent_to` on `deliveries`, in stage 1d's first schema or in a step to `user_version` 2. So a restored anycast delivery keeps its list, and a failover after a `sending` mark keeps the record that the first printer got bytes, which TELLING WHICH RECEIPTS PRINTED relies on.
- docs/plans/printers.md decision 18 stores the route: `route_by`, `route_rule` and `route_mode` on `jobs`, and `candidates` and `sent_to` on `deliveries`, which raise the schema's version. So a restored anycast delivery keeps its list, and a failover after a `sending` mark keeps the record that the first printer got bytes, which TELLING WHICH RECEIPTS PRINTED relies on.
- A job's API `status` derives from its deliveries (decision 12). A delivery counts as taken from when the worker picks it up until it finishes: while it renders, waits for the printer's slot, dials, waits between retries or sends (decision 12):
- Cancelled deliveries (phase 2b) are passed over unless every delivery is cancelled; then the job is `cancelled`. The rest of the rule reads the other deliveries.
- `queued` while every one waits, none taken and none finished;
@@ -704,6 +704,9 @@ internal/pkg/printqueue
- `List(filter, before, limit)` from memory, newest first by sequence number; a `before` no longer kept is an error the server maps to `invalid_body`. The count of jobs with a delivery that `Load` turned `uncertain` at the latest start. `Status.Ref`.
- The reprint (decisions 24-39): `Reprint(id, meta)` and `ReprintCategory(category, meta)` (names assumed) read a finished job's stored content and submit it as a new job that is not unique and records the one it reprints. A category picks per printer the newest unmarked `done` job for `last`, the newest unmarked `failed` one for `failed`, and every unmarked `uncertain` one, oldest first, for `uncertain`, never a job still waiting or printing; the new job's `reprint_of`, in the store, marks the original. They refuse an unfinished job, content and IDs no longer kept, and an empty category.
internal/pkg/jobstore
- The schema gains `reprint_of` on `jobs`, the ID of the job a reprint copies, empty for any other job (decisions 28 and 32), and its version goes to 2. `Add` writes it, and `Load` reads it back, so the marks survive a restart. A store from an earlier version is refused, as INVARIANTS says; nothing is migrated (docs/plans/releases.md decision 19).
internal/app/uberbringer/server
- The route `POST /api/v1/jobs/list` in the table, for full tokens; its request type, with `status`'s enum and `limit`'s bounds in its `jsonschema` tags; its handler and response type; `invalid_body` in errors.go; `Jobs` gains `List`, and `fakeJobs` with it; its case in TestRoutesConform.
- `/healthz`: `queue.uncertain`.
@@ -716,6 +719,7 @@ Docs
- CHANGELOG. docs/swagger.json regenerated.
**Tests.**
- A `jobs.db` at `user_version` 1, as v0.2.0 writes it, is refused, and the error names the file. A reprint's `reprint_of` survives a close and a reopen.
- Filters by status and source, paging with `before`, a `before` no longer kept, the bounds of `limit`, and bad values and an unknown field giving `invalid_body`. An empty body, `{}` and no body give the defaults. `GET /api/v1/jobs/list` answers `404` `job_not_found`, as any path that is not a job's ID does.
- A token limited to modules gets `403` `token_scope`.
- schema_test: the new enums and `limit`'s bounds held to validation.
@@ -736,7 +740,7 @@ Docs
internal/pkg/printqueue
- queue.go:
- `StateCancelled`, with `cancelled` in the `State` enum's `jsonschema` tag: a new value clients may meet, so the CHANGELOG lists it under **Breaking**, as it does `uncertain`.
- `StateCancelled`, with `cancelled` in the `State` enum's `jsonschema` tag: a new value clients may meet, which the CHANGELOG lists under Changed.
- Only a delivery that has not reached `sending` can be cancelled: one waiting, rendering, waiting for the printer's slot, dialling, or between retries that never reached the printer. Cancelling a job cancels those of its deliveries; one that has reached `sending`, or has finished, goes on.
- `Cancel(id)` (name assumed) cancels the job's deliveries that have not reached `sending` and returns its status. With none left to cancel it returns the status as it is if any delivery is cancelled, so a repeated cancel answers as the first did, and `ErrStarted` (name assumed) if none is.
- `CancelSequence(source, sequence)` (name assumed) cancels those deliveries of each job from that source whose `Meta.Sequence` (stage 1c), its notification, equals `sequence`, and returns the jobs' IDs. It matches in memory, so a job restored after a restart is found too. An empty `sequence` matches nothing, so jobs without one, HTTP and module jobs and digests, are never cancelled by it. A job with nothing left to cancel is passed over without an error.
@@ -751,7 +755,7 @@ internal/pkg/printqueue
- store.go: `StoredState` gains `cancelled`, and `Store` gains `Cancel(ctx, deliveries []uint64, at time.Time, p Prune) error`, one synced commit. The memory store implements it.
internal/pkg/jobstore
- `Cancel`: one synced transaction that sets each delivery's `state` and `finished_at` and drops the given jobs, deliveries and contents. The `sequence` column is in the schema and written from stage 1d (RECORDS), so there is no schema step.
- `Cancel`: one synced transaction that sets each delivery's `state` and `finished_at` and drops the given jobs, deliveries and contents. The `sequence` column is in the schema and written from stage 1d (RECORDS), so the schema does not change.
internal/pkg/ntfy
- subscriber.go:
@@ -775,7 +779,7 @@ Docs
- docs/api.md: the route table, a "Cancel a job" section, the `job_started` row in the error table, and the Job status section (`cancelled`).
- docs/ntfy.md: how a subscription behaves: a `message_delete` cancels the waiting receipts of its notification and drops its held digest rows, also under `min_priority` and past `max_backlog`; a `message_clear` does neither; `min_priority` is applied by the subscriber, which reads every message of its topics.
- design.md: the state machine's `cancelled`, its synced commit and the delivery lock; the ntfy subscriptions paragraph (deletes cancel, clears do not, and the subscriber filters priorities itself).
- CHANGELOG: under **Breaking**, the `cancelled` status; under Added, `DELETE /api/v1/jobs/{id}` and cancelling by ntfy deletes; under Changed, that a subscription with `min_priority` reads every message and filters itself.
- CHANGELOG: under Added, `DELETE /api/v1/jobs/{id}` and cancelling by ntfy deletes; under Changed, the `cancelled` status and that a subscription with `min_priority` reads every message and filters itself.
- docs/swagger.json regenerated.
**Tests.**