Skip to content

refactor(kit): cut comments to what the code cannot say - #494

Merged
aicayzer merged 4 commits into
mainfrom
refactor/cull-comments-kit
Dec 4, 2026
Merged

aicayzer merged 4 commits into
mainfrom
refactor/cull-comments-kit

Conversation

@aicayzer

@aicayzer aicayzer commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Comment cull for kit/, shared/ and template/ (piece 1 of 3). Comments only, no behaviour change. The lint-required empty-catch comments in kit/src/telemetry-sdk.ts are kept.

Comment lines (whole-line comments in tracked source)

Area Before After
kit 3,596 2,086
shared 187 117
template 60 49

Kept on purpose: public docs of the kit/package.json exports with every refusal, error and condition; ordering, race and security reasons; the scripted server's stub-shape and contract-citation comments; test witnesses and wait reasons. Test helper doc comments were cut; test // comments were kept except where they restated the code.

Outside claims checked (Node 26.13.1, @jsquash/jpeg 1.6.0)

  • Verified, kept short with the version: AbortSignal.timeout overflow (fires after 1 ms past 2^31, throws past 2^32); undici redirect: "error" gives a fetch failed TypeError with cause "unexpected redirect" and no code; @jsquash/jpeg defines a global ImageData when none exists; SIGUSR1 is not delivered under --permission; new URL(path, base) drops the base's last segment.
  • Not cheaply settled, comment kept short, code unchanged: jpeg-js keeping CMYK/YCCK coefficients in the heap (maxInkJpegPixels); mozjpeg as built not converting CMYK to RGB; server-side limits (30-day idempotency replay, bulk caps) are Marfa contract and were not checked against the server.

Issues to file (not filed)

  • Verify the jpeg-js ink-JPEG memory bound: maxInkJpegPixels rests on an unmeasured claim about heap use within 512 MB.
  • Check the mozjpeg CMYK claim against a newer @jsquash/jpeg: the refusal of CMYK input depends on it.

Code health

  • kit/src/run.ts: about 6,000 lines, should be split.
  • kit/src/define.ts: public types mixed with the internal outbound-journal types.
  • kit/src/marfa.ts: very large, several concerns.
  • kit/src/rows.ts: the Unreachable, Refused and Declined docs partly repeat onChange in define.ts.
  • kit/src/run.ts: the quiet set has a vague name.
  • kit/src/holds.ts and kit/src/define.ts: document the same hold rules (deletes-held, archives-held).

Tested

pnpm build, pnpm connectors:check, pnpm typecheck, pnpm lint, pnpm format:check pass. vitest run kit shared template: 1,882 of 1,883 pass; kit/test/archive-handover.test.ts fails with ENOENT because vendor/marfa-server/marfa-server is not built in the worktree. Not run: that test with the server binary, and the proof.

Review

Two rounds by withmarfa-reviewer, standard depth: comments only, checked by printing every changed file with comments removed and comparing it against main. Round one restored public conditions (verifyHmac, guardHost) and test waits, stub shapes and witnesses in about 30 files, and turned internal doc comments into // lines or cut them. A condensing pass then shortened the long public docs and moved the Unreachable, Refused and Declined details into Connector.onChange. Round two restored 10 conditions that pass dropped and corrected 2 docs it made untrue. The table shows the counts after both rounds. Merged without waiting for Full CI: the change cannot affect any job's behavior.

@aicayzer
aicayzer merged commit 025c57c into main Dec 4, 2026
3 of 4 checks passed
@aicayzer
aicayzer deleted the refactor/cull-comments-kit branch December 4, 2026 04:55

@aicayzer aicayzer left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: ready to merge with open items

Summary. Cuts comments in kit/, shared/ and template/ to what the code cannot say; it is comments only, so it cannot change behavior.

First draft: 4/5. The cut dropped public conditions from verifyHmac and guardHost and many test wait, stub-shape and witness reasons; all restored in 4abc05b. A later condensing pass dropped 10 conditions and made 2 docs untrue; all fixed in 2bae338.

Checked.

  • Done: every changed file printed with comments removed matches main.
  • True: each condensed public doc read against the old text and the code it documents.
  • Comments: kept kinds (ordering, races, outside constraints, test waits and witnesses, public refusals) and internal doc comments.

Found.

  • Public conditions lost. verifyHmac lost that malformed input is false; guardHost lost its RefusedAddress refusal. Restored in 4abc05b. True
  • Docs made untrue by condensing. thumbnailTurns described an unknown cursor wrongly, and a contract reference in the scripted server was split across lines. Fixed in 2bae338. True

For an issue.

  • JPEG decoder claims behind the thumbnail limits. A connector could run out of heap on a large CMYK JPEG if the unmeasured bound is wrong. Filed as #498.

Quick fixes. About 60 internal doc comments turned into // lines or cut, and paragraphs condensed, by the reviewer.


Reviewed by withmarfa-reviewer on Claude Sonnet 5.5. This review may contain mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant