Skip to content

Commit 72e1c92

Browse files
committed
🤖 Verify the whole battery at once, and prove it changed nothing
The checks were always independent; what stopped them running together was shared mutable state, and #304 removed it. This is the command that uses that, and the rule that keeps it true. `deno task verify` starts every applicable check concurrently after one setup, reports them in a fixed order however they finish, prints the first failure's output complete and names the rest, and fails if the battery moved any tracked file's content, mode, symlink target, or presence — including when a command failed, which is when a dirtied tree would otherwise go unnoticed. The split is enforced rather than intended. `scripts/lib/verify.ts` decides what runs and what the report says and is listed in `tsconfig.node.json`, so importing the Deno-only `prepared-state.ts` fails the Node typecheck; `scripts/verify.ts` installs the host behaviour it needs. The harness guarantees complete, byte-exact, non-interleaved output and observed cleanup. It does not slow a child down: `@effectionx/node`'s `fromReadable` subscribes with `on("data")`, so a pipe drains regardless of the consumer. What the guarantee rests on is a sink that cannot fall behind — one that suspends is halted at teardown with its backlog queued and those bytes gone — so the spool writes synchronously, and a test fails if it ever yields. On an unprepared worktree the preflight refuses: a fixture adapter's sentinel is never written, no battery command starts, `deno.lock` is byte-identical, and the exit is non-zero naming `deno task setup`. What the task runner creates while resolving the workspace beforehand is neither required nor asserted. Running the battery concurrently exposed a defect it also fails on serially: a document under test writes its eval blocks to `.xmd-eval/*.ts`, and the workspace `deno check` type-checked them, so `check` broke whenever `docs` had a file in flight. That directory joins the `exclude` list. `verify:clean` now ends by running the battery once, and holds it to a different claim than a build. A build is cache-pure: `build:web`, `build`, and the release compile must leave `node_modules`, the cache's dependency content, and `deno.lock` byte-identical, and that comparison is unchanged. Verification is not cache-pure and does not claim to be — it resolves modules no build walks, the dnt graph behind `scripts/build-npm.ts` among them, so it adds to the Deno cache the runtime owns. What it may never move is what this repository owns, so its phase compares `node_modules` and the lockfile. Once, and `--no-site`. The battery wants four cores and a CI runner has four, so two of them thrash rather than overlap, and the two extra commands are what the `site` job already runs. The cold-refusal test lost its scratch `DENO_DIR` for the same reason — unprepared means the worktree, not the cache, so inheriting a warm one costs six seconds instead of twenty-eight and proves exactly as much. Their scratch repositories also pin identity *and signing* on the command line: inheriting a global config that signs through an external agent made `git commit` exit 128 whenever that agent was busy. `deno bundle` and the esbuild service it spawns stop making progress under concurrent load: both idle at 0% CPU, neither exits, nothing prints, and no observed wedge recovered. Both `composability` runs hit it, hanging silently until cancelled an hour in, and it reproduced locally. The analysis in denoland/deno#36417 — `esbuild_client`'s two bounded protocol channels filling on both sides, each task parked in a send the other must drain — is consistent with every observation and with stacks showing the bundler in `kevent` and every esbuild thread in `cond_wait`. It is evidence-backed analysis awaiting maintainer diagnosis, not a confirmed root cause, and nothing here states it as one. Two deadlines bound it, and nothing retries: - `scripts/lib/verify.ts`: every battery command races a 20-minute deadline, announced when the battery starts and named again in the `(timed out)` line that reports it. A command settled that way is halted, counted failed once, and printed with everything it had written; the rest of the battery still finishes. - `ci.yml`: `composability` keeps `timeout-minutes: 60` as the job backstop. A retry would convert a reproducible upstream defect into an intermittent one and hide it getting worse, so `bundleClient` makes one attempt. A halted build cannot orphan its esbuild service — the service exits on pipe EOF — and a live wedge held exactly one service, the stuck bundle's own child, so the halt-mid-bundle tests are unrelated and stay as they are. The cleanliness comparison after verification reads only what this repository owns. `hostState` takes a root and nothing else: no `denoDir`, no `cacheRoots`, so there is no cache to discover, walk, or hash — not filtered out afterwards, never asked for. Builds keep the full prepared-state comparison, because a build is cache-pure and that claim needs the cache in view. A regression hands the snapshot a reader that throws on anything outside `node_modules` and `deno.lock`, and a mutant that walks the cache and discards the result fails it. `verify:clean` now changes `site/` in its clone on purpose, takes that as the baseline, and runs one battery with the site pair applying — all ten commands, selected by a real change rather than a fixture. The order is the proof, so it is a parameter rather than a statement: `siteEnabledBattery` puts the edit before the baseline, and a regression records the sequence, because the edit made afterwards reads as a tracked file the battery dirtied. The report's byte emission loops until a short-accepting sink has taken every byte and raises on a sink that stops accepting, rather than spinning. One `writeSync` returns a count this code used to ignore. Halting a command reaps its descendants, not just its process group. Signalling the group is what teardown already did, and it is not enough: `@effectionx/process` starts every `exec` in a *new* group, so a command that execs something — `deno task test` reaching `deno bundle` — leaves that grandchild in a group the signal never reaches. A live wedge showed it: after a command was settled at its deadline, the bundler and its esbuild service were still running, each a group leader of its own. The adapter now takes a `ps` snapshot while the command is still alive — after it exits, its children are reparented and the chain naming them as ours is gone — and signals the subtree deepest first. Removing that `ensure` makes the regression hang rather than fail, because the leaked grandchild keeps teardown from finishing at all. `composability` also gains the Bun the battery runs. The first battery ever to complete in that job failed only at `bun run test:bun`: at spawn, in zero seconds, with an empty spool, because the job never installed the runtime. That job now runs on `main` only. Measured on a full green run: it took the workflow's critical path from 434s to 649s, and 1,420s of what it does inside that is the Deno, Node, and Bun suites — which `test-deno`, `test-node`, and `test-bun` already run in parallel, on their own runners. Compressing them onto one four-core runner buys contention, not overlap. What the job uniquely proves — that a clean checkout prepares, that builds stay cache-pure and offline, and that concurrent checks do not dirty what another reads — is a property of installation that most changes cannot break, so it is worth a post-merge run rather than a place on every pull request's critical path. Running the battery concurrently exposed one more collision, of exactly the kind the rule forbids: `deno task test` builds the npm packages into `packages/*/npm`, and `lint` read that output while it was being written — oxlint's `import` plugin resolving through the `node_modules` dnt puts there, oxfmt format-checking generated files. It failed roughly one run in twelve, and reproducibly within two iterations of a lint loop run beside the npm build. That output now sits behind the lint task's ignore patterns, beside the fixtures and for the same reason: an `ignorePatterns` entry in `.oxlintrc.json` stops the rule tests seeing their own fixtures, so both exclusions live on the command line. `deno check` reads that same output, so `**/npm` joins `.xmd-eval` in the workspace `exclude` on the same grounds: both are generated, both are rewritten by a command running beside the one reading them, and type-checking either mid-write fails the whole workspace for a file nobody committed. Closes #279
1 parent f3f7ad5 commit 72e1c92

