mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
1f9d940bff
* refactor(capture-kit): relocate snapshot and recording zones into capture-kit
Move the ADR 0019 end-state capture zones into @agent-device/capture-kit:
- src/snapshot/** -> packages/capture-kit/src/snapshot/** (presentation,
freshness, scroll-edge-state, ios-snapshot-runtime, android occlusion)
- src/recording/** -> packages/capture-kit/src/recording/**
- src/core/snapshot-{chrome,state,tree-ingestion,node-lookup}.ts ->
packages/capture-kit/src/
- src/snapshot-quality/ test -> capture-kit presentation tree (directory
retires with its last file)
Pure renames: import re-pointing and gate updates follow in the next commit.
The snapshot-desktop-surface test parks in src/__tests__/ because it pins
the root eager-import-closure walker.
* refactor(capture-kit): re-point capture and recording consumers to the new subpaths
Rewires every consumer of the relocated snapshot/recording modules to the new @agent-device/capture-kit subpath exports, adds the 23 subpath entries to the capture-kit exports map, fixes the moved recording-scripts test's __dirname-relative paths for the deeper location, and records the completed migration in ADR 0019's end state.
* chore(gates): align layering, mutation, fallow and CI gates with the capture-kit relocation
Moves the executable-policy roots, presentation-owner constant, zone ranks, authority fixture, mutation sharding globs, stryker aliases, fallow baselines and the iOS workflow's android-owned paths-ignore entry onto the new packages/capture-kit paths, and extends the planted-red coverage to the new presentation-owner subpath.
* chore: point capture-domain source-of-truth comments at the relocated capture-kit modules
* test: point shutdown recording mock at capture-kit and cover interactor acquisition presentation
* test(capture-kit): update upstream presentation test imports
* chore(gates): follow relocated snapshot assembly in R74
* test(daemon): freeze prewarm deadline assertion clocks
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
// Selection is what the PR lane spends money on, so both halves of the rule are
|
|
// asserted end to end through the real CLI: a kernel diff selects nothing (the
|
|
// weekly sweep is the kernel report), and a lane-tooling diff selects real
|
|
// mutants rather than an empty matrix that proves nothing.
|
|
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { after, test } from 'node:test';
|
|
import { runCmdSync } from '@agent-device/host-kit/command';
|
|
import { LANE_CANARY, shardMatrix, type ShardSpec } from './modules.ts';
|
|
import { affectedMatrixFor } from './run.ts';
|
|
|
|
const repoRoot = path.resolve(import.meta.dirname, '../..');
|
|
const worktrees: string[] = [];
|
|
|
|
after(() => {
|
|
for (const dir of worktrees) {
|
|
runCmdSync('git', ['worktree', 'remove', '--force', dir], { cwd: repoRoot });
|
|
}
|
|
});
|
|
|
|
/**
|
|
* A throwaway worktree holding one commit that touches only the given files, so
|
|
* `--list-affected` runs against a real `git diff` rather than a stubbed list.
|
|
*/
|
|
function worktreeWithCommit(name: string, files: readonly string[]): string {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), `mutation-${name}-`));
|
|
fs.rmSync(dir, { recursive: true });
|
|
runCmdSync('git', ['worktree', 'add', '--detach', '--quiet', dir, 'HEAD'], { cwd: repoRoot });
|
|
worktrees.push(dir);
|
|
for (const file of files) {
|
|
fs.appendFileSync(path.join(dir, file), '\n');
|
|
}
|
|
runCmdSync('git', ['add', ...files], { cwd: dir });
|
|
// CI runners have no committer identity configured, and this commit is a
|
|
// fixture, so it carries its own rather than depending on the environment.
|
|
runCmdSync(
|
|
'git',
|
|
[
|
|
'-c',
|
|
'user.name=mutation-selection-test',
|
|
'-c',
|
|
'user.email=mutation-selection-test@invalid',
|
|
'commit',
|
|
'--quiet',
|
|
'--no-verify',
|
|
'-m',
|
|
`touch ${name}`,
|
|
],
|
|
{ cwd: dir },
|
|
);
|
|
return dir;
|
|
}
|
|
|
|
function listAffected(cwd: string): ShardSpec[] {
|
|
const result = runCmdSync(
|
|
'node',
|
|
[
|
|
'--experimental-strip-types',
|
|
path.join(repoRoot, 'scripts/mutation/run.ts'),
|
|
'--list-affected',
|
|
'--base',
|
|
'HEAD~1',
|
|
],
|
|
{ cwd },
|
|
);
|
|
assert.equal(result.exitCode, 0, result.stderr);
|
|
return JSON.parse(result.stdout.trim().split('\n').at(-1)!) as ShardSpec[];
|
|
}
|
|
|
|
test('a lane-tooling diff selects real mutants', () => {
|
|
const dir = worktreeWithCommit('tooling', ['scripts/mutation/run.ts']);
|
|
// The lane's own sources own no kernel, so derivation alone yields nothing:
|
|
// without the canary a harness change would run zero mutants.
|
|
assert.deepEqual(listAffected(dir), shardMatrix([LANE_CANARY]));
|
|
});
|
|
|
|
// The weekly sweep is the kernel report; selecting on derived ownership would
|
|
// run the full ten-shard sweep on most PRs for a report nobody gates on.
|
|
test('a kernel diff selects nothing — only a harness diff spends mutants', () => {
|
|
const dir = worktreeWithCommit('kernel', [
|
|
'packages/capture-kit/src/snapshot/scroll-edge-state.ts',
|
|
]);
|
|
assert.deepEqual(listAffected(dir), []);
|
|
assert.deepEqual(
|
|
affectedMatrixFor(['packages/capture-kit/src/snapshot/scroll-edge-state.ts']),
|
|
[],
|
|
);
|
|
});
|
|
|
|
test('a docs-only diff selects nothing', () => {
|
|
assert.deepEqual(affectedMatrixFor(['docs/agents/testing.md']), []);
|
|
});
|