Repository navigation
Expand file tree
/
Copy pathnarrowing.ts
More file actions
62 lines (58 loc) · 2.66 KB
/
Copy pathnarrowing.ts
File metadata and controls
62 lines (58 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* The changes that may run a selection instead of the full suite once a pull request is ready for
* review (e2e/ci-selection.ts).
*
* A draft runs the spec files its `e2e` block names, as before, so an author gets an answer in
* minutes. A pull request that is ready for review and changes anything outside this table runs
* every scenario: nothing ties a source file to the scenarios that cover it, and a selection that
* missed one has turned main red after merge (a change to the SDK's tool code, selected with one
* spec file, failed an OAuth refresh scenario on main). Marking a pull request ready therefore
* starts the full suite on its head, and the merge waits for it.
*
* Each entry names paths whose changes no scenario runs through, and what runs for them instead.
* The comparison is everything the pull request changes since main, so a stack's top layer answers
* for every layer below it: a tests layer above a code layer runs the full suite.
*
* Paths ending in `/` match everything below them; others match one file, `*` standing for any
* part of a name. A path that names nothing in the tree fails a case in
* e2e/tests/ci-selection.spec.ts, so the table cannot keep entries for files that moved.
*/
import { matchesPath } from "./mcp-search-guard.ts";
export interface Narrowing {
/** What these paths hold. */
readonly holds: string;
readonly paths: ReadonlyArray<string>;
/** What a ready pull request that changes only these runs, and why that is enough. */
readonly runs: string;
}
export const narrowings: ReadonlyArray<Narrowing> = [
{
holds: "notes and plans for people and agents",
paths: ["notes/", "plans/"],
runs: "the e2e block's selection: no product code, build or scenario reads them",
},
{
holds: "the repository's own documents and agent skills",
paths: [
"README.md",
"CONTEXT.md",
"DEVELOPMENT.md",
"RELEASING.md",
"SECURITY.md",
"AGENTS.md",
".agents/",
],
runs: "the e2e block's selection: no product code, build or scenario reads them",
},
{
holds: "spec files",
paths: ["e2e/tests/*.spec.ts"],
runs: "every changed spec file, which a pull request always runs, and the e2e block's selection",
},
];
/** The table entry a file falls under, or undefined for product source and everything else. */
export const narrowingOf = (file: string) =>
narrowings.find((entry) => entry.paths.some((path) => matchesPath(path, file)));
/** The files in `files` that no entry narrows: each one makes a ready pull request run everything. */
export const broadChanges = (files: ReadonlyArray<string>) =>
files.filter((file) => narrowingOf(file) === undefined);