Skip to content

refactor: nuclear-review cleanup — turnstile fail-closed, cart dedup, dead-code removal#229

Merged
arzafran merged 6 commits into
mainfrom
refactor/nuclear-review-cleanup
Jun 19, 2026
Merged

refactor: nuclear-review cleanup — turnstile fail-closed, cart dedup, dead-code removal#229
arzafran merged 6 commits into
mainfrom
refactor/nuclear-review-cleanup

Conversation

@arzafran

Copy link
Copy Markdown
Member

What this does

A maintainability pass from a whole-codebase audit. The one behavior-affecting change: Turnstile bot-verification now fails closed — if Cloudflare returns an unexpected response shape, the request is treated as not verified instead of trusting an unchecked cast. Everything else is internal cleanup that leaves runtime behavior identical: less duplicated rate-limiting in the cart, a smaller codemod engine, and removal of dead/duplicate exports.

No public API of the starter kit changes — the Select/Menu/Tabs compound components and all integration entry points are untouched.

Summary

  • fix(turnstile): validate the siteverify response with a Zod schema; on an unexpected shape, return a failed verification (fail-closed) rather than reading an as-cast success.
  • refactor(shopify): extract runCartAction so removeItem/addItem/updateItemQuantity share one IP + standard rate-limit prelude instead of inlining it three times.
  • refactor(scripts): route the ts-morph createSourceFile/getFullText/removeSourceFile lifecycle in ast-transforms through one withSourceFile helper with guaranteed cleanup (~60 fewer lines, behavior-preserving).
  • chore: remove unused batch/measure from lib/utils/raf.ts, hoist the duplicated ShaderMaterial<K>/DoubleRenderTarget webgl types into lib/webgl/utils, and drop the flat Select*/Menu*/Tabs* part exports that had zero importers.
  • docs: record the above under CHANGELOG.md [Unreleased].

Deliberately out of scope

The audit's largest finding — restructuring the snapshot/strip→re-add setup architecture — was not touched: the wrapper Canvas mount and webgl→theatre AST stripping are intentional (team-knowledge webgl-gpu-resource-effect-ownership), and the self-pruning machinery is a cross-repo contract with create-darkroom. That's a design decision for a separate discussion, not a cleanup.

Test Plan

  • bun run check green (biome + tsgo + bun test: 330 pass / 0 fail)
  • ast-transforms codemod tests unchanged; setup/satus e2e (self-prune typecheck) pass
  • Confirm Turnstile happy-path still verifies in a deployed preview

arzafran added 5 commits June 19, 2026 14:08
The Cloudflare siteverify response was read via an unchecked `as` cast. A
shape change would silently surface `success` as undefined and could be
misread. Parse with a zod schema and, on any unexpected shape, return a
failed verification so the gate stays closed.
removeItem/addItem/updateItemQuantity each inlined the same IP + standard
rate-limit prelude. Hoist it into one helper; behavior is identical.
…nsforms

Collapse the repeated createSourceFile/getFullText/removeSourceFile ceremony
across the op handlers into one helper with finally-cleanup. Behavior-
preserving; all codemod tests unchanged. ~60 fewer lines.
- raf: drop unused batch/measure exports (only mutate is consumed)
- webgl: hoist duplicated ShaderMaterial<K>/DoubleRenderTarget types to utils
- ui: remove flat Select/Menu/Tabs part exports with zero importers (the
  compound API used by stories is unchanged)
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
satus Ready Ready Preview, Comment Jun 19, 2026 5:57pm

@arzafran arzafran merged commit 1916587 into main Jun 19, 2026
11 checks passed
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