chore(layering): runner modules reach host-kit only through the runner host port - #2470
Merged
Conversation
Size Report
Startup median (7 runs, lower is better):
|
Member
Author
|
No code findings at 098f795. The rule reuses the existing import parser, covers the supported value-import forms, and keeps type-only imports exempt. The planted violation demonstrates enforcement through the real layering gate. The failed typecheck, repo guards and integration checks point to the inherited |
…r host port R77 apple-runner-host-port bans a direct @agent-device/host-kit/* value import from packages/platform-apple/src/runner/**; the port at runner/host.ts, bound in core/runner-host.ts, is the only door. runner/** sits in the eager closure of seven Apple facade entries eager-closure-budgets.ts holds at a fixed size, so a direct import grows all seven at once (#2423 measured one candidate import adding 5 modules to runner/index.ts's closure, 13 -> 18, after two review rounds spent rediscovering this).
thymikee
force-pushed
the
claude/runner-host-port-rule
branch
from
September 10, 2026 16:15
098f795 to
eae5f7a
Compare
|
Member
Author
|
The reviewed patch is unchanged at eae5f7a after the rebase, and all checks now pass. No code findings or conflicts; ready to merge. |
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.
Rule
packages/platform-apple/src/runner/**may not VALUE-import@agent-device/host-kit/*directly. The host-capability port atrunner/host.tsis the only door: a host-kit symbol the runner needs is added toAppleRunnerHostthere and bound to the real implementation incore/runner-host.ts. A type-only import (import type … from '@agent-device/host-kit/…') is exempt everywhere, since it evaluates nothing. A pure constant that both the runner and another package need does not go in host-kit either — it belongs in a runner module already inside every façade closure (e.g.runner/apple-runner-platform.ts), imported directly from there.This lands as:
runner/host.tsstating the rule and its reason.scripts/layering/apple-runner-host-port-policy.ts(R77 apple-runner-host-port), registered inscripts/layering/check.ts. Violation message: "imports '<spec>' directly. Reach host-kit through the runner host port (runner/host.ts, bound in core/runner-host.ts); a direct import grows the Apple façade eager closures (eager-closure-budgets)."scripts/layering/apple-runner-host-port-policy.test.ts: a planted violation (every import form — named, namespace, dynamic, re-export, side-effect) goes red; a type-only import (in the runner subtree and onhost.tsitself) stays green; imports outside the runner subtree and non-host-kit runner imports are untouched.Reason
runner/**sits in the eager import closure of seven Apple façade entries (app-lifecycle-facade.ts,app-resolution-facade.ts,doctor-facade.ts,perf-facade.ts,physical-device-facade.ts,runner-operations-facade.ts,runner/index.ts), each held at a fixed size (no growth against the merge-base) byscripts/__tests__/eager-closure-budgets.ts. A direct@agent-device/host-kit/*value import from a runner module adds every module on its own import path to all seven closures at once.Measured on #2423: a candidate direct
@agent-device/host-kit/commandimport fromrunner-cache-metadata.tsadded 5 modules torunner/index.ts's eager closure — 13 → 18 — per the PR's own accounting ("a static edge from that file to host-kit adds five modules to thepackages/platform-apple/src/runner/index.tseager closure, whichscripts/__tests__/eager-closure-budgets.test.tsholds at 13"). The PR spent two review rounds rediscovering the port requirement before the constant was routed back throughrunner/host.ts/core/runner-host.ts(round 1: a dependency-free module holding the constant was still +1 on all seven entries; the accepted fix in the final structural round moved the constant intorunner/apple-runner-platform.ts, a module already inside every one of the seven closures, specifically because a new host-kit-owned module was unlandable under the gate). Nothing before this PR wrote the rule down, so nothing enforced it — this closes that gap.Planted-violation output
Appending
import { runCmdSync } from '@agent-device/host-kit/command';topackages/platform-apple/src/runner/apple-runner-platform.tsand runningpnpm check:layering:Reverted before committing; the rule ran clean against
mainfirst (0 violations across the tracked runner subtree) before this PR wired it intocheck:layering, so nothing pre-existing needed a baseline table.Verification
pnpm check:layering— OK, 226/226 gate tests pass (includes the two new rule tests below).pnpm typecheck— fails with a pre-existing, unrelated error insrc/commands/cli-grammar/flag-definitions-action.ts(projectConfigmissing on theuntilflag) that reproduces identically onorigin/mainat this branch's base commit (6d08de4609,#2436), before any change in this PR. Not touched here.pnpm lint— clean.node --experimental-strip-types --test scripts/layering/apple-runner-host-port-policy.test.ts— 5/5 pass.vitest run scripts/__tests__/eager-closure-budgets.test.ts— unchanged, 581/581 pass.Motivated by the review rounds on #2423.