Skip to content

Commit de99c77

Browse files
committed
fix(mutation): order sandbox aliases longest-first so subpaths resolve
Every shard of the mutation sweep aborted in Stryker's dry run with: Cannot find package '@agent-device/selectors/engine' imported from .tmp/stryker/sandbox-*/src/core/selector-pipeline.ts The alias was generated correctly; it just never won. Vite matches a STRING alias by prefix and takes the first hit, and `workspaceSpecifierTargets` emitted the bare `@agent-device/selectors` ahead of the subpath entries. The bare entry therefore captured `@agent-device/selectors/engine` and rewrote it to `…/src/index.ts/engine`, which does not exist; Node fell back to real package resolution, could not find the subpath inside the sandbox, and the dry run failed before a single mutant ran — so the shard uploaded an empty envelope instead of a report and the ratchet failed for want of one. Sorting longest specifier first makes the most specific alias win: @agent-device/selectors/engine -> packages/selectors/src/engine.ts @agent-device/selectors/ast -> packages/selectors/src/ast.ts @agent-device/selectors -> packages/selectors/src/index.ts `/ast` never tripped this because nothing in a related test set imported it; `selector-pipeline.ts` introduced the first subpath import that mattered (#1744), so the mutation lane has been unable to run since that landed. Any PR touching `scripts/mutation/**` — which fails open into the full sweep — would have hit it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SkS4S8XXrfkJ8TD1VBKkvJ
1 parent 43cb6db commit de99c77

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

vitest.mutation.config.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ const repoRoot = path.dirname(fileURLToPath(import.meta.url));
1616
// which Stryker copies into the sandbox — keeps resolution inside the mutated
1717
// tree. Entries come from the shared exports-map reader, never a wildcard, so
1818
// this cannot resolve package internals the boundary forbids (R11).
19-
const workspaceAliases = [...workspaceSpecifierTargets(repoRoot)].map(([find, target]) => ({
20-
find,
21-
replacement: path.join(repoRoot, target),
22-
}));
19+
// Longest specifier first. Vite matches a STRING alias by prefix and takes the first hit,
20+
// so a bare `@agent-device/selectors` entry ahead of `@agent-device/selectors/engine`
21+
// captures the subpath and rewrites it to `…/src/index.ts/engine`. Node then reports
22+
// `Cannot find package '@agent-device/selectors/engine'` from inside the sandbox, the dry
23+
// run fails, and every shard aborts before a single mutant runs.
24+
const workspaceAliases = [...workspaceSpecifierTargets(repoRoot)]
25+
.sort(([a], [b]) => b.length - a.length)
26+
.map(([find, target]) => ({
27+
find,
28+
replacement: path.join(repoRoot, target),
29+
}));
2330

2431
// Test scope for the decision-kernel mutation lane (issue #1415).
2532
//

0 commit comments

Comments
 (0)