Repository navigation
refactor(core): keyed crypto goes through the Cryptography service - #1041
Conversation
Acceptance: PASS with notesChecked Done means
Golden journeys
Evidence CI on this head passed Node 24 tests, both CLI smoke jobs, browser, tier2-smoke, Clerk live, all installer platforms, lint, concurrency, release tarball and rollback rehearsal. CI run. The known shared-machine CLI stub flake was not used as a failure signal. Rollback answers: match the diff. No migrations, new persisted formats, API shapes or infrastructure changes; the previous implementation can read the same sealed values and signatures. No Not run
Notes
|
d77d0f7 to
294857d
Compare
Cryptography, in @patchy/core, is Patchy's crypto as an Effect service: its id, token and digest formats, and the keyed operations Effect's Crypto lacks. NodeCryptography.layer implements it over node:crypto, the way NodeCrypto implements Effect's Crypto. Sealed integration credentials, agent connection retry copies, file-handle MACs, persona cookies, the management secret check and Clerk's JWT key now go through it. Known-answer tests open a credential and a retry copy sealed by the old code, so stored values keep working. Part of #1039. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Seal a retry copy the way the previous release did and refresh through AgentConnections; recompute a file handle's MAC the way the previous release did and compare it with what Files issues. Both go through the code that reads stored values, so a changed HKDF info, associated data, binding or truncation fails them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
d43a6a1 to
16a5f67
Compare
## What changed This finishes #1039. Core's synchronous crypto helpers are gone. These now take `Cryptography` from their environment instead of calling `node:crypto`: - about 75 call sites of the old helpers; - 14 modules that imported `node:crypto` directly. Oxlint now refuses `node:crypto` everywhere except `NodeCryptography` and four Promise-code modules on process boundaries, so new code can't slip back. Nobody using Patchy sees a difference. Closes #1039. Stacked on #1041. ## Look at - **Stored formats are pinned:** - Table index names, which name indexes in every company database, are checked against the names earlier releases gave them. - Ids, tokens and digests are pinned in core's tests. - Setup links and device codes keep their shape tests. - Pidgeon's address-creation Idempotency-Key equals the SHA-256 the previous release sent for the same attempt. Swapping the hashed fields fails the test. - A lost mint is asked again under the same `patchy-<uuid>` key. - **The subscription commit stays one synchronous step.** It hashes with `sha256Unsafe`, named after Effect's own `nextIntUnsafe`, so nothing yields inside the commit or in `close()`. - **Where generation moved:** - Pidgeon's connect-form attempt is made by the page handler, not the pure renderer. - An action's nested call id is made inside the Effect it returns. - Mutation keys, Pidgeon idempotency keys and the dev seeds take `Cryptography` from the environment. - **The look preview** keeps its frame script's CSP hash as a constant, with a test that recomputes it from the rendered page. No crypto runs at runtime, and the Playwright spec stays plain. - **The lint rule** bans `node:crypto` and `crypto`, including inside both CLI import-boundary overrides. I checked it fires on a server file and a CLI file: - Tests and scripts are exempt. - The five files that keep the import carry an inline disable with the reason: `NodeCryptography` itself, the offline task store, and the CLI's dev state, owner lock and config runner. - **Tests** get Patchy's formats from `test/crypto.ts`, computed independently with `node:crypto`. - **Supporting changes:** - `@patchy/core/Cryptography` is exported as a subpath, so declaration emit can name the type. - AGENTS.md, the `effect-service-conventions` skill and GLOSSARY-MAP say where crypto comes from. ## How it was verified - Typecheck of the sources and the tests program both exit 0, with no warnings. Lint and format pass. - The offline suite, minus the CLI suites that flake on this shared machine, passed 2,337 tests. Two failed with the same stray-request flake and passed on rerun. CI runs everything. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required This is an internal refactor. Every id, token, digest and index name keeps its format. - **What does a revert leave behind?** Nothing new. Rows and indexes made in between have the same names and 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]>
What changed
#1000 moved the crypto that Effect's own
Cryptocovers. The rest still callednode:cryptodirectly: sealing integration credentials, signing file links, HKDF for agent connections, the management secret check, and reading Clerk's JWT key. Now those takeCryptographyfrom the environment. It's a new@patchy/coreservice, and itsNodeCryptography.layeris the one place they reach Node. Nobody using Patchy sees a difference.Part of #1039. Stacked on #1010.
Look at
CredentialKeys.AgentConnections.refresh.Filesissues equals the old HMAC of the same key and binding, cut to 24 bytes.CredentialEncryptionFailedwith a redacted cause.CredentialDecryptionFailed, with no cause, and still a 503.CLERK_JWT_KEYstill fails at boot as that setting.NodeCryptography.layerrequires nothing, the way Effect splitsCryptofromNodeCrypto. Entrypoints and test layers provide it besideNodeCrypto, with no ordering between them.Crypto.timingSafeEqualthrew on it.How it was verified
pnpm check: format, lint, typecheck and synth pass.GET /flake on this shared machine, which also fails on the base branch. CI decides those.Cryptography(309 tests).Release impact
This is an internal refactor. Every stored format is unchanged, and the known-answer tests above prove it for the sealed ones.
Made by Claude Opus 5.5 (Claude Code in T3 Code); reviewed by GPT 6.1 Sol.