Repository navigation
refactor: Effect Crypto replaces node:crypto inside Effect - #1000
Conversation
|
Review (GPT 6.1 Sol, xhigh) and what changed:
Everything else Sol checked held: UUIDv7 layout and Rebased onto #994's head (5a2df1d). Since the review, 3aecc51 also moves each company database's file-handle secret to |
c573729 to
17b0280
Compare
Acceptance: PASS with notesChecked Done means This checks #1000's step of #985: replacing crypto inside Effect while preserving behavior and formats. The later TypeScript 7 migration steps are outside this PR.
Golden journeys
Focused commands and observed outputRollback answers: match the diff. No migrations, wire contracts or infrastructure changes; generated data retains the prior formats, and the stored deployment fingerprint is byte-identical for the same effective values. No Not run
Notes
|
17b0280 to
d9759cf
Compare
|
Rebased onto #994's final head (dc83ce9), which changed only |
dc83ce9 to
3df1a74
Compare
TypeScript 7's Effect checker (@effect/tsgo) flags node:crypto imports the TypeScript 6 language service let through. Effect 4 has a Crypto service, so code that already runs in Effect takes it from its environment; the formats stay byte for byte: - Fleet task ids and wake origins are Crypto UUIDv4s; table row ids are Crypto UUIDv7s on the Effect clock, the layout the hand-rolled ones had. - File tokens and SHA-256 digests use Crypto with Effect's Hex and Base64Url, which encode exactly as Node's hex and base64url. - The deployment config's revision, stored with every limit change, is still the SHA-256 hex of its values. It is now an Effect, so only OperatingLimits and the exec entrypoint, which record it, need Crypto; the services that only read values don't. NodeHttpServer already provides Crypto to the server; exec provides NodeCrypto, and the test layers that build these services provide it too. What Effect has no equivalent for keeps node:crypto with its reason: AES-256-GCM, HMAC with a constant-time compare, and the synchronous helpers (core sha256/tokens/ids, index names, the look preview's CSP hash) that callers outside Effect, the CLI included, use. Part of #985. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rypto Inventory.initialize drew each company database's file-handle secret from node:crypto inside Effect; TypeScript 7's Effect checker flags it. Both company database constructors take Crypto from their environment and hand it to initialize. The secret is still 32 random bytes in hex. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ses' merge OperatingLimits now needs Crypto, which NodeServices supplies, and a Layer.mergeAll member can't feed its siblings: the Effect checker's layerMergeAllWithDependencies warning failed typecheck:tests. The four integration runtime harnesses and the Pidgeon live tier now provide NodeServices around the merge, which also covers Crypto. Co-Authored-By: Claude Opus 5.5 <[email protected]>
d9759cf to
7d6977d
Compare
## What changed Patchy now compiles with TypeScript 7, the native compiler, and nothing in the repo reads TypeScript 6 any more. Type-checking the workspace is 6–12× faster, building it 6.5× faster, and new patch repos start on TypeScript 7. Part of #985 (step 4 of 5). Stacked on #1000. ## Look at - **Effect diagnostics come from `@effect/tsgo`.** Builds and `pnpm typecheck` run `effect-tsgo tsc`, TypeScript 7 with the Effect checker built in, so `prepare` no longer patches a compiler in the shared pnpm store. That patching was the trap where one worktree's install silently turned Effect rules off in another. - The rule set is unchanged, and a canary proved `nodeBuiltinImport`, `globalDateInEffect`, `globalConsoleInEffect` and `preferSchemaOverJson` still fail the build. - Turned off, each with a reason: tsgo's default `unstableApiUsage`, since `effect/http` and `effect/sql` are used on purpose (about 5,700 hits); suggestions in `tsc` output; and the new `schemaClassObjectLiteral` warning, until #1002. - The deliberate missing-`PatchLock` test keeps its suppression; its two comments swapped order for the Go checker. - **The CLI's declarations (`scripts/build-patchy-package.mjs`).** - TypeScript 7 emits them, reading workspace packages from source, and Rolldown bundles them. Only the files the bundle publishes must emit cleanly. The dev runtime's internals infer types TypeScript can't name in a declaration, and no published type reaches them. - The release's own dependencies (Preact, signals, PGlite) are explicitly external, so pnpm's `NODE_PATH` can't pull them inline. - The published `.d.ts` files import exactly what `main`'s do: `preact`, `preact/compat`, `preact/jsx-*` and `@preact/signals`. `server.ts` and `csv.ts` joined the build's entries. - **Tests that read TypeScript's API.** The generated-client type tests and the client facade test run the real `tsc` on a temp directory (`test/typescript.ts`), and esbuild strips the types the generated-client tests execute. - **New patch repos scaffold `typescript@^7.0.2`.** The offline test registry packs TypeScript 7's platform binary for this machine and skips the other platforms'. TypeScript 7 exits 1, not 2, on type errors. Publishing still accepts TypeScript 6 until the next PR. Same 16-core machine and script as the baseline in #985, medians, uncached, with equal or higher load during these runs: | | TS 6 + ESLint (`main`) | TS 7 + Oxlint (this stack) | |---|---|---| | Type-check every project | 151 s | 25.5 s | | Type-check the tests program | 87 s | 7.1 s | | `pnpm typecheck` | 142 s | 20.9 s | | `pnpm build` | 75 s | 11.6 s | | `pnpm lint` | 38 s | 11.6 s | | `patchy --version` | 0.35 s | 0.20 s | | CLI tarball | 35.1 MB | 22.5 MB | | Patch repo `tsc --noEmit` (3 real repos) | 2.4 / 2.9 / 1.2 s | 0.39 / 0.35 / 0.24 s | | Patch repo lint | 1.3 / 1.1 / 0.6 s | 0.06 / 0.05 / 0.06 s | ## How it was verified - `pnpm typecheck` exits 0, and `pnpm build`, `pnpm lint` and `pnpm format:check` pass. - The lockfile holds only `[email protected]`: no TypeScript 6, typescript-eslint, `@effect/language-service` or rollup-plugin-dts. - `pnpm test:packed-cli-e2e` and `pnpm test:packed-preact-e2e` pass locally. Real scaffolded repos install `typescript@^7.0.2` from npm and type-check with it. - Passing suites: the TypeScript-sensitive ones (125 tests: scaffold, publish, client and generated-client types, generated server, parsers, lint rules), plus the offline tier 1 init that runs a TypeScript 7 typecheck. - Three real patch repos type-check under TypeScript 7 and lint clean under the scaffold's Oxlint with no code changes. - The full CLI suite has the same stray-`GET /` stub-server failures on this loaded machine as `main`, so CI is the oracle for those. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Build tooling, plus the scaffold's TypeScript range for new repos. Existing patch repos and their publishing are untouched here. - **What does a revert leave behind?** Patch repos created in between scaffold TypeScript 7, which the release before still publishes: 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]>
…1041) ## What changed #1000 moved the crypto that Effect's own `Crypto` covers. The rest still called `node:crypto` directly: sealing integration credentials, signing file links, HKDF for agent connections, the management secret check, and reading Clerk's JWT key. Now those take `Cryptography` from the environment. It's a new `@patchy/core` service, and its `NodeCryptography.layer` is the one place they reach Node. Nobody using Patchy sees a difference. Part of #1039. Stacked on #1010. ## Look at - **Stored values still open, through the code that reads them:** - An integration credential sealed by the old code decrypts through `CredentialKeys`. - A retry copy sealed the old way, with HKDF info, connection-id AAD and layout as before, refreshes through `AgentConnections.refresh`. - The file handle `Files` issues equals the old HMAC of the same key and binding, cut to 24 bytes. - Changing the HKDF info or the truncation fails these tests. I checked both. - HMAC-SHA256 and HKDF also match the RFC 4231 and RFC 5869 test vectors. - **Errors keep their shape:** - A failed seal is still `CredentialEncryptionFailed` with a redacted cause. - A failed open is still `CredentialDecryptionFailed`, with no cause, and still a 503. - A retry copy that won't open is still a defect. - A bad `CLERK_JWT_KEY` still fails at boot as that setting. - **One change from #1039's plan:** - `NodeCryptography.layer` requires nothing, the way Effect splits `Crypto` from `NodeCrypto`. Entrypoints and test layers provide it beside `NodeCrypto`, with no ordering between them. - The plan had it built on Effect's `Crypto`. - **One behaviour gets stricter.** A file handle whose MAC is the wrong length is now refused. Before, Node's `timingSafeEqual` threw on it. ## How it was verified - `pnpm check`: format, lint, typecheck and synth pass. - Tests: - Every suite passes except the CLI suites' stray `GET /` flake on this shared machine, which also fails on the base branch. CI decides those. - The affected suites pass: auth, credentials, files, management and `Cryptography` (309 tests). ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required This is an internal refactor. Every stored format is unchanged, and the known-answer tests above prove it for the sealed ones. - **What does a revert leave behind?** Nothing new. Values sealed or signed in between use the same 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]>
… 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]>
…loop can add (#1049) ## What changed A Fleet test failed often in CI: a refused call reported waiting 40,500 ms instead of 40,000. The call arms its 40-second wait just after it reads the clock, and the test's loop moves the clock in 500 ms steps alongside it. When a step lands between those two, the wait arms one step late. The test now accepts exactly that one step. The product code is unchanged. Closes #1012 ## Look at - **`packages/execution/src/Fleet.test.ts`, the refused call.** `found` and `refused` are still exact, and `waitedMs` must be 40,000 or 40,500, never shorter than the pool wait. This is the "asserts within one step" option from the issue. - **Why now.** This failed on `test (24)` twice in a row on #992 (run 40897302040, both attempts), with the same diff as on #1000: ``` - "waitedMs": 40000, + "waitedMs": 40500, ``` Neither #992 nor any of the speed PRs queued behind it touch this test or `fleet.ts`'s wait. They each run it on three Node versions, so it would keep blocking them. ## How it was verified - The case passes 3 of 3 locally: `pnpm vitest run packages/execution/src/Fleet.test.ts -t "says how a call found"`. - `pnpm typecheck:tests`, oxlint and prettier pass on the file. - CI on this PR runs the full suite on Node 22, 24 and 26. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Test only. - **What does a revert leave behind?** Nothing. - **Does the release before it still work with that?** Yes. Made by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, running in T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
What changed
TypeScript 7's Effect checker (
@effect/tsgo) flagsnode:cryptoimports that the TypeScript 6 language service let through. Effect 4 has aCryptoservice, 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
Crypto, formats unchanged:Cryptoand hand it toInventory.initialize.HexandBase64Urlencode exactly as Node'shexandbase64url. Checked on 32 random bytes.revision, stored with every limit change indeployment_revision: still the SHA-256 hex of the values.mainand this branch both printaf2b298c…2724eforPATCHY_LIMITS_JSON='{"company.connections":9}'.DeploymentConfig.loadkeeps its ripple small.revisionis now an Effect, so onlyOperatingLimitsand theexecentrypoint, the two that record it, needCrypto. The services that only read values don't. The server getsCryptofromNodeHttpServer,execprovidesNodeCrypto, and so do the test layers that build fleets, table writers or operating limits.node:crypto, each with its reason:CredentialKeys, and HMAC with a constant-time compare inFiles.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 typecheckandpnpm typecheck:tests(exit 0),pnpm lintandpnpm format:checkpass. The TypeScript 7 Effect checker reports nothing in the touched packages.mainand this branch, as above.Release impact
An internal refactor: every id, token, digest and stored revision keeps its format.
Made by Claude Opus 5.5 (Claude Code in T3 Code); reviewed by GPT 6.1 Sol.