Repository navigation
refactor(core): decompose extractView into phase helpers - #2064
Merged
Merged
Conversation
extractView in view-extract.ts had grown into a single ~344-line function interleaving the no-system/orphan path, the root system view, the drill-down path, ghost-edge synthesis, and expanded-frame construction — the function most feature PRs touch (expand #1921, boundary #1822 both grew it). Split into named phase helpers, each a verbatim relocation of the original logic with explicit input/output types: - extractOrphanView — no-system-file root + drill-down under an orphan - extractRootSystemView — path=[] with at least one system - extractSystemDrillDownView — drill-down under a known system - collectPromotedChildren — child-collection phase (domain-level resource promotion), previously duplicated verbatim between the orphan-drill-down and system-drill-down branches - synthesizeGhosts / emptyGhostSynthesis — ghost-edge synthesis phase (users, ghost systems, caller ghost systems, ghost domains) - resolveExpandedServices / spliceExpandedFrames — expanded-frame construction phase (#1921 in-place service expansion) extractView itself is now a short dispatcher over the three branches. No logic, ordering, or output changed. Verified byte-identical output by rendering 80 SVGs (40 bundled example projects x shape/icon display mode) via buildAllViewsSvgProject — which recurses extractView across every drill-down path, not just the root — comparing this branch against origin/main: zero diffs. Refs #2014 (point 6) Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
This branch was successfully deployed
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
extractViewinpackages/core/src/view/view-extract.tshad grown into a single ~344-line function interleaving the no-system/orphan path, the root system view, the drill-down path, ghost-edge synthesis, and expanded-frame construction. It's the function most feature PRs touch (expand #1921, boundary #1822 both grew it), so review/merge cost concentrates there.This is a pure structural decomposition — zero behavior change. Each helper is a verbatim relocation of the original logic with an explicit input/output type; no logic, ordering, or output was altered.
New phase helpers:
extractOrphanView— no-system-file root + drill-down under an orphanextractRootSystemView—path = []with at least one systemextractSystemDrillDownView— drill-down under a known systemcollectPromotedChildren— child-collection phase (domain-level dot-notation resource promotion), previously duplicated verbatim between the orphan-drill-down and system-drill-down branches — now single-sourcedsynthesizeGhosts/emptyGhostSynthesis— ghost-edge synthesis phase (ghost users, ghost systems, caller ghost systems, ghost domains)resolveExpandedServices/spliceExpandedFrames— expanded-frame construction phase (Comprehension: single-container in-frame expansion — mixed-LOD Phase 1 (案3) #1921 in-place service expansion)extractViewitself is now a short dispatcher over the three top-level branches, threading a sharedViewExtractContext(resource maps, empty slice, entity resolver) computed once.Byte-identity evidence
Rendered 80 SVGs (40 bundled example projects ×
shape/icondisplay mode,en+ja+github-actions, coveringgetting-started,feature-samples,ec-platform(all 7 tutorial steps incl. multi-file/deploy/cross-system),deploy,deploy-only,deploy-org,org,org-only,hr-tool,migration,payment-platform,multi-file-system,client-mcp,hato) viabuildAllViewsSvgProject— which recursesextractViewacross every drill-down path it produces (system → service → domain/usecase, plus entity levels), not just the root.Compared this branch's core against
origin/main's core (same commit base,7d46eb2d):diff -rqon the two output directories — zero differences.Gates (all pass)
pnpm --filter @karasu-tools/core test— 95 files / 2366 tests passedpnpm typecheck— all workspace packagespnpm check:cycles— no circular dependenciespnpm knip— no new unused exportspnpm lint— 0 warnings / 0 errorsNo changeset needed — internal refactor only,
packages/corepublic exports and behavior are unchanged.Refs #2014 (point 6)
Test plan
pnpm --filter @karasu-tools/core testpnpm typecheckpnpm check:cyclespnpm knippnpm lintdiff -rqclean)🤖 Generated with Claude Code