From 260054fdb4ee089e3eafdfbbe1b1f3dc06cc1e45 Mon Sep 17 00:00:00 2001 From: August Cayzer Date: Fri, 4 Dec 2026 12:19:28 +0000 Subject: [PATCH 1/7] fix(host): read a bare-version start record as lost --- host/src/start-sequence.ts | 2 -- host/test/supervisor.test.ts | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/host/src/start-sequence.ts b/host/src/start-sequence.ts index 60cc0c49..f98e2552 100644 --- a/host/src/start-sequence.ts +++ b/host/src/start-sequence.ts @@ -21,8 +21,6 @@ function valid(sequence: unknown): sequence is number { export function readMintRecord(path: string): MintRecord | undefined { const text = readIfThere(path); if (text === undefined) return undefined; - // An earlier release wrote only the version, with no sequence: read it as sequence 0, not as a lost record. - if (/^\d+\.\d+\.\d+$/.test(text)) return { version: text, start_sequence: 0 }; let record: Partial | null; try { record = JSON.parse(text) as Partial | null; diff --git a/host/test/supervisor.test.ts b/host/test/supervisor.test.ts index c0605c58..1e081011 100644 --- a/host/test/supervisor.test.ts +++ b/host/test/supervisor.test.ts @@ -125,6 +125,7 @@ describe("the connector host's supervisor", () => { ["missing its sequence", '{"version":"0.0.1"}'], ["holding a version that is no text", '{"version":1,"start_sequence":4}'], ["holding a negative sequence", '{"version":"0.0.1","start_sequence":-1}'], + ["only a version", "0.0.1"], ])( "takes a launch record that is %s as lost, and mints a key it reports with", async (_, text) => { @@ -490,7 +491,7 @@ describe("the connector host's supervisor", () => { async (ownId) => { const { api, server, step, starts, home } = supervised(undefined, "off"); writeSecret(home.key("rss"), "cached-test-token"); - writeWhole(home.minted("rss"), "0.0.1"); + writeWhole(home.minted("rss"), '{"version":"0.0.1","start_sequence":0}'); const identity = vi.spyOn(api, "connectorKeyId").mockResolvedValue(ownId); api.connectors = [ assigned("rss", "0.0.1", server.serve("rss", connectorCode()), { @@ -515,7 +516,7 @@ describe("the connector host's supervisor", () => { "off", ); writeSecret(home.key("rss"), "cached-token"); - writeWhole(home.minted("rss"), "0.0.1"); + writeWhole(home.minted("rss"), '{"version":"0.0.1","start_sequence":0}'); vi.spyOn(api, "connectorKeyId").mockResolvedValue("cached-id"); const entry = assigned( "rss", From f8e5a990eef5b547e490e245ea5ad566c5811651 Mon Sep 17 00:00:00 2001 From: August Cayzer Date: Fri, 4 Dec 2026 12:21:33 +0000 Subject: [PATCH 2/7] docs(kit): state what was measured for the JPEG decoders --- kit/src/thumbnails.ts | 14 +++++++++----- kit/test/thumbnails.test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/kit/src/thumbnails.ts b/kit/src/thumbnails.ts index 43395723..f2982810 100644 --- a/kit/src/thumbnails.ts +++ b/kit/src/thumbnails.ts @@ -37,8 +37,10 @@ export const thumbnailLongSide = 256; export const maxThumbnailPixels = 25_000_000; /** - * The most pixels for a CMYK or YCCK JPEG: `jpeg-js` keeps its coefficients in - * the heap, an error no run can catch. + * The most pixels for a CMYK or YCCK JPEG, which `jpeg-js` decodes in memory + * that running out of kills the process. `jpeg-js` 0.4.4 peaked at 13 bytes a + * pixel, 208 MB at this cap, under `--max-old-space-size=512` (measured on + * Node 26.13.1). */ export const maxInkJpegPixels = 16_000_000; @@ -206,9 +208,11 @@ function jpegComponents(bytes: Uint8Array): number { return 0; } -// mozjpeg as built cannot turn CMYK or YCCK into RGB, so `jpeg-js` reads them: -// it turns the inks of an Adobe file into RGB and refuses four components with -// no Adobe marker. Strict mode refuses a damaged file rather than repair it. +// mozjpeg in `@jsquash/jpeg` 1.6.0 refuses CMYK and YCCK with "Unsupported +// color conversion request" (libjpeg has no such conversion), so `jpeg-js` +// reads them: it turns the inks of an Adobe file into RGB and refuses four +// components with no Adobe marker. Strict mode refuses a damaged file rather +// than repair it. function inkJpegSource(bytes: Uint8Array): Source { const { width, height, data } = jpegJs.decode(bytes, { useTArray: true, diff --git a/kit/test/thumbnails.test.ts b/kit/test/thumbnails.test.ts index c3c7cb82..5372b160 100644 --- a/kit/test/thumbnails.test.ts +++ b/kit/test/thumbnails.test.ts @@ -1,7 +1,9 @@ import { readFileSync } from "node:fs"; import { encode as encodePng } from "fast-png"; +import createJpegDecoder from "@jsquash/jpeg/codec/dec/mozjpeg_dec.js"; import jpegJs from "jpeg-js"; import { describe, expect, it } from "vitest"; +import { jpegDecoderWasm } from "../src/codec-wasm.js"; import type { Picture } from "../src/pictures.js"; import { makeThumbnail, @@ -604,6 +606,30 @@ describe("JPEGs as other encoders write them", () => { }, ); + it.each(["adobe-cmyk-halves.jpg", "adobe-ycck.jpg"])( + "refuses %s in the @jsquash/jpeg decoder, which is why jpeg-js reads four-ink JPEGs", + async (name) => { + const messages: string[] = []; + const decoder = await ( + createJpegDecoder as unknown as (options: object) => Promise<{ + decode(data: ArrayBuffer, preserveOrientation: boolean): unknown; + }> + )({ + noInitialRun: true, + print: () => undefined, + printErr: (message: string) => messages.push(message), + wasmBinary: jpegDecoderWasm(), + }); + const bytes = picture(name); + const data = bytes.buffer.slice( + bytes.byteOffset, + bytes.byteOffset + bytes.byteLength, + ) as ArrayBuffer; + expect(() => decoder.decode(data, false)).toThrow(); + expect(messages).toContain("Unsupported color conversion request"); + }, + ); + it("refuses a YCCK JPEG whose data stops short, as the other decoder does", async () => { const whole = picture("adobe-ycck.jpg"); expect(await refusal(whole.slice(0, Math.floor(whole.length * 0.6)))).toBe( From c4a1657913c18310d98302e0ac7fad70ebd0a84f Mon Sep 17 00:00:00 2001 From: August Cayzer Date: Fri, 4 Dec 2026 12:22:55 +0000 Subject: [PATCH 3/7] docs(google-calendar): cite the status codes Google documents --- connectors/google-calendar/src/api.ts | 9 ++++++--- connectors/google-calendar/src/write.ts | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/connectors/google-calendar/src/api.ts b/connectors/google-calendar/src/api.ts index 4160f158..412185e5 100644 --- a/connectors/google-calendar/src/api.ts +++ b/connectors/google-calendar/src/api.ts @@ -145,7 +145,9 @@ export class CalendarApi { : `${events}/${encodeURIComponent(eventId)}`; } - // Google answers 409 where the calendar already holds the id, deleted or not. + // 409 `duplicate` where the calendar already holds the id + // (developers.google.com/workspace/calendar/api/guides/errors, read 2026-12-04). + // Deleted events stay readable, so a deleted id is taken to answer 409 too; no page says so. // The create's own id is how a lost answer is found again: do not replace it with an id Google makes. async insert(calendarId: string, event: Json): Promise { const made = await this.write( @@ -160,7 +162,8 @@ export class CalendarApi { return made; } - // Google answers 412 where the event changed since `etag`. + // 412 `conditionNotMet` where `If-Match` holds a stale etag + // (developers.google.com/workspace/calendar/api/guides/version-resources, read 2026-12-04). async patch( calendarId: string, eventId: string, @@ -199,7 +202,7 @@ export class CalendarApi { } } - // Google answers 412 where the event changed since `etag`. + // The move page names no `If-Match`: 412 is taken to answer as for `patch`. async move( calendarId: string, eventId: string, diff --git a/connectors/google-calendar/src/write.ts b/connectors/google-calendar/src/write.ts index 523d0e53..52fa7947 100644 --- a/connectors/google-calendar/src/write.ts +++ b/connectors/google-calendar/src/write.ts @@ -1517,6 +1517,7 @@ async function splitAgain( const splitPiece = /_R\d{8}(?:T\d{6}Z?)?$/; // Narrow on purpose: a 400 for any other event is a refusal, since making it anew would drop what Google holds of it. +// No Google page names this 400 (read 2026-12-04). function lostSplit(error: unknown, eventId: string): boolean { return ( error instanceof GoogleError && From d9d82f3de5c378614218264a5a9519a13717e5c3 Mon Sep 17 00:00:00 2001 From: August Cayzer Date: Fri, 4 Dec 2026 12:23:23 +0000 Subject: [PATCH 4/7] docs(todoist): cite the command and completed-tasks behavior Todoist documents --- connectors/todoist/src/todoist.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/connectors/todoist/src/todoist.ts b/connectors/todoist/src/todoist.ts index 7f87cc89..cde549c6 100644 --- a/connectors/todoist/src/todoist.ts +++ b/connectors/todoist/src/todoist.ts @@ -273,7 +273,8 @@ export async function user( return ((await response.json()) as SyncAnswer).user; } -// Todoist takes a window of up to three months on its completed tasks; twelve weeks fits inside any three months. +// The completed-tasks endpoint takes a range of up to 3 months +// (developer.todoist.com/api/v1, read 2026-12-04); twelve weeks fits inside any three months. const completedWindowMs = 84 * 86_400_000; export async function completed( @@ -342,7 +343,9 @@ export function describeError(error: CommandError): string { return `${error.error ?? "an error without a message"}${code}`; } -// A resent batch reuses its command uuids: do not give a resend fresh ones. +// A resent batch reuses its command uuids: do not give a resend fresh ones. Todoist skips a command whose +// uuid a successful one already used, and remembers it at least 14 days +// (developer.todoist.com/api/v1, Command UUID, read 2026-12-04). export async function send( base: string, token: string, From 420dedb4aa733214278532cbacead1f1bffa1189 Mon Sep 17 00:00:00 2001 From: August Cayzer Date: Fri, 4 Dec 2026 12:24:31 +0000 Subject: [PATCH 5/7] docs(github): cite the transfer behavior GitHub documents --- connectors/github/src/read.ts | 7 ++++--- connectors/github/src/transfer.ts | 6 +++--- scripts/proof/github-stub.ts | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/connectors/github/src/read.ts b/connectors/github/src/read.ts index 16062411..c2342b12 100644 --- a/connectors/github/src/read.ts +++ b/connectors/github/src/read.ts @@ -2246,9 +2246,10 @@ async function readNamed( unseenComments, ); if (issueRows.length === 0 && commentRows.length === 0) continue; - // A transfer copies a comment, so the old one is gone with the issue's - // old address answering 301. Ask it, so the row follows the copy before - // it is archived with an edit waiting. + // The old issue address answers 301 after a transfer, while the old + // comment address is documented to answer only 404 (read 2026-12-04). Ask + // the issue, so the row follows the copy before it is archived with an + // edit waiting. const owners = commentRows.length === 0 ? [] diff --git a/connectors/github/src/transfer.ts b/connectors/github/src/transfer.ts index ee8f03c9..7c3fbc08 100644 --- a/connectors/github/src/transfer.ts +++ b/connectors/github/src/transfer.ts @@ -20,9 +20,9 @@ import { import { status, type Client } from "./github.js"; import { issuesByNode, nodesOfNumbers } from "./graph.js"; -// A transfer gives an issue a new node, number and address, and copies its comments with new nodes and the old times. -// The old address answering 301 to the new issue is the proof; titles are never matched. -// GitHub shows the new issue before it records the transfer, so a possible mid-transfer issue is not written until known. +// A transfer gives an issue a new node, number and address and keeps its comments. The old address answering 301 to the new issue is the proof; titles are never matched. +// GitHub documents both, with the `TransferredEvent` and the `issues.transferred` delivery (docs.github.com "Transferring an issue to another repository", REST "Get an issue", GraphQL schema, read 2026-12-04). +// Not documented, so assumed and guarded: that the comment copies get new nodes and keep their old times, and that the new issue shows before its `TransferredEvent`, so a possible mid-transfer issue is not written until known. type Context = Pick< RunContext, diff --git a/scripts/proof/github-stub.ts b/scripts/proof/github-stub.ts index 5624bca7..780d88ef 100644 --- a/scripts/proof/github-stub.ts +++ b/scripts/proof/github-stub.ts @@ -554,6 +554,7 @@ export class GitHubStub { } // A transfer makes a new issue (new id, node and number; old times, author, text and comment copies) and the old node stops resolving: its comments answer 404 and its address 301. + // GitHub documents the 301, the `TransferredEvent` and the `issues.transferred` delivery (read 2026-12-04); the copies' new nodes and old times and the lag below are assumed. // `lagging` hides the TransferredEvent until `settleTransfers`; `late` also keeps the old issue as it was; `late` with `showing` shows the event while the old issue still answers 200. transfer( issue: Issue, From 6fd81d110aadc8af13ba470c8f26c84164102957 Mon Sep 17 00:00:00 2001 From: August Cayzer Date: Fri, 4 Dec 2026 13:03:43 +0000 Subject: [PATCH 6/7] docs(kit): correct the vendor claims in the cited comments --- connectors/github/src/read.ts | 8 ++++---- connectors/github/src/transfer.ts | 6 +++--- connectors/google-calendar/src/api.ts | 2 +- kit/src/thumbnails.ts | 7 +++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/connectors/github/src/read.ts b/connectors/github/src/read.ts index c2342b12..88e060ed 100644 --- a/connectors/github/src/read.ts +++ b/connectors/github/src/read.ts @@ -2246,10 +2246,10 @@ async function readNamed( unseenComments, ); if (issueRows.length === 0 && commentRows.length === 0) continue; - // The old issue address answers 301 after a transfer, while the old - // comment address is documented to answer only 404 (read 2026-12-04). Ask - // the issue, so the row follows the copy before it is archived with an - // edit waiting. + // The old issue address answers 301 after a transfer, while the REST + // reference lists only 404 for a comment address (read 2026-12-04). Ask the + // issue, so the row follows the copy before it is archived with an edit + // waiting. const owners = commentRows.length === 0 ? [] diff --git a/connectors/github/src/transfer.ts b/connectors/github/src/transfer.ts index 7c3fbc08..f319a23f 100644 --- a/connectors/github/src/transfer.ts +++ b/connectors/github/src/transfer.ts @@ -21,8 +21,8 @@ import { status, type Client } from "./github.js"; import { issuesByNode, nodesOfNumbers } from "./graph.js"; // A transfer gives an issue a new node, number and address and keeps its comments. The old address answering 301 to the new issue is the proof; titles are never matched. -// GitHub documents both, with the `TransferredEvent` and the `issues.transferred` delivery (docs.github.com "Transferring an issue to another repository", REST "Get an issue", GraphQL schema, read 2026-12-04). -// Not documented, so assumed and guarded: that the comment copies get new nodes and keep their old times, and that the new issue shows before its `TransferredEvent`, so a possible mid-transfer issue is not written until known. +// GitHub documents the 301, the kept comments, the `TransferredEvent` and the `issues.transferred` delivery (docs.github.com "Transferring an issue to another repository", REST "Get an issue", GraphQL schema, read 2026-12-04). +// Not documented, so assumed and guarded: that the issue and its comment copies get new nodes and the comments keep their old times, and that the new issue shows before its `TransferredEvent`, so a possible mid-transfer issue is not written until known. type Context = Pick< RunContext, @@ -371,7 +371,7 @@ export async function withMovedComments( }); } -// The copies of a transfer keep the old times, so no listing of what changed since names them. +// A transfer is assumed to keep the comments' old times, so no listing of what changed since names them. export async function commentsOf( octokit: Client, issue: Issue, diff --git a/connectors/google-calendar/src/api.ts b/connectors/google-calendar/src/api.ts index 412185e5..2c61f686 100644 --- a/connectors/google-calendar/src/api.ts +++ b/connectors/google-calendar/src/api.ts @@ -147,7 +147,7 @@ export class CalendarApi { // 409 `duplicate` where the calendar already holds the id // (developers.google.com/workspace/calendar/api/guides/errors, read 2026-12-04). - // Deleted events stay readable, so a deleted id is taken to answer 409 too; no page says so. + // `get` returns a deleted event until Google drops it, so a deleted id is taken to answer 409 too; no page says so. // The create's own id is how a lost answer is found again: do not replace it with an id Google makes. async insert(calendarId: string, event: Json): Promise { const made = await this.write( diff --git a/kit/src/thumbnails.ts b/kit/src/thumbnails.ts index f2982810..14237b88 100644 --- a/kit/src/thumbnails.ts +++ b/kit/src/thumbnails.ts @@ -37,10 +37,9 @@ export const thumbnailLongSide = 256; export const maxThumbnailPixels = 25_000_000; /** - * The most pixels for a CMYK or YCCK JPEG, which `jpeg-js` decodes in memory - * that running out of kills the process. `jpeg-js` 0.4.4 peaked at 13 bytes a - * pixel, 208 MB at this cap, under `--max-old-space-size=512` (measured on - * Node 26.13.1). + * The most pixels for a CMYK or YCCK JPEG, which `jpeg-js` decodes in the + * heap, where running out ends the process. `jpeg-js` 0.4.4 peaked at 13 bytes + * a pixel, 208 MB at this cap, under `--max-old-space-size=512` (Node 26.13.1). */ export const maxInkJpegPixels = 16_000_000; From c09896b95c38bdaaf0d6ba656b5e1e22d5f536b9 Mon Sep 17 00:00:00 2001 From: August Cayzer Date: Fri, 4 Dec 2026 13:16:09 +0000 Subject: [PATCH 7/7] docs(kit): state the measured CMYK decode cost with versions --- kit/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kit/README.md b/kit/README.md index 554718bf..5195cf19 100644 --- a/kit/README.md +++ b/kit/README.md @@ -637,7 +637,7 @@ if (result.ok) properties.thumbnail = result.uri; | WebP, lossy or lossless | 200 to 280 | 310 to 480 | | JPEG in CMYK or YCCK | 470 to 750 | 810 to 1440 | - The JPEG decoder is mozjpeg in WebAssembly (`@jsquash/jpeg`). It decodes into its own memory and copies the 8-bit pixels out, so a JPEG at the limit holds its pixels twice, about 215 MB, and the peak is the same however the picture is subsampled. PNG decoding inflates the data and then unfilters it, and neither step can be skipped, so a PNG is the largest of the common kinds. Each JPEG is read by a decoder of its own, and a large picture's memory is free to go once it is read. Almost all of this memory is outside the connector's 512 MB heap, which holds JavaScript objects and not these buffers. A CMYK or YCCK JPEG is the exception: mozjpeg as built cannot turn CMYK into RGB, so `jpeg-js` reads it instead, and keeps every block of coefficients as its own small array in the heap. In the table the lower figure is a subsampled picture and the higher one is not, and a CMYK JPEG at 25 million pixels that is not subsampled would need between 320 and 384 MB of the heap, which is why such a JPEG is refused above 16 million. A connector that makes thumbnails of large pictures should make one at a time. The decoders are JavaScript and WebAssembly, carried inside the connector's bundle: nothing is read from the disk, and no process or worker starts. A connector that does not import this module does not carry them. + The JPEG decoder is mozjpeg in WebAssembly (`@jsquash/jpeg`). It decodes into its own memory and copies the 8-bit pixels out, so a JPEG at the limit holds its pixels twice, about 215 MB, and the peak is the same however the picture is subsampled. PNG decoding inflates the data and then unfilters it, and neither step can be skipped, so a PNG is the largest of the common kinds. Each JPEG is read by a decoder of its own, and a large picture's memory is free to go once it is read. Almost all of this memory is outside the connector's 512 MB heap, which holds JavaScript objects and not these buffers. A CMYK or YCCK JPEG is the exception: mozjpeg in `@jsquash/jpeg` 1.6.0 refuses CMYK and YCCK, so `jpeg-js` 0.4.4 reads it instead, and keeps every block of coefficients as its own small array in the heap. Its decode peaks at about 13 bytes a pixel, about 325 MB of the heap for a CMYK JPEG at 25 million pixels that is not subsampled, which is why such a JPEG is refused above 16 million. A connector that makes thumbnails of large pictures should make one at a time. The decoders are JavaScript and WebAssembly, carried inside the connector's bundle: nothing is read from the disk, and no process or worker starts. A connector that does not import this module does not carry them. - **It throws** only for a `maxBytes` that is not a positive whole number.