Skip to content

chore: clear the audit, build auth against zod 4, lazy-load the AWS SDK - #44

Merged
jsnyder10 merged 3 commits into
mainfrom
chore/audit-fixes-and-dead-code
Sep 4, 2026
Merged

chore: clear the audit, build auth against zod 4, lazy-load the AWS SDK#44
jsnyder10 merged 3 commits into
mainfrom
chore/audit-fixes-and-dead-code

Conversation

@jsnyder10

Copy link
Copy Markdown
Contributor

What

Three pieces, all verified against the three consumer apps before release.

pnpm audit 95 findings → 0, overrides 9 → 3

Nearly all of it was stale transitive resolution, so the fix was bumping direct dependencies rather than pinning transitives. minimatch, hono, @hono/node-server, diff, lodash, flatted, rollup and ajv all reach a patched version on their own now.

The three that stay cannot be removed by any version bump:

Override Blocker
deepmerge-ts >=8.0.2 @prisma/config@7.10.0 pins it at exactly 7.1.5
mysql2 >=3.24.3 prisma@7.10.0 pins it at exactly 3.15.3
esbuild >=0.28.1 tsup@8.5.1 caps at ^0.27.0; the advisory is patched only in 0.28.1

prisma@8 drops both of its pins, so two of the three die when it leaves release candidate. tsup's own Renovate PR to bump esbuild (egoist/tsup#1401) is titled "abandoned" and still unmerged, and tsup has not released since November 2025.

auth now builds against zod 4

peerDependencies has always declared zod >=4.3.6 <5, but a zod: 3.25.76 override forced zod 3 into the build. The package compiled green while emitting zod 3 shapes into the published .d.ts, which do not typecheck for a consumer on zod 4. The override is gone and src/types/zod.ts supplies the AnyZodObject equivalent zod 4 removed.

AWS SDK loads only when an AWS code path runs

aws-helpers.ts imported all nine @aws-sdk/client-* packages at module scope, and every AWS scanfix file imports that helper, so any CLI command pulled the whole SDK in. Types are now import type and nine *Sdk() accessors require the real packages on first use.

node bin/stack --help drops from 140 ms to 50 ms; AWS SDK modules resolved at startup drop from 24 to 0.

Also removes roughly 3000 lines of dead code: eight .test.js files jest never ran, and thirteen source files unreachable from any entry point.

Verification

Repo Result
stack 151 tests, typecheck clean, pnpm audit 0
auth 186 tests
link3d 77 tests, typecheck clean, browser: dead-session recovery, login and logout
factiii 912 server + 316 client + 401 shared + 58 mobile tests, 10/10 typecheck, browser: protected routes and register validation
Chop-Shop 536 tests, 6/6 typecheck, browser: createAuthRouter mounts, protected page renders

Zero 5xx, zero TypeErrors and zero zod errors across all three app servers during browser QA.

Chop-Shop needed a zod 4 migration of its own — it ran zod 3.24.1 with a zodv4 alias only for the auth schema extensions, which already fails on the published 0.20.1. That is fixed in its own repo; this release does not regress it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W7W5Fzy93cBfRcRe2BqnrV

pnpm audit went from 95 findings to 0. Nearly all of it came from stale
transitive resolutions, so the fix is upgrading the direct dependencies
rather than pinning transitives:

- stack: @aws-sdk/client-* 3.1127, js-yaml 4.3.2, ts-jest 29.4.12, jest 30
- auth: @typescript-eslint 8, prisma 7.10, tsup 8.5.1, vite 7.3.6,
  drizzle-orm 0.45.2, react-router-dom 7.18.3, @vitejs/plugin-react 5.2
- root: @changesets/cli 3

Overrides drop from 9 to 3. minimatch, hono, @hono/node-server, diff,
lodash, flatted, rollup and ajv all reach a patched version on their own
now. deepmerge-ts, esbuild and mysql2 stay because prisma and tsup pin
them to an exact version no range can reach.

The zod override was hiding a real bug. validators.ts, types/hooks.ts and
procedures/passkey.ts imported AnyZodObject, which zod 3 exported and zod
4 removed, while peerDependencies has always declared ">=4.3.6 <5". The
override forced zod 3 into the workspace, so the build passed and the
emitted .d.ts carried zod 3 shapes (z.ZodObject<..., "strip",
z.ZodTypeAny, ...>) that break every consumer on zod 4. src/types/zod.ts
now defines the zod 4 equivalent, and auth builds against zod 4.5.4.

Unused dependencies: libsodium-wrappers and ts-node (stack),
better-sqlite3 with its adapter and types (auth, also drops a native
build step), and the duplicate @trpc/server devDependency that shadowed
the real one and caused a peer warning.

Dead code, roughly 3000 lines. Eight .test.js files that jest never ran
(testMatch is *.test.ts) and that fail outright when forced, plus the
fixtures and mock only they used. Thirteen source files unreachable from
bin/stack, src/index.ts or any live test: four orphan barrels, seven
modules reachable only through those barrels, and two with no references
at all. template-generator.ts goes too; the live .env.example generation
lives in factiii/scanfix/env-files.ts and port-convention.ts, and the
scanfix tests already cover the PORT slot behaviour its two tests
duplicated.

src/scripts/index.ts stays. mac/staging.ts generates remote code that
deep-requires @factiii/stack/dist/scripts/index.js.

Also runs prettier over auth/src. That check had been failing before any
of this, against its own pinned prettier.

Build, both test suites, both typechecks, auth lint and format, prisma
generate and prisma validate all pass.
aws-helpers.ts imported all nine @aws-sdk/client-* packages at module
scope. Every AWS scanfix file imports that helper, and factiii/index.ts
imports those scanfix files to build its fixes array, so requiring any
CLI command pulled the whole SDK in. Measured, that was 112 ms of a
118 ms module load — including on --help, ops, db and backup, which
never touch AWS.

The SDK types are now `import type`, which TypeScript erases, and nine
*Sdk() accessors require the real packages on first use and cache them.
Call sites construct commands through the accessor: `new
(ec2Sdk().CreateVpcCommand)({...})`. The aws-helpers re-export block for
SDK command classes is gone, since re-exporting them forced the eager
load it existed to hide.

Results: `node bin/stack --help` 140 ms -> 50 ms, module load 126 ms ->
43 ms, AWS SDK modules resolved at startup 24 -> 0. All nine packages
still load on demand, verified by constructing one command from each.

Typecheck clean, stack 151 tests and auth 186 tests pass.
Covers a25c537, which dropped the zod override that was forcing zod 3
into the auth build. Patch, not minor: peerDependencies has always
declared ">=4.3.6 <5", so a consumer on the declared zod 4 sees a fix
rather than a break.

Verified in all three consumers before release. link3d and factiii pass
unchanged. Chop-Shop needed a zod 4 migration of its own, since it ran
zod 3.24.1 with a zodv4 alias only for the auth schema extensions — that
combination already fails on the published 0.20.1, so this release does
not regress it.
@jsnyder10
jsnyder10 merged commit 34125aa into main Sep 4, 2026
1 check passed
@jsnyder10
jsnyder10 deleted the chore/audit-fixes-and-dead-code branch September 4, 2026 21:48
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