Repository navigation
refactor(cli): parse patch sources without the TypeScript API - #994
Conversation
|
Review (GPT 6.1 Sol, xhigh) and what changed. All fixed in 94e4520; each new test is red on dc39476 and green now:
|
|
Answering the FAIL verdict above: fixed in 5a2df1d.
A fresh acceptance run on 5a2df1d is next. |
|
Answering the second FAIL verdict: fixed in 678338d.
The five parser suites pass (113 tests) and |
|
Answering the third FAIL verdict: fixed in bd11f86.
The five parser suites pass (137 tests), and |
|
Answering the fourth FAIL verdict: fixed in 8e055ce. Instead of another special case, insertion now follows one rule.
The five parser suites pass (143 tests) and |
|
One more check on 8e055ce: a generator crossed brace placement (opening and closing each on their own line or beside an entry) × trailing comma or not × trailing comments (none, line, block, two blocks, block then line, multi-line block) × an own-line footer comment × 0–3 entries. That's 195 layouts, each with LF and CRLF. All four invariants held in every case: comments stay with their entries on add, removal keeps the other entries' comments, add then remove gives back the original bytes, and the output parses with its line endings intact. |
|
Answering the fifth verdict: fixed in dc83ce9.
The sweep test gains your whitespace and tab cases: 4 fail on 8e055ce, and all 78 pass now. My own generator now crosses your dimensions: 1,057 layouts × LF/CRLF, tabs and trailing whitespace included. It finds no failures on any invariant apart from |
Acceptance: PASS with notesChecked Done means This checks #994's current parser-replacement and source-preservation claims, not #985's later whole-stack TypeScript 7 criteria. The documented one-line whitespace-only empty-object normalization is allowed; every other roundtrip is checked byte for byte.
Golden journeys
Rollback answers: Compatibility matches the diff. Configs edited in between remain ordinary TypeScript readable by the prior release. Reverting code leaves those source edits in place, but no incompatible schema, API, infrastructure or persisted-config shape. No Notes
Evidence and invariant comparisonSource-level failures among the 3,040 distinct cases, applying the documented exception equally to both commits:
Counts overlap across invariants. Each commit executes all 4,608 combinations, not only the selected packed cases. Comment identity for predecessor checks ignores trailing whitespace; exact roundtrip bytes are checked separately. Inline-empty exception: 16 option executions / 4 distinct source-and-line-ending cases. Their only raw differences are the one-line horizontal-whitespace interiors Each packed cycle runs: patchy add posthog/product --as extra --json
patchy refresh --json
pnpm typecheck
patchy remove extra --json
patchy refresh --json
pnpm typecheckThe previous fixture matrix uses The Cartesian comparison explicitly uses Commands ran one at a time. Test hooks removed disposable fixtures, loopback servers, installed prefixes and test Postgres; Not run
Surface audit: CLI |
TypeScript 7 ships no JavaScript API, and the CLI used TypeScript 6's to read patch repos. It now uses @babel/parser, pure JavaScript like the rest of the offline tarball, and leaves the compiler to the repo: - `patchy add`/`remove` splice one entry into `uses` instead of reprinting the object, so the author's comments and layout survive, CRLF included. A config that doesn't parse is refused at its line. - Package pins, the page and server import checks, and the generated server module list read Babel's AST. The server graph refuses import.defer() as it refuses import(); both load at run time. - The agent/ typecheck warning asks the repo's own compiler for its file list (`tsc --showConfig`), so include, exclude and extends mean what they mean to `pnpm typecheck`, on TypeScript 6 or 7. The CLI bundle no longer carries TypeScript: the tarball drops from 35.1 MB to 22.4 MB and index.js from 13.9 MB to 3.7 MB. Part of #985. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of the Babel port found it stricter than TypeScript's parser in
three places and looser in one:
- `require?.("x")` is an OptionalCallExpression, which the check skipped,
so an aliased package could hide behind it. It is checked like require().
- Inline HTML scripts with a data type, such as JSON or an import map,
are never run by browsers and are no longer parsed. Classic inline
scripts parse as scripts, so an opening HTML comment builds again.
- TypeScript decorators parse, including legacy parameter decorators.
- TypeScript 6's --showConfig refuses an include that matches no file
(TS18003); the agent/ warning now treats that as an empty file list,
as TypeScript 7 already prints it.
- `patchy add` finds a trailing comma behind a comment, so the comment
stays with its property.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Acceptance found `patchy remove` deleting through the next entry's start, taking that entry's own comment with it, and back to the previous entry's end, taking its trailing comment. An entry on lines of its own now goes with exactly those lines, a comment ending them included; other lines stay. A last entry without a trailing comma also takes the previous entry's comma, so the object keeps its style. Adding into an empty uses that holds only comments keeps them too. Adding then removing an alias now gives back the file byte for byte, in every layout the tests cover, with LF or CRLF. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Acceptance found three more layouts where `patchy remove` or a round trip
lost bytes: a last entry whose block comment runs onto further lines
took the previous entry's comment, a comment between entries on a
one-line object went with the entry after it, and removing what was
added to `{ /* note */ }` left a stray space.
An entry's trailing comment is now one comment, on any number of lines,
with nothing after it on its last line. A last or only entry takes the
space before it, never what sits between it and its neighbour; an
object left empty closes up to `{}`. A sweep over commented layouts,
with LF and CRLF, checks that removing any entry keeps every other
entry's comments and undoes an add byte for byte.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Acceptance found comments moving onto a new entry: several comments trailing one entry (`/* a */ // b`), block comments trailing a one-line object's last entry, and comments on lines of their own after the last entry. A trailing run is now any number of comments, block comments on more lines and a line comment last. A new entry goes after everything that follows the last one: on a one-line object after its trailing comments, in a multi-line object on the closing brace's line. The sweep test now also checks that adding leaves each comment after the entry it followed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Acceptance found layouts where the opening and closing braces sit on
different kinds of lines (the first entry beside `{`, or `}` beside the
last entry's comments). The editor chose one-line or multi-line style
from the gap before the first entry, and so put the new entry between
the last one and its trailing comments.
Now one rule: everything between the last entry and the closing brace
is its separator and comments, and the new entry goes after all of it,
on a line of its own when the object ends on one, else on the same line.
An empty object's comments get the same rule, so `{ // note` no longer
swallows the new entry into its comment.
The sweep test gains the mixed-brace layouts; a local sweep over 32
layouts, LF and CRLF, keeps every comment with its entry through add and
remove and gives back the original bytes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Acceptance's systematic sweep found the last remaining byte change: a new
entry went in before the spaces ending the line it follows, so they
moved onto its line and left with it on removal. The entry now goes in
after them. An empty object spread over lines takes the entry on a line
of its own and keeps its shape after removal; only a one-line object of
spaces, `{ }`, still comes back as `{}`, as it did before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
dc83ce9 to
3df1a74
Compare
## What changed TypeScript 7's Effect checker (`@effect/tsgo`) flags `node:crypto` imports that the TypeScript 6 language service let through. Effect 4 has a `Crypto` service, so code that already runs inside Effect now takes it from its environment instead of importing Node's. Nothing anyone sees changes: every id, token, digest and stored fingerprint keeps its format. Part of #985 (step 3 of 5). Stacked on #994. ## Look at - **Moved to `Crypto`, formats unchanged:** - Fleet task ids and wake origins: UUIDv4. - Each company database's file-handle secret: still 32 random bytes in hex. Both company database constructors take `Crypto` and hand it to `Inventory.initialize`. - Table row ids: UUIDv7 on the Effect clock, the same layout the hand-rolled ones had. - File tokens and SHA-256 digests: Effect's `Hex` and `Base64Url` encode exactly as Node's `hex` and `base64url`. Checked on 32 random bytes. - The deployment config's `revision`, stored with every limit change in `deployment_revision`: still the SHA-256 hex of the values. `main` and this branch both print `af2b298c…2724e` for `PATCHY_LIMITS_JSON='{"company.connections":9}'`. - **`DeploymentConfig.load` keeps its ripple small.** `revision` is now an Effect, so only `OperatingLimits` and the `exec` entrypoint, the two that record it, need `Crypto`. The services that only read values don't. The server gets `Crypto` from `NodeHttpServer`, `exec` provides `NodeCrypto`, and so do the test layers that build fleets, table writers or operating limits. - **Kept on `node:crypto`, each with its reason:** - What Effect has no equivalent for: AES-256-GCM in `CredentialKeys`, and HMAC with a constant-time compare in `Files`. - Synchronous helpers callers outside Effect use: core `sha256`, tokens and ids, which the CLI uses too; table index names; and the look preview's CSP hash, a module constant. ## How it was verified - `pnpm build`, `pnpm typecheck` and `pnpm typecheck:tests` (exit 0), `pnpm lint` and `pnpm format:check` pass. The TypeScript 7 Effect checker reports nothing in the touched packages. - Suites that build what moved pass: limits (deployment config and operating limits), table operations, files and the files API, wakes over Postgres, the fleet controller, client documents and OAuth endpoints (163 tests); company databases on Postgres and PGlite, and tables (89 tests). - The deployment revision matches between `main` and this branch, as above. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required An internal refactor: every id, token, digest and stored revision keeps its format. - **What does a revert leave behind?** Nothing new. Rows written in between carry the same id, token, digest and revision formats as before. - **Does the release before it still work with that?** Yes. Made by Claude Opus 5.5 (Claude Code in T3 Code); reviewed by GPT 6.1 Sol. --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
## What changed Patches now publish on TypeScript 7. Publishing a patch repo still on TypeScript 6 stops before anything runs, with the exact steps for the builder's agent: upgrade TypeScript, and move lint from ESLint to Oxlint, because typescript-eslint can't run beside TypeScript 7. Published patches keep running untouched, and `patchy dev` and `patchy refresh` only warn. Each repo moves the next time someone publishes it. Closes #985 (step 5 of 5). Stacked on #1009. ## Look at - **The gate (`toolchainProcess.ts`, `repoBuild.ts`).** Publish reads the version in the repo's `node_modules/typescript`, the compiler it actually runs, rather than the declared range. It checks that against the release's `typescript.accepted` (`^7.0.2`, served by `GET /api/release`) right after the release check, before it syncs the description or runs config, Vite or the typecheck. The refusal reuses `toolchain_unsupported`, exit 1 and the existing `--json` failure shape: > This repo has TypeScript 6.0.3; this release publishes only TypeScript ^7.0.2 (tested against 7.0.2). Run: pnpm add --save-dev 'typescript@^7.0.2'. typescript-eslint doesn't run beside TypeScript 7: if the lint script runs ESLint, move it to Oxlint as .agents/skills/patchy-preact/SKILL.md says. - **The lint move (`patchy-preact` skill).** The skill now carries the scaffold's `.oxlintrc.json` and what to remove. A test fails if the documented config drifts from what `patchy init` writes. - **Docs.** ADR-0004 now treats TypeScript as a publish gate, and the CLI README and `docs/product.md` follow. `docs/product.md` also drops a stale "by TypeScript AST" left from #994. ## How it was verified - The new `cliRepoBuild` case runs against a release that requires `typescript@^99`: - `refresh` exits 0 with the warning. - `publish --json` exits 1 with `toolchain_unsupported` and the upgrade line. - The only API calls during publish are `/api/me` and `/api/release`, and `patchy.config.ts` is unchanged. - `cliRepoBuild` (13), `initProject` (15) and `packages/sdk` (34) pass. `pnpm lint`, `pnpm typecheck:tests` and the CLI's `effect-tsgo` typecheck exit 0. - The upgrade path is real: three of the company's own patch repos (52, 40 and 25 files) type-check under `[email protected]`, and lint clean under the scaffold's Oxlint config, with no code changes (see #985). - Not covered by a test: `patchy dev`'s warning. It rides the same `typescriptRefusal` check and the warnings list dev already prints. ## Release impact - [x] **Breaking** — requires action from anyone already running this - [ ] **Not breaking** — no action required A patch repo on TypeScript 6 can't publish until it moves: `pnpm add --save-dev 'typescript@^7.0.2'`, then, if its lint runs ESLint, the Oxlint config from the `patchy-preact` skill. The refusal says exactly that, so a builder's agent can do it unaided. Running patches, local dev and refresh are unaffected. Deploying this needs a What's new line telling builders their next publish asks for the move. - **What does a revert leave behind?** Patch repos moved to TypeScript 7 and Oxlint, which the release before publishes fine: it never gated TypeScript. - **Does the release before it still work with that?** Yes. Made by Claude Opus 5.5 (Claude Code in T3 Code); reviewed by GPT 6.1 Sol. Co-authored-by: Claude Opus 5.5 <[email protected]>
… 7 (#1046) ## What changed This adds release 22's What's new entry, written from `a2d1331`. It covers everything merged since release 21's `through` (`f30d8fe`), and sets the `patchy` release to `0.22.0` in `packages/patchy/package.json` and `CURRENT_RELEASE`. With this release, patch repos move to TypeScript 7 and Oxlint, and Patchy's crypto runs through one Effect service. | Change | PRs | | --- | --- | | Improved: Your agent checks patches several times faster. New repos use TypeScript 7 and Oxlint, the patchy download is a third smaller, and an existing repo's next publish asks it to move over | #989, #994, #1009, #1010 | | Behind the scenes: Patchy itself builds with TypeScript 7 and Oxlint | #989, #1009 | | Behind the scenes: Encryption, signing and ids go through one place, with tests proving stored values still open | #1000, #1041, #1042 | One merged PR gets no line: #971 is release 21's own entry. ## Look at - **The entry**, at the top of `releases` in `packages/core/src/whatsNew.ts`. It tells builders that their next publish of an existing repo will ask them to move to TypeScript 7, and that live patches keep working. That's the one behaviour change people will meet. - **Rollback safety, from the live commit `2f9f7c1` (release 21) to `a2d1331`:** - No PR in the range is labelled `one-way`, and none has a migration or an infrastructure change. - Every stored format is unchanged: ids, tokens, digests, sealed credentials, file handles and index names. The crypto PRs prove this with known-answer tests. - #1010 is Breaking for builders: publishing a TypeScript 6 repo is refused, with the command to fix it. A rollback lifts that refusal, and doesn't strand anyone. - `rollback-rehearsal` passed on every landed head. **Rollback line:** If this release misbehaves, roll back to `2f9f7c1` (release 21). ## How it was verified - **Tests.** `whatsNew.test.ts`, `WhatsNewPages.test.ts` and `schemas.test.ts` pass (21 tests), and prettier passes on the changed files. - **The stack.** All seven PRs were Sol-reviewed with every finding fixed, and each got an acceptance PASS or PASS with notes. Each landed after a rebase onto `main` that left it unchanged (range-diff `=`), with all 12 required checks passing. #1000's one red run was the known Fleet flake #1012, and it passed on rerun. - **Deploy state.** The live commit, pinned from `/healthz/deep`, is `2f9f7c1` (release 21). The Deploy run updated last succeeded, and none is unfinished. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Text and version numbers only. The `0.22.0` bump tells CLIs and patch repos installed before this deploy to upgrade, as every release does. - **What does a revert leave behind?** Nothing. - **Does the release before it still work with that?** Yes. Made by Claude Opus 5.5 (Claude Code in T3 Code). Co-authored-by: Claude Opus 5.5 <[email protected]>
What changed
The
patchyCLI no longer bundles TypeScript to read patch repos, which makes it a third smaller. TypeScript 7 ships no JavaScript API, so this is the next step of the move (#985).@babel/parserreads patch sources instead, and the repo's own compiler answers what only it knows.Part of #985 (step 2 of 5). Stacked on #989.
Look at
patchy add/patchy remove(editUses.ts) splice one entry intousesinstead of reprinting the whole object through TypeScript's printer, which reflowed indentation and dropped or moved comments. The new entry goes after everything that follows the last entry, on a line of its own when the object ends on one. Every comment stays with the entry it follows, and removal keeps every comment not on the removed entry's own lines. Adding then removing an alias gives back the file byte for byte, LF or CRLF, with one exception: a one-line object of spaces,{ }, comes back as{}, as it does on main. The existing one-line output is unchanged:uses: { "analytics": { kind: "posthog", handle: "product" } }. A config that doesn't parse is refused at the line Babel stopped on.editUses.test.tscovers each layout, a sweep of commented layouts, the refusals and the lines they name. Acceptance's runs drove most of this: see the verdicts and replies below.agent/typecheck warning (serverModules.ts) asks the repo's own compiler for its file list withtsc --showConfig. That givesinclude,excludeandextendsthe meaning they have forpnpm typecheck, on TypeScript 6 or 7, instead of re-implementing them.pageImports.ts) reads each file as Vite would. TypeScript with decorators parses with JSX outside.ts. Inline HTML scripts parse as plain JavaScript, classic or module, and data blocks such as JSON and import maps are skipped. Every existing form keeps its test: type-only imports and exports, import-equals,require,require?.()andimport.defer. One deliberate tightening: the server graph refusesimport.defer()as it already refusedimport(), because both load a module at run time.dist/index.jsdist/dev.jsHow it was verified
editUses.test.ts,pageImports.test.ts,serverModules.test.ts(the warning now runs the linked compiler),packagePin.test.tsandManagedProject.test.tspass: 151 tests. A local generator over 1,057useslayouts, with LF and CRLF, checks the editor's invariants: comments stay with their entries through add and remove, output parses, and add then remove gives back the original bytes except{ }. It finds no failures.tscon the CLI andpnpm typecheck:testspass, andpnpm lintis clean.packages/patchysuite passed 595 of 618 locally. The rest failed on a loaded shared machine (load average about 17), where a strayGET /reached the tests' localhost stub servers. The same files fail identically on build: lint with Oxlint #989's head without this change, and build: lint with Oxlint #989's CI ran them green. CI on this head is the oracle.Release impact
patchy addandremovewrite the same declarations into the same place, and now leave the rest of the file alone. A server bundle withimport.defer()was already outside the contract ("closed modules without dynamic imports").Made by Claude Opus 5.5 (Claude Code in T3 Code); reviewed by GPT 6.1 Sol.