22 files changed

Lines changed: 2470 additions & 29 deletions

‎.github/workflows/ci.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,19 @@ jobs:
255255
# whole chain end to end rather than each link separately.
256256
composability:
257257
runs-on: ubuntu-latest
258+
# `main` only. The battery this job runs spends ~1,420s on the Deno, Node,
259+
# and Bun suites — which `test-deno`, `test-node`, and `test-bun` already
260+
# run in parallel, on their own runners. Compressing them onto one four-core
261+
# runner made the workflow's critical path 434s → 649s to prove a property
262+
# about installation that most changes cannot break. What this job uniquely
263+
# proves — a clean checkout prepares, builds stay cache-pure and offline,
264+
# and concurrent checks do not dirty what another reads — is worth a
265+
# post-merge run, not a place on every pull request's critical path (#279).
266+
if: github.event_name == 'push'
267+
# A wedged `deno bundle` ↔ esbuild pair inside the battery would otherwise
268+
# hang this job to the six-hour default with nothing printed. The battery
269+
# itself settles a stuck command at 20 minutes; this is the backstop.
270+
timeout-minutes: 60
258271
steps:
259272
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
260273

@@ -264,6 +277,13 @@ jobs:
264277

265278
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
266279

280+
# The battery this job runs includes `bun run test:bun`; without the
281+
# runtime that command fails at spawn, in zero seconds, with an empty
282+
# spool.
283+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
284+
with:
285+
bun-version: 1.3.14
286+
267287
- uses: denoland/setup-deno@e95548e56dfa95d4e1a28d6f422fafe75c4c26fb # v2.0.3
268288
with:
269289
deno-version: v2.9.5

