bivium 0.3.3 → 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
  |:---|:---|
@@ -86,10 +125,10 @@ A file it can't lex cleanly is read by a regex extractor instead, which over-app
86
125
  | `reads` | File glob → the files it reads as text, as with `@reads`: only a direct change to one counts, so their imports and unknowns don't spread to it. An `edges` or `reads` key that names one file (no wildcard) declares what it reads, as its own `@depends-on` or `@reads` would, so its disk reads aren't unknown. Values take `$1`… as in `edges`: `{ "tests/*.test.ts": "tests/__snapshots__/$1.test.ts.snap" }` |
87
126
  | `self` | The selector's own files: a change to one runs everything. The config file is always one |
88
127
  | `importOnly` | Files only an import reaches: deleting one never orphans a suite |
89
- | `hermetic` | Files whose disk reads and non-literal imports reach no file of the repository: a library's `fs` calls on its caller's paths, a test that reads only the temporary files it writes. They add no unknown |
128
+ | `hermetic` | Files whose disk reads and non-literal imports reach no file of the repository: a library's `fs` calls on its caller's paths, a test that reads only the temporary files it writes. They add no unknown, and `check` still flags a repository path one spells that nothing declares |
90
129
  | `barrels` | Modules that may bind named imports. Default: every module made only of re-exports |
91
130
  | `external` | Packages a dependency installs that your code imports without declaring |
92
- | `inert` | Packages no test uses except by importing them: linters, formatters, type packages (`["@biomejs/biome", "knip", "@types/*"]`). A [lockfile change](#lockfiles) that only they reach selects nothing. With `loadedByName` set, only packages with a `bin` need listing |
131
+ | `inert` | Packages no test uses except by importing them: linters, formatters, type packages (`["@biomejs/biome", "knip", "@types/*"]`). A [lockfile change](#lockfiles) that only they reach selects nothing. With `loadedByName` set, only packages with a `bin` need listing. bivium itself always is |
93
132
  | `loadedByName` | Packages a test may load other than by an import: a test environment or a plugin a config names by string (`["jsdom", "ts-jest"]`). Setting it, even to `[]`, says every other package without a `bin` is loaded only by imports, so a [lockfile change](#lockfiles) that reaches one no test imports selects only its importers. A package with a `bin` always counts as one a test may run |
94
133
  | `extensions` | Suffixes tried after a specifier |
95
134
  | `deadGlobs` | Dead globs `check` allows, each `{ file, glob, reason }`, the glob as `file` spells it |
@@ -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,13 +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.
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>`.
120
192
 
121
193
  ## Recipes
122
194
 
123
- **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:
124
200
 
125
201
  ```ts
126
202
  suites: {
@@ -138,11 +214,24 @@ alias: { "@/": "src/" },
138
214
  reads: { "src/**/*.test.{ts,tsx}": "src/$1__snapshots__/$2.test.$3.snap" },
139
215
  ```
140
216
 
141
- 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.
142
-
143
- **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.
144
-
145
- **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`:
146
235
 
147
236
  ```ts
148
237
  e2e: {
@@ -153,13 +242,45 @@ e2e: {
153
242
  },
154
243
  ```
155
244
 
156
- **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.
157
252
 
158
253
  ## Lockfiles
159
254
 
160
- 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.
161
-
162
- 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`. 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.
163
284
 
164
285
  ```console
165
286
  $ bunx bivium plan
@@ -182,15 +303,65 @@ unit tests: 4 of 12 files
182
303
 
183
304
  | Command | Does |
184
305
  |:---|:---|
185
- | `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` |
186
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 |
187
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 |
188
- | `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. `--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) |
189
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` |
190
311
 
191
- `--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
+ ```
192
333
 
193
- `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`.
194
365
 
195
366
  ```console
196
367
  $ bunx bivium why e2e/accordion.test.ts
@@ -229,7 +400,8 @@ selected: e2e/accordion.test.ts ← src/AccordionItem.svelte (5 hops)
229
400
  + 1 more change reaches this test: css/_accordion.scss (--all shows each chain)
230
401
  ```
231
402
 
232
- 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:
233
405
 
234
406
  ```console
235
407
  $ bunx bivium why tests/e2e.test.ts --format chain
@@ -243,14 +415,25 @@ tests/e2e.test.ts runs on every change
243
415
 
244
416
  ## Dead globs
245
417
 
246
- 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:
247
425
 
248
426
  | Problem | Means |
249
427
  |:---|:---|
250
428
  | matches nothing | No file matches: a typo or a stale path |
251
429
  | matches only ignored files, partly ignored | Some matches are ignored and not in the graph, so a change to one selects nothing |
252
430
 
253
- 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:
254
437
 
255
438
  ```ts
256
439
  deadGlobs: [
@@ -260,7 +443,8 @@ deadGlobs: [
260
443
 
261
444
  ## CI
262
445
 
263
- 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:
264
448
 
265
449
  ```yaml
266
450
  jobs:
@@ -297,41 +481,79 @@ jobs:
297
481
 
298
482
  ### The checkout
299
483
 
300
- 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:
301
490
 
302
491
  ```
303
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`).
304
493
  ```
305
494
 
306
- `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' }}`.
307
-
308
- 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:
309
511
 
310
512
  | History | Checkout | What a plan pays |
311
513
  | :--- | :--- | :--- |
312
514
  | Small: a full clone takes a second or two | `fetch-depth: 0` | Nothing more: every old version is already on disk |
313
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 |
314
516
 
315
- `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.
316
524
 
317
525
  ### The cache
318
526
 
319
- 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.
320
533
 
321
534
  ### What a plan costs
322
535
 
323
- 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):
324
538
 
325
539
  | Repository | Files | Bun, no cache | Bun, warm | Node 24, no cache | Node 24, warm | Cache |
326
540
  |:---|---:|---:|---:|---:|---:|---:|
327
541
  | carbon-components-svelte | 4,680 | 0.15 s | 0.09 s | 0.27 s | 0.13 s | 452 KB |
328
542
  | generated TypeScript, 23 MB | 7,000 | 0.14 s | 0.08 s | 0.30 s | 0.12 s | 896 KB |
329
543
 
330
- 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.
331
549
 
332
550
  ## Narrowers
333
551
 
334
- 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.
335
557
 
336
558
  ```ts
337
559
  narrowers: [
@@ -349,7 +571,18 @@ narrowers: [
349
571
  ],
350
572
  ```
351
573
 
352
- 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.
353
586
 
354
587
  ## From code
355
588
 
@@ -361,7 +594,14 @@ const result = await plan({ config, base: "origin/main" });
361
594
  result.suites.unit; // { mode: "some", files: [...] }; result.suites.e2e is a type error
362
595
  ```
363
596
 
364
- `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.
365
605
 
366
606
  ## Compared with
367
607