Public: anyone can read this; the crew can change it.
A granted app's two-page print comes out as one sheet, printed on both sides #18194
Merged 14h 4m ago, live in production
An app can now ask for a two-page print on both sides of one sheet, and the daily cap counts sheets of paper instead of jobs. Nothing was printed on the real printer. The print, raster, OpenAPI-error, module-state and dead-code tests pass, as do tsc and the gate.
-
Reviews
Changes requested — before the latest pushTwo things to fix in one round.
- A printer that cannot be asked about sides uses up a sheet of the day. In
printFor, when the sides probe fails the job is loggedfailedwith the defaultsheets = 1.failedrows count against the cap, but nothing reached the printer, which breaks the rule that a refusal never uses up the day. Log it asrefused_document, or give it zero sheets. - The OpenAPI entry and the route do not say the same words (box 5).
daily_capreads differently inPRINT_WORDSand in the route'srefusals. The new test holds onlyinvalid_sidesandsides_unsupportedto the route's words, so it cannot catch this. Use thePRINT_WORDS.daily_capsentence in the OpenAPI entry and extend the test to cover it.
Smaller: the
encodePrintJobtest ends withexpect(decodeResponse).toBeDefined(). That assertion proves nothing, so remove it and the unused import.The rest is sound. The sides check runs before the body is read. The IPP
sidesattribute is sent only when asked. Two-sided is refused without contact when the printer does not list it. Sheets are reserved with no await between the check and the reservation. The docs are indocs/features/devices.mdand not in the README. I did not exercise the preview.ApprovedBoth earlier asks are met on the lines that changed since 23fba30: a failed sides probe is logged with 0 sheets and the new test shows
printedTodayunchanged after a 502, and the OpenAPIdaily_capentry now uses the route's sentence and the words test holds it. The permit is released infinallyon every early return, and the sheet check and reservation have no await between them. No security, door or design findings. Non-blocking: the raster probe failure still logs one sheet although nothing was sent; log 0 there too. - A printer that cannot be asked about sides uses up a sheet of the day. In
-
Checks
shipped production is serving it deploy f698c54
-
History
- Print: a failed sides probe uses no sheet; OpenAPI daily_cap says the route's words (#18190) 5a931da
- Print: two-sided jobs, and a daily cap that counts sheets (#18190) 23fba30
- Bug and crash reports from an app become work: an issue on its repository, a triage, and a fix pull (#18097) 68dcbf7
- Games survival step 4: admin mods (luckperms fabric, ledger with fabric-language-kotlin) (#18148) 4fb3248
- Games: /forge reads are answered in the same sync, and the agent sends a request within a fifth of a second (#18149) e529fa8
- Traces 5a: compare two traces of one issue side by side, with the cost and time difference (#18164) e7394aa
- Access 3a: the /api/v1 repository routes ask may(), shadowed first, then their inline checks go (#18165) 7ba81ba
- Spark's config is installed with the mod so a profile uploads to the forge and never elsewhere (#18173) 7de2fc0
- Games survival step 3b: a sleep (night-skip) mod in the quality set (#18172) 56e2b82
- Automate a review finding as a lint or test: One high finding, then smaller ones, all for one round. (#18167) f6eb779
- A spark profile decodes to a summary: call tree, slowest ticks, per-mod time, GC and memory (#18144) e30e2b6
- Access 4b: the 'Who may do what' page, linked from settings, by person and by resource (#18131) 3ecccb5
- "asks ledger failed: database is locked" two minutes after a release (v0.7.733) (#18169) 009df15
- Traces 4: a Claude Code session file imports as a trace and is listed beside the others (#18129) 68f0754
- A game box stores spark profiles in the forge: POST /post gives a Location, reads need the box's game grants (#18146) b992c0d
- Games survival step 3: quality-of-life mods tried on a copy first (graves, essential-commands, sleep, harvest, vein miner, styled-chat) (#18145) f058287
- Spend 1: a monthly budget per cloud account, one notice at 80% and one at 100% (#18121) 3382c40
- Games: a proxy plugin update can wait until nobody has been on for 30 minutes (#18039) 9a5eb31
- Traces 5: compare two traces, and share one with secrets redacted (#18017) 7a17314
- AWS writes for mail setup are a named allowlist beside the read rule, and nothing else (#18142) 93c7c3d
An app can now ask for a two-page print on both sides of one sheet, and the daily cap counts sheets of paper instead of jobs. Nothing was printed on the real printer. The print, raster, OpenAPI-error, module-state and dead-code tests pass, as do tsc and the gate.
print.test.ts and print_raster.test.ts fail together in one process: one raster test gets 429, apparently from the shared per-minute limiter. They fail the same way on main and pass when run alone.
What changed
sidesoption:POST /api/v1/devices/:id/print?sides=takesone-sided(the default) ortwo-sided-long-edge. Anything else is a 400invalid_sidesthat names both values. It is checked after the grant lookup but before the body is read, and the permit is released.- IPP encoding:
encodePrintJobadds the IPPsidesattribute only when asked. A test decodes the bytes and finds it for two-sided and finds none otherwise. - Printer support:
- Two-sided is sent only when the printer's
sides-supportedlists it.reportOfnow reads that attribute, and a fresh Get-Printer-Attributes is made at print time. - Otherwise the answer is 422
sides_unsupported, a plain sentence, and nothing reaches the printer. Tested with a fake printer that lists nothing.
- Two-sided is sent only when the printer's
- Sheet cap:
- A job's sheets are
pagesone-sided andceil(pages/2)two-sided. Rows older than the newprint_job.sheetscolumn count as one each, as before. - After the body is read, the job's sheets are checked against printed-today plus the sheets other in-flight jobs hold, and reserved before any await. A job that does not fit gets a 429
daily_capand is never sent. - Tested: two pages two-sided is 1, two pages one-sided is 2, and a job over the remainder is refused unsent.
- A job's sheets are
- Words: the OpenAPI entry,
docs/features/devices.md, the device page and the terminal Devices screen all say "sheets". A test holds the OpenAPI refusal lines to the route's own sentences.
Behaviour change. A one-sided 20-page job is now 20 sheets against the default cap of 10. I changed two tests for that: print.test.ts raises the grant cap to 100 for its 20-page job, and the old "1 page, then 3 pages, cap 2" case is now two 1-page jobs. The same raise went into print_raster.test.ts.
What I chose not to do
- No change to the comic or
raster.ts, which live in the morning-paper app. - No detection of printers that silently ignore
sides. The cap counts what was asked. - No
two-sided-short-edge.
Reused: the probeRasterSupport pattern (ask the printer just before sending) and permitPrint's synchronous reservation. I changed the in-flight map's value to hold sheets, so no new module-level state was added.
To try: POST /api/v1/devices/<id>/print?sides=two-sided-long-edge with a two-page PDF and an app token on a preview. ?sides=duplex should return a 400 naming the allowed values. I have not tried it on a preview.
No review block: the only page change is two labels ("sheets") on /settings/devices.
🤖 Generated with Claude Code
Both changes @sentinel asked for are in and pushed, along with the smaller cleanup. bun test test/print.test.ts passes and tsc is clean. I haven't run the full suite or exercised the preview.
- Failed sides probe: in
printFor, a probe that fails is now loggedfailedwithsheets = 0, so a refusal where nothing reached the printer no longer uses up a sheet of the day. A new test points a two-sided job at a printer that answers 500. It checks that the response is 502 and thatprintedTodaydoes not change. daily_capwords: the OpenAPI route entry now uses thePRINT_WORDS.daily_capsentence. The words test now holdsdaily_capto it too, alongsideinvalid_sidesandsides_unsupported.- Cleanup: I removed the
expect(decodeResponse).toBeDefined()assertion and its unused import from theencodePrintJobtest.
I left the raster probe alone. When it fails, the job is still logged failed with one sheet, and the raster probe sits outside this round's scope. Say so if you want it to log zero sheets as well.
gate.ts also reported a possible duplicate (printDocument and readJob in src/devices/ipp.ts) and some long comment lines, and I changed neither. --fix rewrapped nothing and I added no comment lines. The gate's note says the nightly rewrap handles the long lines on main.
The commit line carries No door: because only a refusal's accounting and one contract sentence changed, with no page, action or tool.
An app can now ask for a two-page print on both sides of one sheet, and the daily cap counts sheets of paper instead of jobs. Nothing was printed on the real printer. The print, raster, OpenAPI-error, module-state and dead-code tests pass, as do
tscand the gate.print.test.tsandprint_raster.test.tsfail together in one process: one raster test gets 429, apparently from the shared per-minute limiter. They fail the same way onmainand pass when run alone.What changed
sidesoption:POST /api/v1/devices/:id/print?sides=takesone-sided(the default) ortwo-sided-long-edge. Anything else is a 400invalid_sidesthat names both values. It is checked after the grant lookup but before the body is read, and the permit is released.encodePrintJobadds the IPPsidesattribute only when asked. A test decodes the bytes and finds it for two-sided and finds none otherwise.sides-supportedlists it.reportOfnow reads that attribute, and a fresh Get-Printer-Attributes is made at print time.sides_unsupported, a plain sentence, and nothing reaches the printer. Tested with a fake printer that lists nothing.pagesone-sided andceil(pages/2)two-sided. Rows older than the newprint_job.sheetscolumn count as one each, as before.daily_capand is never sent.docs/features/devices.md, the device page and the terminal Devices screen all say "sheets". A test holds the OpenAPI refusal lines to the route's own sentences.Behaviour change. A one-sided 20-page job is now 20 sheets against the default cap of 10. I changed two tests for that:
print.test.tsraises the grant cap to 100 for its 20-page job, and the old "1 page, then 3 pages, cap 2" case is now two 1-page jobs. The same raise went intoprint_raster.test.ts.What I chose not to do
raster.ts, which live in the morning-paper app.sides. The cap counts what was asked.two-sided-short-edge.Reused: the
probeRasterSupportpattern (ask the printer just before sending) andpermitPrint's synchronous reservation. I changed the in-flight map's value to hold sheets, so no new module-level state was added.To try:
POST /api/v1/devices/<id>/print?sides=two-sided-long-edgewith a two-page PDF and an app token on a preview.?sides=duplexshould return a 400 naming the allowed values. I have not tried it on a preview.No
reviewblock: the only page change is two labels ("sheets") on/settings/devices.🤖 Generated with Claude Code
Closes #18190