‎.oxfmtrc.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
// Markdown is source code here: oxfmt reindents fenced blocks and rewrites
33
// `yield*` as `yield *`, which changes what a document does. Fixtures carry
44
// the exact indentation the rule tests assert on.
5-
"ignorePatterns": ["**/*.md", "scripts/tests/fixtures/**"]
5+
// `packages/*/npm` is generated dnt output, written by a test while the
6+
// battery runs; format-checking it fails on a file nobody wrote by hand.
7+
"ignorePatterns": ["**/*.md", "scripts/tests/fixtures/**", "**/npm/**"]
68
}

‎AGENTS.md‎

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,67 @@ representative release target and proves the host tree and lock survived it,
4848
then runs every build phase offline — including a release compile for
4949
`x86_64-unknown-linux-gnu`, the same shape `release.yml` uses — fingerprinting
5050
the content and modes of `node_modules`, the cache's dependency roots, and
51-
`deno.lock` after each one. It verifies the commit, so commit before running it.
52-
CI runs the same harness in its `composability` job.
51+
`deno.lock` after each one. It then changes `site/` in that clone on purpose,
52+
takes the changed tree as its baseline, and runs the battery once with the site
53+
pair applying — all ten commands together, selected by a real change rather
54+
than by a fixture.
55+
56+
Builds and checks are held to different claims there. A build is cache-pure:
57+
nothing it does may move `node_modules`, the cache's dependency content, or the
58+
lockfile, and the comparison around a build walks all three. Verification is
59+
not, and does not pretend to be — the battery resolves modules no build walks,
60+
so it adds to the Deno cache, which the runtime owns. Its comparison therefore
61+
reads only what this repository owns, `node_modules` and `deno.lock`, and never
62+
looks at the cache at all: not filtered out afterwards, never asked for. What
63+
verification may never move is tracked files, `node_modules`, `deno.lock`, and
64+
another invocation's temporary state.
65+
66+
It verifies the commit, so commit before running it. CI runs the same harness in
67+
its `composability` job — **on `main` only**. The battery it runs spends most of
68+
its time on the three runtime suites, which `test-deno`, `test-node`, and
69+
`test-bun` already run in parallel on their own runners, so putting it on every
70+
pull request bought a 50% longer critical path and no new information. Run it
71+
locally before you push anything that could move dependency state; on `main` it
72+
is the post-merge proof, and a failure there opens a `ci-main-red` issue.
5373

5474
## Verification
5575

