Repository navigation
chore(router): #684 follow-ups — DRY consolidations + docs-api guard over caching/PPR skills - #686
Merged
Merged
Conversation
…red cache key base, CFCacheStore warn-once, docs-api guard over caching/PPR skills Issue #684 groups A (DRY consolidations) and D (tooling): - safeSameOriginLanding() in redirect-origin.ts: the one answer to "where does a blocked redirect go"; redirect-guard.ts and resolveShellHitRedirectTarget (rsc-rendering.ts) now share it. - cacheKeyBase() in cache-key-utils.ts: the one host-namespaced ${host}${pathname}[:params][?search] composition; cache-scope.ts (segment tier) and document-cache.ts (document tier) both ride it. Output byte-identical to both prior inline shapes. - CFCacheStore.warnOncePerNamespace(): collapses the three open-coded once-per-namespace warn dances (no-KV read invalidation, TTL floor, no-TTL marker growth). - check:docs-api now also guards the 8 caching/PPR skills (cache-guide, caching, defer-hydration, document-cache, ppr, prerender, shell-manifest, use-cache) — the cacheTag() render-callable drift class (plan 003). Shakedown found and fixed a guard false-negative: class declarations (e.g. errors.ts Skip) matched no definition-ish position; createHydrationGate allowlisted as a userland recipe name.
commit: |
11 tasks
ivogt
marked this pull request as ready for review
July 5, 2026 13:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes out groups A (DRY consolidations) and D (tooling) of #684. Chore-class PR: no consumer-visible behavior change; cache key strings and warning text are byte-identical to before.
Problem statement
The #685 audit wave landed three new code sites that each correctly mirrored an established idiom inline (blocked-redirect landing, host-namespaced cache key, once-per-namespace warn). Idioms copied inline drift; #684-A asks for one owner each. Separately (#684-D), the caching/PPR skills teach API surface with no existence guard — the render-callable
cacheTag()drift (plan 003) recurred silently becausecheck:docs-apionly covered README + why-rango.Changes
safeSameOriginLanding(basename)— new insrc/redirect-origin.tsbeside the two resolvers.rsc/redirect-guard.ts:82andresolveShellHitRedirectTarget(rsc/rsc-rendering.ts) now share the one "where does a blocked redirect go" answer.cacheKeyBase(host, pathname, searchParams?, params?)— new insrc/cache/cache-key-utils.ts(the module that already owns the sort helpers).cache-scope.tsdropped its privategetCacheKeyBase;document-cache.tsdropped its inline default-key template. Both tiers now compose${host}${pathname}[:params][?search]from the one function; the JSDoc pins the byte-stability contract (changing the composition silently invalidates every persisted entry). The consumerkeyGeneratorbranch is untouched.CFCacheStore.warnOncePerNamespace(seen, message)— private method collapsing the three open-codednamespace ?? "default"+ Set dances (no-KV read invalidation, tagInvalidationTtl floor, no-TTL marker growth).check:docs-apinow guards the 8 caching/PPR skills (cache-guide,caching,defer-hydration,document-cache,ppr,prerender,shell-manifest,use-cache). The shakedown immediately caught two things:Skip(src/errors.ts:267, taught by the prerender skill) MISSed. Added aclass <name>alternation.createHydrationGate— a suggested userland factory name in the defer-hydration recipe, allowlisted like the existingwithCaching/withAuth.Guard now verifies 167 identifiers (was 68 over the two positioning docs).
Internal docs updated in the same PR:
feature-map.md+feature-file-map.md(three shared redirect-origin rules;cache-key-utils.tsadded to the Cache APIs row).Deliberately unchanged
keyGeneratordocument-cache branchwarnedNullCaptures/warnedRefusedCaptures(shell-capture)Test plan
pnpm run typecheckcleanpnpm run test:unit:all— all packages pass (router 108 targeted: document-cache, cf-cache-store-tags, shell-hit-redirect-guard; full recursive run green)pnpm run lint(oxlint --deny-warnings) 0/0pnpm run formatclean on all touched filesnode tools/check-docs-api.mjs— 167 identifiers verified*.gen.tschurn (verifiedgit statusempty of.gen.ts)Notes
Groups B and C of #684 are reported on the issue directly: B (shell-HIT redirect flip e2e) is not deterministically reachable through real routing — analysis with
path:lineevidence in the issue comment; C investigations ran as five independent read-only agents, verdicts posted there.