Skip to content

Commit bceb0bc

Browse files
auxesisclaude
andcommitted
fix(mise): make the wasi-check dependency gate see through colour
wasm:wasi-check greps cargo tree output for crates that must never link into a WASI guest (wasm-bindgen, web-sys, js-sys, reqwest, hyper, aws-lc-sys). CI sets CARGO_TERM_COLOR=always, so cargo wraps each line's tree prefix in ANSI colour codes, and the grep, which anchors on that prefix, can never match. A deliberate-break run on 2 October 2026 added wasm-bindgen to stack-kms, and the CI step still printed "all WASI crates compile with no JS-host or native-HTTP deps". Only the cargo check half of the step was working. Ask cargo tree for --color never. With CARGO_TERM_COLOR=always, the gate now fails on that break and passes on the clean tree. A script test checks every cargo tree call in the task asks for uncoloured output, and records why with a coloured sample the patterns cannot match. cipherstash-suite has the same task and the same CI setting, so its gate is dead too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PaY5xYydZUWhv8Nex9Sw8a
1 parent 7e3d126 commit bceb0bc

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

‎mise.toml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ check() {
9595
# cargo tree can die on EPIPE, and pipefail would adopt that status —
9696
# silently masking a MATCH once the tree outgrows the pipe buffer.
9797
local tree
98-
tree=$(cargo tree --target wasm32-wasip1 -e normal -p "$crate" "$@")
98+
# --color never: CI sets CARGO_TERM_COLOR=always, and the colour codes
99+
# around the tree prefix stop the grep below from ever matching.
100+
tree=$(cargo tree --color never --target wasm32-wasip1 -e normal -p "$crate" "$@")
99101
if grep -Eq '^[^a-z]*(wasm-bindgen|web-sys|js-sys) ' <<<"$tree"; then
100102
echo "error: $crate pulls a JS-host backend (wasm-bindgen/web-sys/js-sys) on WASI — not wazero-loadable" >&2
101103
exit 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { readFileSync } from 'node:fs'
2+
import { join } from 'node:path'
3+
import { describe, expect, it } from 'vitest'
4+
import { REPO_ROOT } from './lib/repo-root.mjs'
5+
6+
/**
7+
* `wasm:wasi-check` greps `cargo tree` output for crates that must never link
8+
* into a WASI guest. CI sets `CARGO_TERM_COLOR=always`, and cargo then wraps
9+
* each line's tree prefix in ANSI colour codes. The grep anchors on that
10+
* prefix, so with colour on it can never match: the gate passed with
11+
* `wasm-bindgen` added to stack-kms in a deliberate-break run on 2 October
12+
* 2026, while the same break failed it locally, where output is plain.
13+
*/
14+
15+
const miseToml = readFileSync(join(REPO_ROOT, 'mise.toml'), 'utf8')
16+
17+
function taskRun(name) {
18+
const start = miseToml.indexOf(`[tasks."${name}"]`)
19+
expect(start, `${name} task`).toBeGreaterThan(-1)
20+
const open = miseToml.indexOf('run = """', start)
21+
const close = miseToml.indexOf('"""', open + 'run = """'.length)
22+
return miseToml.slice(open, close)
23+
}
24+
25+
const run = taskRun('wasm:wasi-check')
26+
27+
describe('wasm:wasi-check dependency gate', () => {
28+
it('asks cargo tree for uncoloured output', () => {
29+
const calls = run.match(/^(?!\s*#).*cargo tree[^\n]*/gm) ?? []
30+
expect(calls.length).toBeGreaterThan(0)
31+
for (const call of calls) expect(call).toContain('--color never')
32+
})
33+
34+
it('its patterns match a forbidden crate in a plain tree, and not in a coloured one', () => {
35+
const patterns = [...run.matchAll(/grep -Eq '([^']+)'/g)].map(
36+
([, pattern]) => new RegExp(pattern, 'm'),
37+
)
38+
expect(patterns.length).toBe(2)
39+
const plain = 'stack-kms v0.1.0\n├── wasm-bindgen v0.2.100\n'
40+
const coloured =
41+
'stack-kms v0.1.0\n\u001b[2m├── \u001b[0mwasm-bindgen v0.2.100\n'
42+
expect(patterns[0].test(plain)).toBe(true)
43+
// Documents why `--color never` is load-bearing.
44+
expect(patterns[0].test(coloured)).toBe(false)
45+
})
46+
})

0 commit comments

Comments
 (0)