56-
After making any changes to source files (`src/`) or test files (`tests/`),
57-
always run all four checks before committing:
76+
One command runs everything that applies, concurrently:
77+
78+
```bash
79+
deno task verify # add --no-site to skip the site pair
80+
```
81+
82+
**The whole applicable battery is designed to run at once, after one setup.**
83+
That is a repository rule, not a convenience, and it has two halves:
84+
85+
**Builds are cache-pure.** `deno task build:web`, `deno task build`, and the
86+
release compile must leave `node_modules`, the Deno cache's dependency content,
87+
and `deno.lock` byte-identical.
88+
89+
**Verification may populate the runtime cache** — the battery resolves module
90+
graphs no build walks, and that cache belongs to the runtime. What no check may
91+
do is modify tracked files, `node_modules`, `deno.lock`, or another
92+
invocation's temporary state. Temporary state a check needs belongs to that
93+
invocation alone.
94+
95+
A helper that reaches for repository-owned mutable state breaks every other
96+
check running beside it, which is how a `deno task build` came to break the Node
97+
typecheck (#279).
98+
99+
`verify` reports every command in a fixed order however they finish, prints the
100+
first failure's output complete and names the rest, and fails if the battery
101+
moved any tracked file's content, mode, symlink target, or presence — including
102+
when a command failed, because that is when a dirtied tree would otherwise go
103+
unnoticed. **Capture a failure's first output before re-running anything**: the
104+
report is what you paste, and a second run can hide the first.
105+
106+
The site pair applies when `site/` changed, judged from the branch and the
107+
worktree, both sides of a rename included.
108+
109+
Running the checks individually is still fine, and is what `verify` does for
110+
you. After making any changes to source files (`src/`) or test files (`tests/`),
111+
always run all four before committing:
58112

59113
1. **Lint + Format**: `deno task lint` (runs `oxlint` + `oxfmt --check`) — must
60114
produce 0 errors. Run `deno task fmt` to auto-fix formatting.
@@ -71,7 +125,13 @@ here:
71125

72126
- `check`, `test`, and `check:jsr` follow the `packages/*` workspace glob in the
73127
root `deno.json`. Its `exclude` list holds the paths that must stay
74-
unchecked — currently the deliberately-malformed `scripts/tests/fixtures`.
128+
unchecked: the deliberately-malformed `scripts/tests/fixtures`; `.xmd-eval`,
129+
where a running document writes the `.ts` files its eval blocks compile to;
130+
and `**/npm`, the dnt build's output, which a test rewrites while the battery
131+
runs. All three are generated and belong to whichever command is producing
132+
them — type-checking one mid-write fails on a partial file, and fails the
133+
whole workspace check for a file nobody committed. The same output is skipped
134+
by `lint` and `fmt`, for the same reason.
75135
- `test:node` and `test:bun` derive the same corpus through
76136
`scripts/lib/test-files.ts`, which walks `tests/` beneath each workspace
77137
member plus `scripts/tests/` — that boundary, and nothing else. A new
@@ -89,10 +149,14 @@ here:
89149
- `lint` and `fmt` are defined once, as `package.json` scripts that `deno task`
90150
also exposes, and cover `packages` and `scripts`. Oxfmt skips Markdown
91151
(`.oxfmtrc.json`): these documents are executable, and reformatting a fenced
92-
block changes what they do. The fixtures stay out of both, on the lint task's
93-
command line rather than in `.oxlintrc.json` — the rule tests in
94-
`scripts/tests/` lint those same files through the repository config and need
95-
it to keep reporting on them.
152+
block changes what they do. `packages/*/npm` — the dnt build's output, which
153+
a test writes while the battery runs — is skipped by both: it is generated,
154+
gitignored, and carries a `node_modules` of its own that oxlint's `import`
155+
plugin resolves through, so linting it reports on half-written files nobody
156+
committed. The fixtures and that output stay out of `.oxlintrc.json`, on the
157+
lint task's command line instead — the rule tests in `scripts/tests/` lint
158+
through the repository config, and an `ignorePatterns` entry there stops them
159+
seeing their own fixtures.
96160

97161
## MUST READ
98162

‎README.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,17 @@ deno task build # compile the standalone xmd bi
242242
deno task lint # oxlint + oxfmt
243243
deno task check # typecheck
244244
deno task test # run the test suite
245+
deno task verify # the whole applicable battery, concurrently
245246
```
246247

247248
`deno task setup` is the only thing that installs. Builds and checks read what
248-
it prepared and write nothing back, so they compose instead of undoing one
249-
another — `deno task verify:clean` runs that claim end to end against a clean
250-
clone (AGENTS.md).
249+
it prepared and leave what this repository owns — tracked files, `node_modules`,
250+
`deno.lock` — exactly as they found it, so they compose instead of undoing one
251+
another. A build is cache-pure on top of that; verification may add to the
252+
runtime's own module cache, which is why it resolves graphs no build walks.
253+
`deno task verify` starts the entire applicable battery at once and fails if any
254+
of it leaves a tracked file changed, and `deno task verify:clean` runs that
255+
claim end to end against a clean clone (AGENTS.md).
251256

252257
## Status
253258

‎deno.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"workspace": ["packages/*", "site"],
3-
"exclude": ["scripts/tests/fixtures", "spikes"],
3+
"exclude": ["scripts/tests/fixtures", "spikes", ".xmd-eval", "**/npm"],
44
"nodeModulesDir": "auto",
55
"lock": {
66
"frozen": true
@@ -51,6 +51,7 @@
5151
"gen:publish-workflow": "deno run --allow-all packages/cli/src/deno.ts run scripts/gen-publish-workflow.md",
5252
"bump": "deno run -A scripts/bump-version.ts",
5353
"test": "deno test --allow-all --frozen",
54+
"verify": "deno run --allow-all --node-modules-dir=none --cached-only --frozen scripts/preflight.ts scripts/verify.ts",
5455
"check": "deno check --frozen",
5556
"check:jsr": "deno publish --dry-run --allow-dirty",
5657
"review": "deno run --allow-all packages/cli/src/deno.ts run .reviews/ReviewPR.md --component-dir .reviews/components --component-dir .reviews/policies --component-dir packages/core/components -j .reviews/journal.jsonl",

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"test:node": "tsx scripts/runtime-tests.ts node",
7272
"test:bun": "bun scripts/runtime-tests.ts bun",
7373
"test:deno": "deno task test",
74-
"lint": "oxlint -c .oxlintrc.json --ignore-pattern 'scripts/tests/fixtures/**' packages scripts && oxfmt --check packages scripts",
74+
"lint": "oxlint -c .oxlintrc.json --ignore-pattern 'scripts/tests/fixtures/**' --ignore-pattern '**/npm/**' packages scripts && oxfmt --check packages scripts",
7575
"fmt": "oxfmt --write packages scripts"
7676
},
7777
"workspaces": [

‎scripts/build-web-client.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ function* run(command: string, args: string[]): Operation<void> {
116116
yield* exec(command, { arguments: args, cwd: new URL(repoRoot).pathname }).expect();
117117
}
118118

119+
/**
120+
* This bundle can stop making progress under concurrent load, along with the
121+
* esbuild service it spawns — see denoland/deno#36417. Nothing here retries:
122+
* the battery's own per-command deadline settles a wedged command once and
123+
* reports it, so a worsening upstream defect stays visible instead of being
124+
* absorbed by an attempt count.
125+
*/
119126
function* bundleClient(scratch?: string): Operation<string> {
120127
return yield* scoped(function* () {
121128
const output = yield* until(Deno.makeTempFile({ dir: scratch, suffix: ".js" }));

‎scripts/lib/changed-paths.ts‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/**
2+
* Which paths this branch and worktree touched, from git's two answers.
3+
*
4+
* Verify asks one question of these: did anything under `site/` change? The
5+
* answer has to survive a rename, which is where the two sources stop agreeing.
6+
* Measured on this repository, renaming `site/page.md` to `moved-out.md`:
7+
*
8+
* ```text
9+
* git status --porcelain=v1 -z "R moved-out.md"\0"site/page.md"\0
10+
* ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
11+
* status and NEW path share one field, then old
12+
*
13+
* git diff --name-status -z -M -C "R100"\0"site/page.md"\0"moved-out.md"\0
14+
* ^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^
15+
* status OLD path new path
16+
* ```
17+
*
18+
* The path order is reversed between them, so one parser cannot read both.
19+
* Both paths are always yielded: a rename out of `site/` changes `site/` just
20+
* as much as a rename into it does.
21+
*
22+
* Two more shapes came out of the same measurements. An *unstaged* rename is
23+
* not reported as a rename at all — git emits ` D site/page.md` and
24+
* `?? moved-out.md` — so nothing here may assume an `R` exists. And a copy does
25+
* reach porcelain when `status.renames=copies` is configured
26+
* (`C site/copy2.md\0keep.md\0`), so `C` is read, not guessed at.
27+
*
28+
* A status neither parser recognises raises. Reading one path where git meant
29+
* two would silently drop the side that mattered.
30+
*/
31+
32+
export class ChangedPathsError extends Error {}
33+
34+
/** Every status letter git may put in a porcelain field or a name-status record. */
35+
const STATUS_LETTERS = new Set([" ", "M", "A", "D", "R", "C", "U", "T", "X", "B", "?", "!"]);
36+
37+
function fields(output: string): string[] {
38+
return output.split("\0").filter((field) => field.length > 0);
39+
}
40+
41+
function known(letter: string): boolean {
42+
return STATUS_LETTERS.has(letter);
43+
}
44+
45+
/**
46+
* Paths from `git status --porcelain=v1 -z`.
47+
*
48+
* The status is a fixed two-character prefix, not a split: `slice(0, 2)` and
49+
* `slice(3)`, because a path may itself contain spaces.
50+
*/
51+
export function parsePorcelain(output: string): string[] {
52+
const parts = fields(output);
53+
const paths: string[] = [];
54+
let index = 0;
55+
while (index < parts.length) {
56+
const record = parts[index]!;
57+
index += 1;
58+
const status = record.slice(0, 2);
59+
const [staged, worktree] = [status[0]!, status[1]!];
60+
if (!known(staged) || !known(worktree)) {
61+
throw new ChangedPathsError(
62+
`git status reported \`${status}\`, which this parser cannot read`,
63+
);
64+
}
65+
paths.push(record.slice(3));
66+
if (staged === "R" || staged === "C" || worktree === "R" || worktree === "C") {
67+
const origin = parts[index];
68+
if (origin === undefined) {
69+
throw new ChangedPathsError(`git status reported \`${status}\` without its second path`);
70+
}
71+
index += 1;
72+
paths.push(origin);
73+
}
74+
}
75+
return paths;
76+
}
77+
78+
/** Paths from `git diff --name-status -z -M -C`. */
79+
export function parseNameStatus(output: string): string[] {
80+
const parts = fields(output);
81+
const paths: string[] = [];
82+
let index = 0;
83+
while (index < parts.length) {
84+
const status = parts[index]!;
85+
index += 1;
86+
const letter = status[0]!;
87+
if (!known(letter)) {
88+
throw new ChangedPathsError(`git diff reported \`${status}\`, which this parser cannot read`);
89+
}
90+
const wanted = letter === "R" || letter === "C" ? 2 : 1;
91+
for (let taken = 0; taken < wanted; taken += 1) {
92+
const path = parts[index];
93+
if (path === undefined) {
94+
throw new ChangedPathsError(`git diff reported \`${status}\` without ${wanted} paths`);
95+
}
96+
index += 1;
97+
paths.push(path);
98+
}
99+
}
100+
return paths;
101+
}
102+
103+
/** Whether any changed path lies under `directory`. */
104+
export function touches(paths: string[], directory: string): boolean {
105+
const prefix = directory.endsWith("/") ? directory : `${directory}/`;
106+
return paths.some((path) => path.startsWith(prefix));
107+
}

