fix: keep each application's Next.js cache apart and fail a deploy with no build, for PR previews #91
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #91"
general
weight: 0.35
Ethan-Arrowood
<img src="https://github.com/user-attachments/assets/3a23025f-8faf-494c-a83f-e945d16b8cb6" alt="A squirrel sorts painted pages into separate baskets for an old oak and a sapling while one bell rings over both" title="A squirrel sorts painted pages into separate baskets for an old oak and a sapling while one bell rings over both" align="right" width="256">
<!-- tour: none @a60c418 — the Changes list links each file -->
⊙ Problem
Running a Next.js app as a Harper pull request preview (HarperFast/harper#3042) showed two defects. With
dataMode=shared, preview and production shared ISR rows, so production served the preview's render, even after the drop; any two Next.js apps on one cluster collide this way. And a preview deployed without.nextwas certified, then answered 404.💡 Solution
The Harper-backed cache handler stores each application's ISR and Data Cache entries under its name, and caches nothing when it can't tell its application. A prebuilt app with no build now fails its deploy with the reason. The README gets a "Pull request previews" section.
🔧 Changes
src/cacheNamespace.cts: the plugin registers each app directory under its Harper name just beforeprepare(), and a failed start removes only its own registration. Lookups byserverDistDirare memoized, since Next.js builds a handler per request; without one, the worker's only app is used.src/CacheHandler.cts: reads and writes use<app>:<key>; with no app,getandsetdo nothing. Tags stay unprefixed: they name data, so a shared-data preview'srevalidateTag()still expires production's matching entries.src/storageKey.cts,src/UseCacheHandler.cts: the'use cache'handler's long-key hashing moves to its own module so ISR keys use it too.src/prebuilt.ts,src/plugin.ts: a missing.next,BUILD_IDor an empty one throws, and no failure row is written over the serving release's.README.md,schema.graphql: the previews section (CI build, data mode, server actions,basePath, cache directories, unsupported modes) and the new key format.integrationTests/next-16-caching.pw.ts: the route matcher reads past the app prefix.✅ Verification
getis about 0.2 µs slower thanmain, mostly hashing a fresh key string, which a real Harpergetdoes anyway when it encodes the key.mainand pass here, withprebuiltBuildIdtests;npm test257 passing. The integration suites were not run locally (no loopback alias pool here).enable_previewsandharper preview deployof a create-harper Next.js app usingcacheHandlerPath(): in shared mode production servedvariant=previewbefore; after, each app keeps its own rows and production staysvariant=production. A preview deployed without.nextnow fails:release … failed to load in its canary worker: … Prebuilt mode is enabled, but …/.next does not exist.Follow-ups filed: #87, #88, #89, #90, and a comment on #75. Companion: HarperFast/nextjs-example#6 has the preview workflows the README links.
🤖 Generated with Claude Code
Related PRs: none found
<!-- review-deferrals:start -->
Deferred findings
7ed8cc4534a9ae1eminor correctness —src/plugin.ts— Build-time handlers (Next 14 dedup, read-only children) resolve no namespace and cache nothing — NOT FILED46a82b8edf6ad17bminor reliability —src/cacheNamespace.cts— No-serverDistDir handler on a multi-app worker silently skips the cache — NOT FILED264cffa5ec318132minor data-integrity —src/plugin.ts— Prebuilt success row written before prepare can replace the serving release's row — filed https://github.com/HarperFast/nextjs/issues/899c1b2d751fc7f566minor documentation —README.md— README promises nextjs-example preview workflows not yet on its default branch — NOT FILED<!-- review-deferrals:end -->
<sub>Review-Coverage: authored=claude; ran=cursor-composer,gemini,codex,cursor-grok; late=cursor-grok:adjudicated; adjudicated=domain; declined=muse; rounds=4; full=3 @ a60c418e1eb0</sub>
<sub>Review-Attention: study ~20m (critical: schema.graphql, storageKey.cts; decisions: namespace-key-source, fail-closed-unknown-app, shared-tags, cold-cache-upgrade, do-less-alternative, requirement-shift, perf-cost) @ a60c418e1eb0</sub>