mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
60400d04b7
* feat(mutation): add target-annotation-serde + snapshot-occlusion kernels Both are pure decision kernels the lane's own membership rule covers (target-annotation-serde: parse/validate/normalize the .ad comment-line codec, zero I/O; snapshot-occlusion: pure covered/not-covered decision where a wrong answer silently blocks or mis-allows a tap) but were excluded from KERNEL_MODULES. Fixing the harness's packages/*/src blind spot was required, not optional: test-scope.ts, ownership.ts, and vitest.mutation.config.ts all hardcoded `src/` as the only place a kernel's tests could live. target-annotation-serde's own tests live under packages/ad-script/src/internal/__tests__/, so without this fix the module would score 0% from day one — not from weak tests, but because its test file was silently invisible to the lane. Widened the same three places, plus mutation-affected.yml's path filter and isTestFile/ownedTestFiles in ownership.ts, to also recognize packages/*/src/**/*.test.ts (mirroring vitest.config.ts's own unit-core project include list). Triaged every surviving mutant from the initial run: real coverage gaps got a new/adjusted test (kill-with-test), everything else is documented equivalent with an inline comment at the mutation site explaining the invariant that makes it unobservable (redundant early-returns, JSON.stringify dropping undefined-valued keys, Number.isFinite/isSafeInteger's total-function safety, caller-enforced positiveRect/candidate invariants, etc). Baseline recorded from the actual measured run, not inherited or guessed: 94.03% (315/335) and 89.74% (175/195). * style: run the formatter over the four files the gate flagged
45 lines
2.2 KiB
TypeScript
45 lines
2.2 KiB
TypeScript
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { defineConfig } from 'vitest/config';
|
|
import { workspaceSpecifierTargets } from './scripts/layering/package-boundaries.ts';
|
|
import { readTestScope, threadHostileTestFiles } from './scripts/mutation/test-scope.ts';
|
|
import { SUBPROCESS_STUB_TESTS } from './vitest.config.ts';
|
|
|
|
const repoRoot = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
// Workspace-package aliases for the Stryker sandbox (#1490 W0). Stryker copies
|
|
// the tree into .stryker-tmp and symlinks node_modules back to the real repo,
|
|
// so a `@agent-device/*` specifier resolved through pnpm's link escapes the
|
|
// sandbox: mutants written into the sandbox copy never load, and
|
|
// `vitest related` finds no tests for a mutated package file. Aliasing each
|
|
// EXPORTED specifier to its source file — resolved relative to this config,
|
|
// which Stryker copies into the sandbox — keeps resolution inside the mutated
|
|
// tree. Entries come from the shared exports-map reader, never a wildcard, so
|
|
// this cannot resolve package internals the boundary forbids (R11).
|
|
const workspaceAliases = [...workspaceSpecifierTargets(repoRoot)].map(([find, target]) => ({
|
|
find,
|
|
replacement: path.join(repoRoot, target),
|
|
}));
|
|
|
|
// Test scope for the decision-kernel mutation lane (issue #1415).
|
|
//
|
|
// `scripts/mutation/run.ts` derives the per-run scope from Vitest's module graph
|
|
// (`vitest related` over the mutated files) and hands it over through
|
|
// AGENT_DEVICE_MUTATION_TEST_FILES; the fallback is the deterministic unit suite,
|
|
// which keeps `pnpm exec stryker run` usable by hand. Excluded either way: the
|
|
// subprocess-stub group and the CLI-capture tests — see
|
|
// scripts/mutation/test-scope.ts for why, and why excluding them cannot hide a
|
|
// surviving mutant.
|
|
const scope = readTestScope();
|
|
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: workspaceAliases,
|
|
},
|
|
test: {
|
|
include: scope ?? ['src/**/*.test.ts', 'packages/*/src/**/*.test.ts'],
|
|
exclude: [...SUBPROCESS_STUB_TESTS, ...threadHostileTestFiles(repoRoot), '**/node_modules/**'],
|
|
setupFiles: ['src/__tests__/hermetic-env-setup.ts', 'src/__tests__/process-memo-setup.ts'],
|
|
},
|
|
});
|