Skip to content

refactor(core): decompose extractView into phase helpers - #2064

Merged
kompiro merged 2 commits into
mainfrom
refactor/core-extract-view-decomp
Jul 18, 2026
Merged

kompiro merged 2 commits into
mainfrom
refactor/core-extract-view-decomp

Conversation

@kompiro

@kompiro kompiro commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

extractView in packages/core/src/view/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. 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 orphan
  • extractRootSystemView — path = [] with at least one system
  • extractSystemDrillDownView — drill-down under a known system
  • collectPromotedChildren — child-collection phase (domain-level dot-notation resource promotion), previously duplicated verbatim between the orphan-drill-down and system-drill-down branches — now single-sourced
  • synthesizeGhosts / 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)

extractView itself is now a short dispatcher over the three top-level branches, threading a shared ViewExtractContext (resource maps, empty slice, entity resolver) computed once.

Byte-identity evidence

Rendered 80 SVGs (40 bundled example projects × shape/icon display mode, en + ja + github-actions, covering getting-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) via buildAllViewsSvgProject — which recurses extractView across 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 -rq on the two output directories — zero differences.

Gates (all pass)

  • pnpm --filter @karasu-tools/core test — 95 files / 2366 tests passed
  • pnpm typecheck — all workspace packages
  • pnpm check:cycles — no circular dependencies
  • pnpm knip — no new unused exports
  • pnpm lint — 0 warnings / 0 errors
  • 80-SVG byte-identity render check — zero diffs (see above)

No changeset needed — internal refactor only, packages/core public exports and behavior are unchanged.

Refs #2014 (point 6)

Test plan

  • pnpm --filter @karasu-tools/core test
  • pnpm typecheck
  • pnpm check:cycles
  • pnpm knip
  • pnpm lint
  • Byte-identity render check (80 SVGs, diff -rq clean)

🤖 Generated with Claude Code

kompiro and others added 2 commits July 18, 2026 00:59
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]>
@kompiro
kompiro merged commit 4250635 into main Jul 18, 2026
9 checks passed
@kompiro
kompiro deleted the refactor/core-extract-view-decomp branch July 18, 2026 01:31

This branch was successfully deployed

1 active deployment
preview — 773001f1 Deployed Jul 18, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant