Repository navigation
refactor(router): orphan revalidation → shared parallel helper via policy args (#568 sub-item 2) - #578
Merged
Conversation
…r via policy args (#568) resolveOrphanLayoutWithRevalidation inlined ~130 lines of parallel-slot resolution that duplicated resolveParallelSegmentsWithRevalidation. The two diverged in exactly two ways; both are now explicit args on the shared helper, preserving each path BYTE-FOR-BYTE: - parentChainDefault: "type-derived" (main) seeds an unknown parent-chain slot with belongsToRoute || isNewParent; "force-render" (orphan) seeds unconditional true -- orphan parallels always belong to the route (the #482 blank-parent-chain-slot guard). Divergence (A): INTENTIONAL, carried, not normalized. - loaderOrder: "after" (main) emits a slot's loaders after the slot segment; "before" (orphan) emits them first. Divergence (B): cosmetic emission order (the client reconciler is order-insensitive), carried exactly. The orphan loop becomes a single call; the orphan layout's own loader/inherited/ handler resolution is untouched. Coverage-first: the existing parallel-revalidate-fns suite never exercised the divergent case (all orphan tests used belongsToRoute=true, where the policies coincide). Added pinning tests, written + verified green BEFORE the refactor: - (A) belongsToRoute=false, slot not in client, parent in client, zero revalidate fns -> main SKIPS the slot (component null), orphan FORCE-RENDERS it. Non-vacuous: normalizing the orphan policy turns the orphan test red. - (B) loaderOrder flips slot-vs-loader emission order; orphan chooses "before". Behavior-preserving: semantic matrix 61/61 dev+prod (no row changes), parallel e2e 65/65 dev+prod, adversarially verified byte-identical for both paths.
commit: |
6 tasks
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.
Summary
Sub-item 2 of #568 (the M11 item):
resolveOrphanLayoutWithRevalidationinlined ~130 lines of parallel-slot resolution that duplicatedresolveParallelSegmentsWithRevalidation. This folds the orphan loop into the shared helper, carrying the two divergences as explicit policy args — byte-for-byte behavior-preserving for both paths, no consumer-observable change.This is a refactor, but it touches the partial-revalidation hot path, so the bar is provable behavior-preservation. The headline is the coverage built first: the existing pinning suite silently failed to lock the divergence the issue is about, and that gap is now closed.
The two divergences, carried as policy args
parentChainDefault"type-derived"→ seed an unknown parent-chain slot withbelongsToRoute || isNewParent"force-render"→ seed unconditionaltruebelongsToRoute=false. Carried, never normalized.loaderOrder"after"→ emit a slot's loaders after the slot segment"before"→ emit them firstThe orphan loop is now a single call:
entry.shortCode === orphan.shortCode(orphan is passed asentry), so all parallel ids and the loadershortCodeOverrideare unchanged. The orphan layout's own loader / inherited-parent-loader / handler resolution (everything before the loop) is untouched.Coverage-first — the part that matters
The existing
parallel-revalidate-fns-invocation.test.tsdid not actually lock either divergence: every orphan case usedbelongsToRoute=true, where (A)'s two policies coincide, and the revalidate fns overrode the seed. It would stay green under any unification. So before refactoring, I added pinning tests (written and verified green on the unmodified code):belongsToRoute=false, slot ∉ client, parent ∈ client (isNewParent=false), zero revalidate fns (so the seed is the final decision), sentinel-returning handler so "resolved vs skipped" is observable: the main path SKIPS the slot (componentnull, handler never runs); the orphan path FORCE-RENDERS it (handler runs). Empirically non-vacuous — flipping the orphan to"type-derived"turns the orphan test red while main stays green.loaderOrderflips slot-vs-loader emission order, and the orphan path chooses"before"(a slot's loaders precede its slot segment).These stay green after the refactor — that is the behavior-preservation proof for the policy semantics.
Test plan
pnpm run typecheck— 12/12pnpm run test:unit:all(repo root) — 0 failurespnpm run lint/pnpm run format— cleansemantic-matrix— 61/61 dev + production, no row changesparallel-reval-after-action,parallel-loader-reval,parallel-loader-inherit,parallel-meta) — 65/65 dev + production (incl. the fix(router): invoke parallel slot revalidate() fns when slot missing from clientSegmentIds #482 orphan-parallel-after-action scenario)reasonstring, emission order for 1-slot / 2-slots-same-entry / 2-slots-different-entries, shortCodeOverride, all other invariants) —refuted: false, high confidenceNotes
fresh.tsvsrevalidation.tsresolution trees) remains deferred — it's a strategy-parameterized traversal, not a literal dedup (the "byte-identical" premise is false), and is tracked on Matrix-critical refactors from review (fresh/revalidation unification, trie suffix order, loader-cache rebind) #568.loaderOrderordering rested on a literal arg with no test; that latent fragility is now closed by the (B) tests.