Repository navigation
chore(tools): check:internals recognises the test kit's makeRequestContext - #1246
Merged
Merged
Conversation
…ntext Rule 1 now counts Object.create of a value from makeRequestContext when the file binds it by a named import (aliases included) of src/__tests__/kit/request-context. A same-named function from another module, a local one, or a method call is not matched. The two `: RequestContext` annotations that kept cache-scope.test.ts and build-version-table.test.ts counted are dropped; the baseline is unchanged.
49 of 50 tasks
ivogt
added a commit
that referenced
this pull request
Oct 23, 2026
Brings in S16 (#1248, wire-params.ts WIRE), S5 (#1245, deriveRenderPass), S15 (#1243, discovery phases), #1246 and #1247. Conflicts, each resolved by keeping S14's structure and applying S16's intent to it: - rsc/handler.ts imports: kept the request-stages.js import; dropped the classifyRequest, RequestPlan and INTERNAL_RANGO_DEBUG imports S14 had already moved out; added S16's WIRE import, still read by the code that stayed in the handler (warmup, loader refuse, redirect tracking mode, isPartialAction). - rsc/handler.ts response tail: kept the finalizeRequestResponse call; the inline partial/action interception S16 rewrote lives in request-stages.ts and now reads WIRE.partial and WIRE.action. - rsc/handler.ts terminal plans: kept the terminalPlanResponse call; the action-rewrite check, partial redirect and version-mismatch log S16 rewrote live in request-stages.ts and now read WIRE.action, WIRE.partial and WIRE.version. - testing/dispatch.ts imports: added WIRE; dropped applyStreamIdleTimeout, which the stages now call. - testing/dispatch.ts isPartial: kept S14's shape (the reverse and isAction moved into the stages) with S16's WIRE.partial. - tools/internals-baseline.json: took the stack's version; check-internals --update leaves it unchanged (rsc-param-literal 4, all in use-loader.tsx). request-stages.ts has no `_rsc_*` literal left. The handler and stages together make the same searchParams calls as S16's handler.ts: has() on action x3, partial x3, loader and warmup; get() on loader and version.
16 of 17 tasks
ivogt
added a commit
that referenced
this pull request
Oct 23, 2026
Brings in S16 (WIRE), S5 (deriveRenderPass), S15 (discovery phases), S14 and S14b (request stages, dispatch), S10b (Vercel store), S6 (ShellCaptureState), #1246 and #1247. Conflicts: - src/server/request-context.ts: S6 removed `_shellCaptureRun`, whose doc comment S9 edited. Kept S6's `_shellCaptureState` field and doc. S9's fact (the capture switch is read by `resolveOwnerLoaders`, not `fresh.ts emitStreaming`) moved to `ShellCaptureState.run` in rsc/shell-capture.ts, which carried the old text. - docs/design/ppr-shell-resume.md: S6's `_shellCaptureState.run` with S9's `resolveOwnerLoaders` settle guard in place of `fresh.ts` `emitStreaming`. - docs/internal/feature-file-map.md: one table hunk (both sides realigned the columns). Each row taken from the side that changed it; the two rows both sides changed are combined: "PPR shell caching (axis 2)" keeps S6's field names and S9's revalidation.ts link in place of fresh.ts; "Internal unit-test kit" lists S6's makeShellCaptureState and S9's makeFreshPass. - docs/internal/feature-map.md: the transition() entry keeps S15's vite/discovery/dev-server-phase.ts and S9's `revalidation.ts` without `fresh.ts`. Semantic fix: - src/server/__tests__/render-pass.bench.tsx (S5): the background re-render's RouterContext stub gave `resolveAllSegments`, which S9 removed; rerenderAndCacheRoute now calls `resolveAllSegmentsWithRevalidation`, so the stub gives that. Without it the "background re-render (stub resolution)" bench reports NaN.
6 tasks done
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.
devcorner: rango-t155 · session rango-s284
Problem
Rule 1 of
tools/check-internals.mjs(request-context-object-create) recognised aRequestContextonly throughgetRequestContext,_getRequestContext,createRequestContext, an annotation, or a same-file helper. The internal test kit'smakeRequestContext(src/__tests__/kit/request-context.ts, landed in S1) is imported from another file, soObject.create(makeRequestContext(...))in a test was invisible to the ratchet.cache-scope.test.tsandbuild-version-table.test.tscarried a: RequestContextannotation with a "Typed so check-internals counts the Object.create below" comment to keep their counts honest; without it the check reported "baseline 1, now 0" although theObject.createwas still there (finding rango-t131-c1, confirmed in rango-t131-c2).No router behaviour changes: the only
src/edits drop two type annotations and one now-unused type import in tests.Before / after (internal shape)
Before:
After:
Code changes
tools/check-internals.mjsKIT_REQUEST_CONTEXT_FACTORY/KIT_REQUEST_CONTEXT_MODULE: the kit factory is matched by import, not by name.callIsRequestContextfalls through toimportsKitFactoryAs(sf, local)when the callee identifier has no same-file declaration; it acceptsimport { makeRequestContext }orimport { makeRequestContext as x }whose relative specifier resolves (extension stripped) topackages/rangojs-router/src/__tests__/kit/request-context. A same-named function from another module, a local declaration that shadows the import, and a method callobj.makeRequestContext()are not matched.resolveRelative(importer, specifier)is extracted fromimportsBrowser(rule 4) and shared by both rules; rule 4's behaviour is unchanged.tools/check-internals.test.mjs: two tests.cache/cf/__tests__).makeRequestContextimported from./helpers.js, one from a look-alike./kit/request-context.jsthat resolves elsewhere, a method call, a local binding that shadows the kit import, and a same-file function of that name returning a plain object (the shape ofcache-key.test.ts).src/cache/__tests__/cache-scope.test.ts,src/server/__tests__/build-version-table.test.ts: the compensating annotations and their comments are dropped;build-version-table.test.tsloses its now-unusedtype RequestContextimport.Test plan
node tools/check-internals.mjs: OK, 3389 files scanned; request-context-object-create 21, internal-vi-mock 327, rsc-param-literal 71, browser-import-into-server 1. Baseline unchanged; no count moved.cache-scope.test.ts baseline 1, now 0andbuild-version-table.test.ts baseline 1, now 0(FAILED, 2 below the baseline); this checker passes.makeRequestContextadded toREQUEST_CONTEXT_FACTORIES) both new tests fail (25/27); with this checker 27/27 pass.node --test tools/*.test.mjs: 53/53 pass.vitest run src/cache/__tests__/cache-scope.test.ts src/server/__tests__/build-version-table.test.ts: 2 files, 64 tests pass.pnpm run typecheck: 16/16 tasks pass.oxlint --deny-warnings: 0 warnings, 0 errors.oxfmt --check .: clean.test:unit:allnot run: the onlysrc/change removes type annotations and a type import in the two test files above, which were run directly. No e2e: no runtime code changes.Practices
oxlint --deny-warningsandoxfmt --check .on the whole repo; nothing found.type RequestContextimport inbuild-version-table.test.tsbecame unused and is removed;cache-scope.test.tsstill uses it (a parameter at line 613), so it stays. The inline path resolution inimportsBrowseris replaced by the sharedresolveRelative, so no duplicate is left. Nothing else is left without callers.node:testcases pin the import-scoped match (positive and negative), each shown red against the base checker and a name-only variant; the two touched vitest files pass.import * as kit) of the kit is not recognised; no test uses one, and it is recorded in the header's known misses.tools/check-internals.mjs, updated here. AGENTS.md already names the test kit as the seam andpnpm check:internalsas the check; nothing else needs changing.Notes