bivium 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,23 @@
2
2
 
3
3
  > Run only the tests a change can affect, and never miss one.
4
4
 
5
- bivium builds a static, file-level dependency graph of a repository and walks it backwards from the files a change touches to the tests that reach them. It fails closed: anything it can't read (a non-literal `import()`, an unresolved specifier, a disk read with no declared inputs) counts as depending on everything, and a change it can't place runs the whole suite, with a reason. It picks the tests; your runner runs them.
6
-
7
- It has no dependencies and needs no install of the repository it plans: it reads the git index and the working tree, never `node_modules`. CI can plan in a job that skips the install, and skip the test jobs whose selection is `none`. It runs on Node ≥ 22 and Bun. It was extracted from [carbon-components-svelte](https://github.com/carbon-design-system/carbon-components-svelte)'s `test:changed`.
5
+ bivium builds a static, file-level dependency graph of a repository
6
+ and walks it backwards from the files a change touches to the tests that
7
+ reach them.
8
+ It fails closed: anything it can't read
9
+ (a non-literal `import()`, an unresolved specifier, a disk read with no
10
+ declared inputs) counts as depending on everything,
11
+ and a change it can't place runs the whole suite, with a reason.
12
+ It picks the tests; your runner runs them.
13
+
14
+ It has no dependencies and needs no install of the repository it plans:
15
+ it reads the git index and the working tree, never `node_modules`.
16
+ CI can plan in a job that skips the install,
17
+ and skip the test jobs whose selection is `none`.
18
+ It runs on Node ≥ 22 and Bun.
19
+ It was extracted from
20
+ [carbon-components-svelte](https://github.com/carbon-design-system/carbon-components-svelte)'s
21
+ `test:changed`.
8
22
 
9
23
  ```sh
10
24
  bun add -d bivium
@@ -41,7 +55,13 @@ $ bunx bivium run --suite unit # vitest run tests/Button.test.ts …
41
55
 
42
56
  ## What it reads
43
57
 
44
- A one-pass lexer reads JavaScript and TypeScript (`.js`, `.ts`, `.jsx`, `.tsx`, and their `m`/`c` variants), the scripts and markup expressions of `.svelte`, the scripts of `.vue`, `.astro` and `.html`, and the `script[src]`, `link[href]` and `iframe[src]` of `.html`. Only code counts: an import spelled in a string or a comment adds no edge.
58
+ A one-pass lexer reads JavaScript and TypeScript
59
+ (`.js`, `.ts`, `.jsx`, `.tsx`, and their `m`/`c` variants),
60
+ the scripts and markup expressions of `.svelte`, the scripts of `.vue`,
61
+ `.astro` and `.html`, and the `script[src]`,
62
+ `link[href]` and `iframe[src]` of `.html`.
63
+ Only code counts: an import spelled in a string
64
+ or a comment adds no edge.
45
65
 
46
66
  | It follows | As |
47
67
  |:---|:---|
@@ -57,15 +77,34 @@ A one-pass lexer reads JavaScript and TypeScript (`.js`, `.ts`, `.jsx`, `.tsx`,
57
77
  | A file's own package and its ancestors' `package.json` dependencies, and builtins | `pkg:` nodes |
58
78
  | Anything else | Unknown: the file depends on every change |
59
79
 
60
- A root `bun.lock`, `package-lock.json` or `pnpm-lock.yaml` isn't a source file: a change to one seeds the packages it changed (see [Lockfiles](#lockfiles)).
61
-
62
- Nor is a `tsconfig.json` (or a file one `extends`) or a `package.json` under `roots`: their options, `paths`, `type` or `exports` change how the files under them resolve or run, which no import says. A change to one seeds the files it governs, those it's the nearest of its kind to. A change the parsed file doesn't show (formatting, comments), or to a `package.json`'s metadata alone (`version`, `description`, `repository` and the like), seeds nothing, and a dependency change is the lockfile's.
63
-
64
- A file it can't lex cleanly is read by a regex extractor instead, which over-approximates. CSS isn't scanned: generated stylesheets reach their inputs through `edges`, and a [narrower](#narrowers) can do better.
80
+ A root `bun.lock`, `package-lock.json` or `pnpm-lock.yaml` isn't a
81
+ source file: a change to one seeds the packages it changed
82
+ (see [Lockfiles](#lockfiles)).
83
+
84
+ Nor is a `tsconfig.json` (or a file one `extends`)
85
+ or a `package.json` under `roots`: their options, `paths`,
86
+ `type` or `exports` change how the files under them resolve or run,
87
+ which no import says.
88
+ A change to one seeds the files it governs,
89
+ those it's the nearest of its kind to.
90
+ A change the parsed file doesn't show (formatting, comments),
91
+ or to a `package.json`'s metadata alone
92
+ (`version`, `description`, `repository` and the like), seeds nothing,
93
+ and a dependency change is the lockfile's.
94
+
95
+ A file it can't lex cleanly is read by a regex extractor instead,
96
+ which over-approximates.
97
+ CSS isn't scanned: generated stylesheets reach their inputs through
98
+ `edges`, and a [narrower](#narrowers) can do better.
65
99
 
66
100
  ## Config
67
101
 
68
- `bivium.config.ts` (or `.mts`, `.mjs`, `.js`, `.json`) in the repository root, or `--config <file>`. A `.ts` config needs Bun or Node ≥ 22.18. Every glob key takes one glob or a list. An unknown key is an error, since a misspelled one would quietly select less.
102
+ `bivium.config.ts` (or `.mts`, `.mjs`, `.js`, `.json`) in the repository
103
+ root, or `--config <file>`.
104
+ A `.ts` config needs Bun or Node ≥ 22.18.
105
+ Every glob key takes one glob or a list.
106
+ An unknown key is an error, since a misspelled one would quietly select
107
+ less.
69
108
 
70
109
  | Key | Meaning |
71
110
  |:---|:---|
@@ -100,7 +139,14 @@ A file it can't lex cleanly is read by a regex extractor instead, which over-app
100
139
 
101
140
  ## A change no test reaches
102
141
 
103
- A changed file under a suite's `root` that no test of the suite reaches is wired some other way (a runner config, a setup file), so the whole suite runs: the orphan rule. With the default `root`, the whole repository, any file bivium can't trace to a test runs the suite, which is sound and coarse. Set `root` on every suite to the directories its tests and sources live in, and say what the rest is:
142
+ A changed file under a suite's `root` that no test of the suite reaches
143
+ is wired some other way (a runner config, a setup file),
144
+ so the whole suite runs: the orphan rule.
145
+ With the default `root`, the whole repository,
146
+ any file bivium can't trace to a test runs the suite,
147
+ which is sound and coarse.
148
+ Set `root` on every suite to the directories its tests
149
+ and sources live in, and say what the rest is:
104
150
 
105
151
  | You changed… | and want… | Use |
106
152
  |:---|:---|:---|
@@ -114,15 +160,43 @@ A changed file under a suite's `root` that no test of the suite reaches is wired
114
160
  | a file a test lists but doesn't read (a route, a story) | the test, when one is added or deleted | `// @lists <glob>` in the test |
115
161
  | a file a build turns into what tests load | the tests that load the output | `edges` from the output to its inputs |
116
162
 
117
- A file outside `roots` that isn't ignored runs everything: it's the backstop for wiring the graph can't see, such as a CI workflow.
118
-
119
- `bivium check` lists every file under a suite's `root` that no test reaches and the config doesn't exempt, with a fix for each by what it looks like: a test's snapshot, a runner's config, or anything else. It's the list to work through when adopting bivium, and a new entry is a gap someone just added.
120
-
121
- A file's own disk reads make it unknown, but a test that hands a path to the code under test (`typecheck({ workspace: "tests/fixtures" })`), or a `hermetic` one that reads it, reads nothing the graph can see. So `check` also reads the string literals in each test, and in what the tests reach under a suite's `root`, for repository paths: relative to the root when they have a slash (`join(root, "tests/fixtures")`), and relative to the file (`new URL("fixtures", import.meta.url)`). It fails on one a change to which wouldn't select the tests that reach the file, with the `reads`, `edges` or annotation that declares it. A path whose change runs the suite anyway, as `wiring`, `self` or by the orphan rule, doesn't fail, and an unreached file's fix names where it's spelled. Strings inside brackets are skipped as data (`["src/a.ts", …]`, `map["key"]`), as are the directories a file is in and paths outside the graph. A path a test only names, such as an expected output, takes `// @lists <path>`.
163
+ A file outside `roots` that isn't ignored runs everything:
164
+ it's the backstop for wiring the graph can't see, such as a CI workflow.
165
+
166
+ `bivium check` lists every file under a suite's `root` that no test
167
+ reaches and the config doesn't exempt,
168
+ with a fix for each by what it looks like: a test's snapshot,
169
+ a runner's config, or anything else.
170
+ It's the list to work through when adopting bivium,
171
+ and a new entry is a gap someone added.
172
+
173
+ A file's own disk reads make it unknown,
174
+ but a test that hands a path to the code under test
175
+ (`typecheck({ workspace: "tests/fixtures" })`),
176
+ or a `hermetic` one that reads it, reads nothing the graph can see.
177
+ So `check` also reads the string literals in each test,
178
+ and in what the tests reach under a suite's `root`,
179
+ for repository paths: relative to the root when they have a slash
180
+ (`join(root, "tests/fixtures")`), and relative to the file
181
+ (`new URL("fixtures", import.meta.url)`).
182
+ It fails on one a change to which wouldn't select the tests that reach
183
+ the file, with the `reads`, `edges` or annotation that declares it.
184
+ A path whose change runs the suite anyway, as `wiring`,
185
+ `self` or by the orphan rule, doesn't fail,
186
+ and an unreached file's fix names where it's spelled.
187
+ Strings inside brackets are skipped as data
188
+ (`["src/a.ts", …]`, `map["key"]`), as are the directories a file is in
189
+ and paths outside the graph.
190
+ A path a test only names, such as an expected output,
191
+ takes `// @lists <path>`.
122
192
 
123
193
  ## Recipes
124
194
 
125
- **Vitest or Jest.** Name the setup files the runner loads, mirror `resolve.alias` (a Vite key like `"@/"` works as written), give snapshots to their tests, and, for a suite that runs code, skip type-only edges:
195
+ **Vitest or Jest.**
196
+ Name the setup files the runner loads,
197
+ mirror `resolve.alias` (a Vite key like `"@/"` works as written),
198
+ give snapshots to their tests, and, for a suite that runs code,
199
+ skip type-only edges:
126
200
 
127
201
  ```ts
128
202
  suites: {
@@ -140,11 +214,24 @@ alias: { "@/": "src/" },
140
214
  reads: { "src/**/*.test.{ts,tsx}": "src/$1__snapshots__/$2.test.$3.snap" },
141
215
  ```
142
216
 
143
- tsconfig `paths` (what `vite-tsconfig-paths` reads) are read without an `alias`. An extensionless `vi.mock("@/x")` resolves as an import does. A test environment the runner loads by name (`jsdom`, `happy-dom`) goes in `loadedByName` if you set it.
144
-
145
- **pnpm workspaces.** Workspace packages resolve through their `package.json` `exports`, and a `.js` specifier into one (`@acme/ui/Button.js`) reaches its `.ts` source. A `pnpm-lock.yaml` change selects through the packages it changed. Set `roots` to the packages and apps whose changes the suites should see, and a suite per test runner.
146
-
147
- **Playwright.** Map `page.goto()` URLs to the pages they open with `urls`, list pages only a `goto()` opens in `pages`, and name `playwright.config.ts` in `wiring`:
217
+ tsconfig `paths` (what `vite-tsconfig-paths` reads) are read without an
218
+ `alias`.
219
+ An extensionless `vi.mock("@/x")` resolves as an import does.
220
+ A test environment the runner loads by name (`jsdom`, `happy-dom`) goes
221
+ in `loadedByName` if you set it.
222
+
223
+ **pnpm workspaces.**
224
+ Workspace packages resolve through their `package.json` `exports`,
225
+ and a `.js` specifier into one (`@acme/ui/Button.js`) reaches its `.ts`
226
+ source.
227
+ A `pnpm-lock.yaml` change selects through the packages it changed.
228
+ Set `roots` to the packages and apps whose changes the suites need to
229
+ see, and a suite per test runner.
230
+
231
+ **Playwright.**
232
+ Map `page.goto()` URLs to the pages they open with `urls`,
233
+ list pages only a `goto()` opens in `pages`,
234
+ and name `playwright.config.ts` in `wiring`:
148
235
 
149
236
  ```ts
150
237
  e2e: {
@@ -155,13 +242,45 @@ e2e: {
155
242
  },
156
243
  ```
157
244
 
158
- **Generated code.** A content or type generator that writes into a gitignored directory (`.velite`, `.contentlayer/generated`) is an `edges` entry from what it writes to what it reads: `{ ".velite/*": ["content/**", "velite.config.ts"] }`. An import of `#velite` or `../.velite` then reaches the content, and not every change.
245
+ **Generated code.**
246
+ A content or type generator that writes into a gitignored directory
247
+ (`.velite`, `.contentlayer/generated`) is an `edges` entry from what it
248
+ writes to what it reads:
249
+ `{ ".velite/*": ["content/**", "velite.config.ts"] }`.
250
+ An import of `#velite` or `../.velite` then reaches the content,
251
+ and not every change.
159
252
 
160
253
  ## Lockfiles
161
254
 
162
- A dependency bump changes a lockfile, which no file imports. When a root `bun.lock`, `package-lock.json` (v2 or v3) or `pnpm-lock.yaml` (v6 or v9) changes, bivium diffs it against the merge base and seeds the walk with the `pkg:` nodes of the packages whose entries changed, and of every package that depends on one, so a `svelte` bump selects what imports `svelte`, or a package built on it. A `package.json` whose only change is to dependencies the lockfile records the same way counts as those packages changing.
163
-
164
- A changed package can also be used in ways the graph can't see: a CLI a test spawns, a runner, a type package. So when a change reaches a package that a `package.json` declares, or that some file imports, and that no test imports, everything runs, with the reason (`bun.lock: playwright 1.63.0 → 1.64.0, and no test imports it`), unless the package is `inert` (bivium itself always is: a bump changes which tests later plans pick, not what a test does). With `loadedByName` set, only a package with a `bin` in the lockfile, or one it lists, counts as used that way: a bump that reaches a library only a CMS config imports selects nothing. Everything also runs for a lockfile bivium can't parse, one whose settings other than its packages changed (`overrides`, patches, pnpm's `settings`, `catalogs`, or the version of pnpm itself), and a `package.json` change the lockfile doesn't record. Other lockfiles (`yarn.lock`, `bun.lockb`) are files like any other: outside the roots, a change to one runs everything.
255
+ A dependency bump changes a lockfile, which no file imports.
256
+ When a root `bun.lock`, `package-lock.json` (v2 or v3)
257
+ or `pnpm-lock.yaml` (v6 or v9) changes,
258
+ bivium diffs it against the merge base and seeds the walk with the
259
+ `pkg:` nodes of the packages whose entries changed,
260
+ and of every package that depends on one,
261
+ so a `svelte` bump selects what imports `svelte`,
262
+ or a package built on it.
263
+ A `package.json` whose only change is to dependencies the lockfile
264
+ records the same way counts as those packages changing.
265
+
266
+ A changed package can also be used in ways the graph can't see:
267
+ a CLI a test spawns, a runner, a type package.
268
+ So when a change reaches a package that a `package.json` declares,
269
+ or that some file imports, and that no test imports, everything runs,
270
+ with the reason
271
+ (`bun.lock: playwright 1.63.0 → 1.64.0, and no test imports it`),
272
+ unless the package is `inert`
273
+ (bivium itself always is: a bump changes which tests later plans pick,
274
+ not what a test does).
275
+ With `loadedByName` set, only a package with a `bin` in the lockfile,
276
+ or one it lists, counts as used that way:
277
+ a bump that reaches a library only a CMS config imports selects nothing.
278
+ Everything also runs for a lockfile bivium can't parse,
279
+ one whose settings other than its packages changed
280
+ (`overrides`, patches, pnpm's `settings`, `catalogs`, or the version of
281
+ pnpm itself), and a `package.json` change the lockfile doesn't record.
282
+ Other lockfiles (`yarn.lock`, `bun.lockb`) are files like any other:
283
+ outside the roots, a change to one runs everything.
165
284
 
166
285
  ```console
167
286
  $ bunx bivium plan
@@ -184,15 +303,65 @@ unit tests: 4 of 12 files
184
303
 
185
304
  | Command | Does |
186
305
  |:---|:---|
187
- | `bivium plan [base] [--json] [--github]` | Prints each suite's selection (`none`, the files out of how many, `all` files when each reaches a change, or `all (full run)`) and why a suite runs in full. `--json` adds the base, merge base, changed files, narrower results, changed packages, each suite's test count (`totals`), and the reasons as data (`causes`, each a `FullRunCause`: `{ kind, suites, file?, package?, narrower?, message }`). `--github` also writes each suite's selection to `$GITHUB_OUTPUT` |
306
+ | `bivium plan [base] [--json] [--github]` | Prints what it planned against (the base, its merge base, how many files changed, the config file), then each suite's selection (`none`, the files out of how many, `all` files when each reaches a change, or `all (full run)`) and why a suite runs in full. `--json` adds the base, merge base, config file, changed files, narrower results, changed packages, each suite's test count (`totals`), and the reasons as data (`causes`, each a `FullRunCause`: `{ kind, suites, file?, package?, narrower?, message }`). `--github` also writes each suite's selection to `$GITHUB_OUTPUT` |
188
307
  | `bivium run [base] [--suite <name>]` | Runs the suite's `run` command with its selection (default: the first suite), or skips it when nothing is affected |
189
308
  | `bivium why <test> [file] [--format tree\|chain\|source\|json] [--all]` | The shortest chain of edges from a changed file, or from `file`, to the test, with what spells each edge and the line it's on, and how many other changes reach the test. `--format tree` (the default) draws it from the test; `chain` reads from the change to the test; `source` prints each hop's line of source; `json` (or `--json`) prints the chain as data. `--all` shows every change's chain. For a test that isn't selected, it says what the file's chains reach instead |
190
- | `bivium check [--max-unknown <n>] [--json]` | Counts what it found by cause first, then lists every node with unknown dependencies, with where and how to fix each cause, and fails when more than `n` of them reach a test, or on one `knownUnknowns` doesn't list. A node no test depends on is listed apart and not counted: plans only run tests, so it widens nothing. Also lists the files under a suite's `root` that no test reaches, each with a fix (a change to one runs the whole suite; see [A change no test reaches](#a-change-no-test-reaches)), `tsconfig.json` files that don't parse, and [dead globs](#dead-globs), and fails on one `deadGlobs` doesn't allow or on an entry that matches none. Fails on a repository path a test spells that nothing declares (see [A change no test reaches](#a-change-no-test-reaches)). `--json` prints the report as data |
309
+ | `bivium check [--max-unknown <n>] [--json]` | Counts what it found by cause first, then lists every node with unknown dependencies, with where and how to fix each cause, and fails when more than `n` of them reach a test, or on one `knownUnknowns` doesn't list. A node no test depends on is listed apart and not counted: plans only run tests, so it widens nothing. Also lists the files under a suite's `root` that no test reaches, each with a fix (a change to one runs the whole suite; see [A change no test reaches](#a-change-no-test-reaches)), `tsconfig.json` files that don't parse, and [dead globs](#dead-globs), and fails on one `deadGlobs` doesn't allow or on an entry that matches none. Fails on a repository path a test spells that nothing declares (see [A change no test reaches](#a-change-no-test-reaches)). `--json` prints the report as data, with `ok` (what the exit status says) and `summary` (the counts the text leads with) |
191
310
  | `bivium graph [--suite <name>] [--top <n>] [--json]` | How many of each suite's tests a change to each file selects through the graph (leaving out the tests that run on any change, which it counts apart): the `n` files that reach the most, and how files spread from none to every test. A few hub files that reach most tests are what make plans wide. `--json` prints each suite's `total` and `everyChange` tests, and every node with its `imports` and `importers` (file edges), `fanIn` per suite and whether it's `unknown` |
192
311
 
193
- `--config`, `--cwd` and `--no-cache` work with every command, before or after it, and `why` and `check` take `--base <ref>`. `--help` (or `-h`) prints usage. An unknown command, option or `--format` is an error. Exit status: 0 when done, 1 when `check` finds problems, 2 for a usage or configuration error; `run` exits with its command's status.
312
+ `--config`, `--cwd` and `--no-cache` work with every command,
313
+ before or after it, and `why` and `check` take `--base <ref>`.
314
+ An option takes its value as `--flag value` or `--flag=value`,
315
+ and a switch such as `--json` also takes `=true` or `=false`.
316
+ A path may be repo-relative, relative to the current directory
317
+ (`./tests/a.test.ts`) or absolute.
318
+ `--help` (or `-h`) prints usage.
319
+ An unknown command, option, suite, test or `--format` is an error,
320
+ which names what's close when something is
321
+ (`unknown option --jsno (did you mean --json?)`).
322
+ Exit status: 0 when done, 1 when `check` finds problems, 2 for a usage,
323
+ configuration or git error; `run` exits with its command's status.
324
+
325
+ Every JSON output carries `schemaVersion`, which is `1`;
326
+ a change that drops or retypes a field bumps it, and new fields don't.
327
+ With `--json`, an error is also printed to stdout as JSON,
328
+ so a pipeline that parses stdout gets an object either way:
329
+
330
+ ```json
331
+ { "schemaVersion": 1, "error": { "kind": "git", "message": "bivium: no commit nosuchref here to diff against: fetch it." } }
332
+ ```
194
333
 
195
- `why` names each edge by what spells it: `import`, `type` (an `import type`, `export type … from`, JSDoc type, or an edge to or from a declaration file), `setup` (a suite's setup file), `goto` (a page `page.goto()` opens), `html` (a module an HTML page loads: `script[src]`, `link[href]`, `iframe[src]` or an inline script's import), `name` (a named import bound to a barrel name) and `export` (the file that exports it), `glob` (`import.meta.glob`), `depends-on`, `edges` (the config's), `reads` and `lists`.
334
+ `kind` is `usage` (bivium was called wrong),
335
+ `config`
336
+ (the config can't be read or is invalid; the message names the file and
337
+ lists every unknown key at once), `git`
338
+ (the base or its history is missing, or git refused, in its own words)
339
+ or `other`.
340
+
341
+ ### From an agent
342
+
343
+ - `bivium plan --json` gives the selection per suite and why:
344
+ `causes` (typed) for each full run, `totals` for the scale, `changed`,
345
+ `base` and `mergeBase`.
346
+ - `bivium why <test> --format json` gives the chain from a change to a
347
+ test, each link's `kind` (`import`, `type`, `goto`, `edges`…)
348
+ and `at` (`file:line`).
349
+ - `bivium check --json` gives `ok` and a `summary` of what widens plans,
350
+ then each node with a `fix`.
351
+ - Read the exit status first: 0 done, 1 `check` found problems,
352
+ 2 an error, with `error.kind` in the JSON.
353
+
354
+ `why` names each edge by what spells it:
355
+ `import`, `type`
356
+ (an `import type`, `export type … from`, JSDoc type, or an edge to or
357
+ from a declaration file), `setup` (a suite's setup file),
358
+ `goto` (a page `page.goto()` opens),
359
+ `html`
360
+ (a module an HTML page loads: `script[src]`, `link[href]`, `iframe[src]`
361
+ or an inline script's import), `name`
362
+ (a named import bound to a barrel name)
363
+ and `export` (the file that exports it), `glob` (`import.meta.glob`),
364
+ `depends-on`, `edges` (the config's), `reads` and `lists`.
196
365
 
197
366
  ```console
198
367
  $ bunx bivium why e2e/accordion.test.ts
@@ -231,7 +400,8 @@ selected: e2e/accordion.test.ts ← src/AccordionItem.svelte (5 hops)
231
400
  + 1 more change reaches this test: css/_accordion.scss (--all shows each chain)
232
401
  ```
233
402
 
234
- For a test that depends on every change, `chain` says why, where, and how to fix it, as `check` does:
403
+ For a test that depends on every change, `chain` says why, where,
404
+ and how to fix it, as `check` does:
235
405
 
236
406
  ```console
237
407
  $ bunx bivium why tests/e2e.test.ts --format chain
@@ -245,14 +415,25 @@ tests/e2e.test.ts runs on every change
245
415
 
246
416
  ## Dead globs
247
417
 
248
- A typo'd `@depends-on`, or one pointing only at files the planner skips, looks fine and never selects its file. `check` evaluates every `@depends-on`, `@reads`, `@lists` and `import.meta.glob` pattern, every `edges` and `reads` value, and every suite's `setup`, against every file git lists (tracked and untracked, inside the roots or not) and reports one that:
418
+ A typo'd `@depends-on`, or one pointing only at files the planner skips,
419
+ looks fine and never selects its file.
420
+ `check` evaluates every `@depends-on`, `@reads`,
421
+ `@lists` and `import.meta.glob` pattern,
422
+ every `edges` and `reads` value, and every suite's `setup`,
423
+ against every file git lists
424
+ (tracked and untracked, inside the roots or not) and reports one that:
249
425
 
250
426
  | Problem | Means |
251
427
  |:---|:---|
252
428
  | matches nothing | No file matches: a typo or a stale path |
253
429
  | matches only ignored files, partly ignored | Some matches are ignored and not in the graph, so a change to one selects nothing |
254
430
 
255
- A config value with captures is dead only when it matches nothing for every file its key matches, and a key that matches no file the graph reads is reported too, under the config's file. An ignored file the graph reads still seeds a walk, and a change outside the roots runs everything, so neither is dead. A glob that's dead on purpose goes in `deadGlobs` with a reason:
431
+ A config value with captures is dead only when it matches nothing for
432
+ every file its key matches, and a key that matches no file the graph
433
+ reads is reported too, under the config's file.
434
+ An ignored file the graph reads still seeds a walk,
435
+ and a change outside the roots runs everything, so neither is dead.
436
+ A glob that's dead on purpose goes in `deadGlobs` with a reason:
256
437
 
257
438
  ```ts
258
439
  deadGlobs: [
@@ -262,7 +443,8 @@ deadGlobs: [
262
443
 
263
444
  ## CI
264
445
 
265
- Plan in a job of its own, before any install, and feed each suite's job its selection:
446
+ Plan in a job of its own, before any install,
447
+ and feed each suite's job its selection:
266
448
 
267
449
  ```yaml
268
450
  jobs:
@@ -299,41 +481,79 @@ jobs:
299
481
 
300
482
  ### The checkout
301
483
 
302
- A plan compares the branch with its merge base: the commit where it forked from the base branch. So the job needs the history back to that commit, not just the commit under test. `actions/checkout` fetches one commit by default (`fetch-depth: 1`), with no base branch, and the plan stops with what's missing:
484
+ A plan compares the branch with its merge base:
485
+ the commit where it forked from the base branch.
486
+ So the job needs the history back to that commit,
487
+ not only the commit under test.
488
+ `actions/checkout` fetches one commit by default (`fetch-depth: 1`),
489
+ with no base branch, and the plan stops with what's missing:
303
490
 
304
491
  ```
305
492
  bivium: origin/main and HEAD share no commit here, so there's no merge base to diff against. The clone is shallow: fetch the history (actions/checkout: `fetch-depth: 0`).
306
493
  ```
307
494
 
308
- `fetch-depth: 0` fetches every commit. Only a job that plans needs it; one that runs every test anyway, such as a push to the default branch, can keep the default: `fetch-depth: ${{ github.event_name == 'pull_request' && '0' || '1' }}`.
309
-
310
- The history git fetches is three kinds of object: commits, trees (each directory's file names, each with the ID of its content) and blobs (the contents). A plan needs the commits, to find the merge base, and the trees, to list what changed. Of the blobs it needs the working tree's, which the checkout has, and the merge base's version of a few changed files only: a lockfile, a `package.json`, a `tsconfig.json`, a barrel, and what a narrower reads. So pick the clone by how big the history is:
495
+ `fetch-depth: 0` fetches every commit.
496
+ Only a job that plans needs it; one that runs every test anyway,
497
+ such as a push to the default branch, can keep the default:
498
+ `fetch-depth: ${{ github.event_name == 'pull_request' && '0' || '1' }}`.
499
+
500
+ The history git fetches is three kinds of object:
501
+ commits, trees
502
+ (each directory's file names, each with the ID of its content)
503
+ and blobs (the contents).
504
+ A plan needs the commits, to find the merge base, and the trees,
505
+ to list what changed.
506
+ Of the blobs it needs the working tree's, which the checkout has,
507
+ and the merge base's version of a few changed files only:
508
+ a lockfile, a `package.json`, a `tsconfig.json`, a barrel,
509
+ and what a narrower reads.
510
+ So pick the clone by how big the history is:
311
511
 
312
512
  | History | Checkout | What a plan pays |
313
513
  | :--- | :--- | :--- |
314
514
  | Small: a full clone takes a second or two | `fetch-depth: 0` | Nothing more: every old version is already on disk |
315
515
  | Large: years of commits, big files | `fetch-depth: 0` and `filter: blob:none` | A fetch from the remote for the old versions it reads, when a change needs any: about a second, sometimes several |
316
516
 
317
- `filter: blob:none` makes a partial clone: every commit and tree, and only the blobs the checkout needs. Git fetches any other blob when something reads it, and fetches for reads made at once run in parallel. Without the filter, a large history's old contents are most of the download; with it, a small repository pays a round trip to the remote for contents it could have had for free.
517
+ `filter: blob:none` makes a partial clone: every commit and tree,
518
+ and only the blobs the checkout needs.
519
+ Git fetches any other blob when something reads it,
520
+ and fetches for reads made at once run in parallel.
521
+ Without the filter, a large history's old contents are most of the
522
+ download; with it, a small repository pays a round trip to the remote
523
+ for contents it could have had for free.
318
524
 
319
525
  ### The cache
320
526
 
321
- The cache holds what bivium extracted from each file, keyed by git blob, so a warm plan reads only the files a branch changed. Key it on the merge base: a pull request can restore caches from the default branch, whose run at that commit is the one to hit. Without `node_modules`, the cache lives in `.bivium/cache`; it writes a `.gitignore` so it never shows up as a change.
527
+ The cache holds what bivium extracted from each file, keyed by git blob,
528
+ so a warm plan reads only the files a branch changed.
529
+ Key it on the merge base: a pull request can restore caches from the
530
+ default branch, whose run at that commit is the one to hit.
531
+ Without `node_modules`, the cache lives in `.bivium/cache`;
532
+ it writes a `.gitignore` so it never shows up as a change.
322
533
 
323
534
  ### What a plan costs
324
535
 
325
- Measured on an Apple M-series laptop under load (median of five, wall time):
536
+ Measured on an Apple M-series laptop under load
537
+ (median of five, wall time):
326
538
 
327
539
  | Repository | Files | Bun, no cache | Bun, warm | Node 24, no cache | Node 24, warm | Cache |
328
540
  |:---|---:|---:|---:|---:|---:|---:|
329
541
  | carbon-components-svelte | 4,680 | 0.15 s | 0.09 s | 0.27 s | 0.13 s | 452 KB |
330
542
  | generated TypeScript, 23 MB | 7,000 | 0.14 s | 0.08 s | 0.30 s | 0.12 s | 896 KB |
331
543
 
332
- So the cache is optional at this size, `bunx --bun` is worth it, and planning inside a test job (no extra job, no install) costs well under a second. A cold plan of the generated repository peaks at 88 MB of RSS on Bun and 124 MB on Node.
544
+ So the cache is optional at this size, `bunx --bun` is worth it,
545
+ and planning inside a test job (no extra job, no install) costs well
546
+ under a second.
547
+ A cold plan of the generated repository peaks at 88 MB of RSS on Bun
548
+ and 124 MB on Node.
333
549
 
334
550
  ## Narrowers
335
551
 
336
- Some changes reach every test through a generated file: every page loads the compiled stylesheet, so any style edit selects every e2e test. A narrower replaces such a change's coarse seeds with finer ones from a semantic diff, such as the sources that render a changed CSS rule.
552
+ Some changes reach every test through a generated file:
553
+ every page loads the compiled stylesheet,
554
+ so any style edit selects every e2e test.
555
+ A narrower replaces such a change's coarse seeds with finer ones from a
556
+ semantic diff, such as the sources that render a changed CSS rule.
337
557
 
338
558
  ```ts
339
559
  narrowers: [
@@ -351,7 +571,18 @@ narrowers: [
351
571
  ],
352
572
  ```
353
573
 
354
- The matched files still seed the walk, but it stops at the `opaque` nodes, and the seeds stand in for them. A narrower can only narrow: its suites' selection is cut to what the walk without it selects. One that returns `{ all: reason }`, throws, or returns anything else runs its suites in full with the reason. `narrow()` gets the repository `root`, the merge base and the working tree as `base` and `head` (each with `commit` and `read(path)`), the matched `changed` files, and a read-only `graph` (`nodes()`, `importers(node)`, `dependents(nodes)`, `tests(suite)`). [`eval/carbon/css-narrower.ts`](eval/carbon/css-narrower.ts) is carbon-components-svelte's, over crassus.
574
+ The matched files still seed the walk,
575
+ but it stops at the `opaque` nodes, and the seeds stand in for them.
576
+ A narrower can only narrow: its suites' selection is cut to what the
577
+ walk without it selects.
578
+ One that returns `{ all: reason }`, throws,
579
+ or returns anything else runs its suites in full with the reason.
580
+ `narrow()` gets the repository `root`,
581
+ the merge base and the working tree as `base`
582
+ and `head` (each with `commit` and `read(path)`),
583
+ the matched `changed` files, and a read-only `graph`
584
+ (`nodes()`, `importers(node)`, `dependents(nodes)`, `tests(suite)`).
585
+ carbon-components-svelte runs one over crassus.
355
586
 
356
587
  ## From code
357
588
 
@@ -363,7 +594,14 @@ const result = await plan({ config, base: "origin/main" });
363
594
  result.suites.unit; // { mode: "some", files: [...] }; result.suites.e2e is a type error
364
595
  ```
365
596
 
366
- `plan(options?)` takes `cwd`, `base`, `config` (default: the config file in `cwd`) and `cache`, and returns each suite's selection, its test count, the reasons as sentences and as data, the packages a lockfile change seeded or found inert, the base, merge base and changed files, and what each narrower returned. Given a config, the suite names carry through to the result's type. The package exports only `plan`, `defineConfig` and their types.
597
+ `plan(options?)`
598
+ takes `cwd`, `base`, `config` (default: the config file in `cwd`)
599
+ and `cache`, and returns each suite's selection, its test count,
600
+ the reasons as sentences and as data,
601
+ the packages a lockfile change seeded or found inert, the base,
602
+ merge base and changed files, and what each narrower returned.
603
+ Given a config, the suite names carry through to the result's type.
604
+ The package exports only `plan`, `defineConfig` and their types.
367
605
 
368
606
  ## Compared with
369
607