refactor: extract metro/ folder — Phase 5#947
Merged
Conversation
Move the metro cluster into src/metro/ per plans/perfect-shape.md §5.5 (`metro/ ← metro* · client-metro*`): src/metro.ts -> src/metro/metro.ts src/metro-types.ts -> src/metro/metro-types.ts src/client-metro.ts -> src/metro/client-metro.ts src/client-metro-companion.ts-> src/metro/client-metro-companion.ts Pure path codemod, no behavior change. Imports were rewritten by a resolve-based codemod (compares resolved absolute paths, not naive string match). Also updated the three non-.ts references to the moved paths: the rslib `metro` entry, the fallow entry list, and the fallow health-baseline key. The companion-tunnel cluster (client-companion-tunnel*, companion-tunnel, client-react-devtools-companion) stays at src/ root — it is a separate domain (the future `companion/` slice) and keeps the worker process entrypoint (companion-tunnel.ts / client-companion-tunnel-worker.ts) co-located with its spawner (client-companion-tunnel.ts), so the worker entry resolution is unchanged. `npm run build` emits both dist/src/metro.js and dist/src/internal/companion-tunnel.js.
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
Member
Author
|
Reviewed against This looks ready for maintainer review. I checked the PR as a pure metro-domain move: Additional checks I ran locally while reviewing:
CI is green across 21 checks. I did not find an actionable blocker. |
|
thymikee
added a commit
that referenced
this pull request
Jun 30, 2026
Relocate the central contracts barrel into the kernel/ dependency sink alongside device/errors/redaction/snapshot (kernel now owns the pure domain types per plans/perfect-shape.md §5.5). - src/contracts.ts -> src/kernel/contracts.ts (git rename) - repoint all 44 internal importers to ../kernel/contracts.ts - rslib entry keeps key 'contracts' so dist output stays dist/src/contracts.js; the public 'agent-device/contracts' subpath is byte-identical (proven by the metro precedent in #947 and verified via build + package-exports test) - update .fallowrc.json entrypoint + fallow-baselines/health.json key Behaviorless path codemod (49 files, +57/-57). typecheck/lint/build/fallow audit/public-contract tests all green.
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
Phase 5 (layering) slice from
plans/perfect-shape.md§5.5 — extract the metro cluster fromsrc/root into asrc/metro/folder. Pure path codemod, no behavior change.§5.5 target:
metro/ ← metro* · client-metro*.Move set (→
src/metro/)metro.tsmetroentry)metro-types.tsclient-metro.tsclient-metro-companion.tsensure/stopMetroCompanion)These four form a cohesive metro domain:
metro.ts→client-metro*+metro-types;client-metro.ts→client-metro-companion+metro-types. Moving them together keeps intra-folder imports as./(unchanged); only their edges to root infra (contracts,kernel/errors,utils/*,client-companion-tunnel-contract) and their external importers were rewritten.Deliberately kept OUT (stay at
src/root)The companion-tunnel cluster —
client-companion-tunnel-contract.ts,client-companion-tunnel.ts,client-companion-tunnel-worker.ts,companion-tunnel.ts,client-react-devtools-companion.ts— is a separate domain (the futurecompanion/slice, not part ofmetro*/client-metro*). Keeping it at root avoids a reverse/sibling churn and, critically, keeps the worker process entrypoint co-located with its spawner (see below). General-purpose infra (utils,contracts,kernel) also stays out.Worker-path verification (the critical risk for this slice)
metro.tsis itself an rslib entrypoint (metro: 'src/metro.ts'), and the companion tunnel runs as a detached child process whose entry issrc/companion-tunnel.ts(rslib entryinternal/companion-tunnel). That worker is not anew Worker(new URL('./worker.ts'))thread —client-companion-tunnel.tsresolves the entry by name relative to its own built location indist/and spawns it viarunCmdDetached.client-companion-tunnel.ts) and the worker entry source (companion-tunnel.ts) both stay at root → entry-name resolution is unchanged.metro.ts(companion-tunnel.ts→client-companion-tunnel-worker.ts→metro.ts); that import was rewritten and re-bundled.npm run build(exit 0), which emits bothdist/src/metro.jsanddist/src/internal/companion-tunnel.js. Themetrooutput path is keyed by the entry name, sopackage.json./metro(→dist/src/metro.js) is unaffected.Codemod
A resolve-based node codemod: for every
.tsinsrc/test, each relative import/vi.mock/vi.importActualspecifier is resolved to an absolute path against the file's original dir, mapped through the old→new move table, and rewritten relative to the file's new dir (compares resolved paths — no naive string replace). Three non-.tsreferences were updated to the new paths: the rslibmetroentry, the.fallowrc.jsonentry list, and thefallow-baselines/health.jsonbaseline key.tsconfiguses glob includes (no change).Verification (all green)
tsc -p tsconfig.json --noEmit→ exit 0oxfmt --check src test→ exit 0;oxlint src --deny-warnings→ exit 0npm run build→ exit 0 (metro entry + companion-tunnel worker bundle both emitted)fallow audit --base origin/main→ CLEAN (no issues, 21 changed files)vitest run(full) → 314 files / 2892 tests passed; affected metro/client tests: 7 files / 58 tests passedgit grepforcommands/imports in daemon/platforms/kernel) → EMPTYPure path codemod — no runtime behavior change.