‎scripts/lib/prepared-state.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ export interface PreparedState {
8585
lock: string;
8686
}
8787

88+
/** The repository-owned half, with no cache in it to begin with. */
89+
export interface HostState {
90+
tree: Fingerprint;
91+
lock: string;
92+
}
93+
8894
const FINGERPRINTED: ("tree" | "cache")[] = ["tree", "cache"];
8995

9096
/** How many entries the walk covers before giving the scheduler a chance to halt it. */
@@ -222,6 +228,34 @@ export function* preparedState(root: string, denoDir: string): Operation<Prepare
222228
return yield* stateOf(root, yield* cacheRoots(denoDir));
223229
}
224230

231+
/**
232+
* What this repository owns: the installed tree and the lockfile. No cache.
233+
*
234+
* Not "the prepared state with the cache filtered out afterwards" — this takes
235+
* no `denoDir`, never calls `cacheRoots`, and so has nothing to discover, walk,
236+
* or hash beyond `node_modules` and `deno.lock`. That is the difference the
237+
* #279 contract turns on: verification may populate the runtime-owned cache, so
238+
* a comparison that walked it would be measuring state its subject is allowed
239+
* to change — and paying to hash tens of thousands of files to discard the
240+
* result.
241+
*/
242+
export function* hostState(root: string): Operation<HostState> {
243+
const read = yield* FileReads.expect();
244+
return {
245+
tree: yield* fingerprint({ node_modules: `${root}/node_modules` }, read),
246+
lock: digest(read(`${root}/deno.lock`)),
247+
};
248+
}
249+
250+
/** What moved between two host snapshots, named part by part. */
251+
export function hostStateChanges(before: HostState, after: HostState): string[] {
252+
return describe({ ...before, cache: EMPTY_FINGERPRINT }, { ...after, cache: EMPTY_FINGERPRINT }, [
253+
"tree",
254+
]);
255+
}
256+
257+
const EMPTY_FINGERPRINT: Fingerprint = { entries: [], roots: [] };
258+
225259
/**
226260
* What moved in the host's own state: the installed tree and the lock, ignoring
227261
* the cache.

0 commit comments

Comments
 (0)