Skip to content

Commit 608768c

Browse files
committed
refactor(scripts): standardize on .mts and bump the Node floor
Convert the three remaining scripts/**/*.mjs files (binding_pins, fp_fuzz, node_compat_matrix) to TypeScript .mts, standardizing onto the same module + type-stripping convention the soak scripts already use. Add reasonable types (function signatures, interfaces, typed collections) without a deep typing pass — `any` where inference is unclear. Node floor: declare engines.node >= 22.18.0 in package.json (the minimum for native .mts type stripping). The repo's .node-version pin (26.5.1) is well above this, and every CI workflow already uses node-version-file: .node-version, so no workflow Node-version bump was needed. 3 files converted. Invocation sites updated: - .github/workflows/test.yml (binding_pins --check) - .github/workflows/node-compat-matrix.yml (node_compat_matrix --check + comments) - scripts/soak/external-tools.mts (string reference) - external-tools.json (description fields) - test-parity/node-compat-matrix.baseline.json (description) - test-parity/node-compat-matrix.skip.json (description) - docs/src/cli/fast-math.md, docs/src/native-libraries/upstream-pins.md, docs/src/testing/node-compat-matrix.md - CLAUDE.md, llms.txt, .gitignore - crates/perry/src/commands/compile/well_known.rs (comments) - gc-handoff/NODE26-NOTES.md - docs/po/*.po + docs/po/messages.pot (translation strings) - In-script help/usage text in all three converted files No files left as .mjs — all scripts/**/*.mjs are now .mts. CHANGELOG.md and historical changelog.d fragments left untouched (frozen archive / per-PR records of past releases). Verified: binding_pins --check passes, node_compat_matrix --help runs, fp_fuzz runs (trivial invocation), npm run soak / tools:check / test:scripts all pass, CI YAML validated.
1 parent 389adf3 commit 608768c

30 files changed

Lines changed: 242 additions & 165 deletions

‎.github/workflows/node-compat-matrix.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Node Compat Matrix Guard
22

3-
# Gates scripts/node_compat_matrix.mjs --check: a breadth sweep over every
3+
# Gates scripts/node_compat_matrix.mts --check: a breadth sweep over every
44
# require("module").builtinModules entry, both import forms (M and node:M),
55
# against a PINNED, SRI-verified Node oracle (external-tools.json tools.node,
66
# currently 26.5.1). It compares Perry's export-SHAPE fingerprint per module
@@ -11,7 +11,7 @@ name: Node Compat Matrix Guard
1111
#
1212
# Its OWN job on purpose: the runner downloads the pinned Node dist tarball
1313
# (~40MB) and verifies it, which must not slow the main cargo-test job. The
14-
# node used by setup-node here only EXECUTES the .mjs; the oracle Node is the
14+
# node used by setup-node here only EXECUTES the .mts; the oracle Node is the
1515
# pinned dist the runner fetches + SRI-verifies itself.
1616
#
1717
# Decoupled from the (not-yet-enabled) merge queue like node-suite-guard.yml:
@@ -76,7 +76,7 @@ jobs:
7676
uses: actions/setup-node@v7
7777
with:
7878
# Single source of truth: .node-version at the repo root. This node
79-
# only RUNS node_compat_matrix.mjs; the compat oracle is the pinned
79+
# only RUNS node_compat_matrix.mts; the compat oracle is the pinned
8080
# Node the runner downloads + SRI-verifies from external-tools.json.
8181
node-version-file: .node-version
8282

@@ -91,6 +91,6 @@ jobs:
9191
set -euo pipefail
9292
echo '### Node builtin compat matrix guard' >> "$GITHUB_STEP_SUMMARY"
9393
echo '```' >> "$GITHUB_STEP_SUMMARY"
94-
node scripts/node_compat_matrix.mjs --check \
94+
node scripts/node_compat_matrix.mts --check \
9595
| tee -a "$GITHUB_STEP_SUMMARY"
9696
echo '```' >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ jobs:
294294
# newly-soaked upstream releases as advisories.
295295
- name: Binding upstream pins (lock-step)
296296
if: ${{ !cancelled() }}
297-
run: node scripts/binding_pins.mjs --check
297+
run: node scripts/binding_pins.mts --check
298298

299299
# GC write-barrier store-site inventory: every raw heap-slot store in
300300
# perry-codegen / perry-runtime / perry-stdlib must be barriered or

‎.gitignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ __pycache__/
66
*.py[cod]
77

88
# Pinned Node oracle for the builtin-module compat matrix
9-
# (scripts/node_compat_matrix.mjs downloads + SRI-verifies + caches here).
9+
# (scripts/node_compat_matrix.mts downloads + SRI-verifies + caches here).
1010
.cache/node-pin/
1111

1212
# Android Gradle: caches and build outputs are regenerable. Source under
@@ -192,7 +192,7 @@ private-*
192192
# mdBook output
193193
docs/book/
194194

195-
# scripts/fp_fuzz.mjs failure dumps (regenerable, machine-local)
195+
# scripts/fp_fuzz.mts failure dumps (regenerable, machine-local)
196196
fp_fuzz_failures/
197197

198198
test-files/.perry-cache/

‎CLAUDE.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ Three workflows are deliberately exempt and say so inline: `node-core-subset.yml
2929
- **Test/CI mechanics** — `#794` (per-category parity thresholds), `#796` (gap-suite output truncation + O(n²) `normalize_output`), `#812` (42-module behavioral matrix), `#806/#807/#808` (test harnesses for mixins / async context / ≥300-init scale).
3030
- **Skip-list audit** — `#797` covers `test-parity/known_failures.json` provenance (issue # + date per entry).
3131

32-
### Node builtin compatibility matrix (`scripts/node_compat_matrix.mjs`)
32+
### Node builtin compatibility matrix (`scripts/node_compat_matrix.mts`)
3333

3434
Breadth sweep over EVERY `require("module").builtinModules` entry, both import forms (`M` and `node:M`), against a **pinned, SRI-verified Node** (the "latest stable" oracle, pinned in `external-tools.json` `tools.node.version` — currently **26.5.1**, independent of the `.node-version` gap-suite oracle). It compares Perry's export-SHAPE fingerprint (sorted `name:typeof` over the module namespace + the default export's typeof) to the oracle's. This is the systematic version of the #812 "42-module behavioral matrix" — shape, not deep behavior (behavioral cases stay in the node-suite).
3535

3636
```bash
3737
# FAST LOOP — reach for this first when iterating on ONE builtin:
38-
node scripts/node_compat_matrix.mjs --module fs # one module, both forms
39-
node scripts/node_compat_matrix.mjs --module fs,path,crypto # a few
40-
node scripts/node_compat_matrix.mjs --module fs --method readFileSync,promises # only these exports
41-
node scripts/node_compat_matrix.mjs --only fs.readFileSync,path.join # combined mod.export form
38+
node scripts/node_compat_matrix.mts --module fs # one module, both forms
39+
node scripts/node_compat_matrix.mts --module fs,path,crypto # a few
40+
node scripts/node_compat_matrix.mts --module fs --method readFileSync,promises # only these exports
41+
node scripts/node_compat_matrix.mts --only fs.readFileSync,path.join # combined mod.export form
4242
# (the pinned Node download is skipped once cached under .cache/node-pin/)
4343

4444
# FULL SWEEP + GATE:
45-
node scripts/node_compat_matrix.mjs # whole matrix + summary table
46-
node scripts/node_compat_matrix.mjs --check # CI gate: exit 1 on regressions vs the baseline
47-
node scripts/node_compat_matrix.mjs --update-baseline # rewrite test-parity/node-compat-matrix.baseline.json
45+
node scripts/node_compat_matrix.mts # whole matrix + summary table
46+
node scripts/node_compat_matrix.mts --check # CI gate: exit 1 on regressions vs the baseline
47+
node scripts/node_compat_matrix.mts --update-baseline # rewrite test-parity/node-compat-matrix.baseline.json
4848
```
4949

5050
A `--module` selector scopes `--check`/`--update-baseline` to just that slice (a single-module refresh never rewrites the whole baseline). A `--method`/`--only` subset is a print-only fast diagnostic (it narrows the fingerprint, so it is refused for `--check`/`--update-baseline`). **Bump the pinned Node** by editing `tools.node.version` in `external-tools.json` (add per-platform sha512 SRI), then `--update-baseline` and review the diff. Needs the release binary (`cargo build --release -p perry`). Full page: `docs/src/testing/node-compat-matrix.md`.

‎changelog.d/8241-scripts-mts.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Converted the three remaining `scripts/**/*.mjs` files (`binding_pins`, `fp_fuzz`, `node_compat_matrix`) to TypeScript `.mts`, standardizing onto the same module + type-stripping convention the soak scripts already use. Declared `engines.node >= 22.18.0` in `package.json` (the floor for native `.mts` type stripping; the repo's `.node-version` pin of 26.5.1 is well above it). All invocation sites — CI workflows, docs, config JSON, in-script help text, Rust comments — updated to reference the new `.mts` paths.

‎crates/perry/src/commands/compile/well_known.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub struct WellKnownBinding {
7171
/// Upstream provenance pin — which release of the npm package this
7272
/// wrapper ports, and when it was last reviewed against it. See
7373
/// `docs/src/native-libraries/upstream-pins.md` and the lock-step
74-
/// gate in `scripts/binding_pins.mjs`. `None` for entries exempt
74+
/// gate in `scripts/binding_pins.mts`. `None` for entries exempt
7575
/// from pinning (`node_builtin`, `alias_of`, and perry-owned
7676
/// packages).
7777
// Provenance metadata parsed from `well_known_bindings.toml` and consulted
@@ -133,7 +133,7 @@ fn binding_is_faithful(
133133
///
134134
/// The **lock-step rule**: `ported_at` must equal `version`. Re-pinning
135135
/// an upstream release without re-reviewing the wrapper against the
136-
/// upstream diff reds the `binding_pins.mjs --check` gate until
136+
/// upstream diff reds the `binding_pins.mts --check` gate until
137137
/// `ported_at` advances with the review — an upstream release can never
138138
/// go silently stale, and a pin bump can never outrun its port.
139139
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -317,7 +317,7 @@ fn parse_well_known_toml(raw: &str) -> Result<BTreeMap<String, WellKnownBinding>
317317
let version = required("version")?;
318318
let ported_at = required("ported-at")?;
319319
// Parse-time lock-step backstop. The authoritative gate is
320-
// `scripts/binding_pins.mjs --check` (CI); failing here too
320+
// `scripts/binding_pins.mts --check` (CI); failing here too
321321
// means a skewed pin can't even ship inside the binary.
322322
if ported_at != version {
323323
return Err(format!(
@@ -741,7 +741,7 @@ mod tests {
741741

742742
/// The lock-step rule enforced at parse time: a pin bump
743743
/// (`version`) that outruns its review (`ported-at`) must refuse
744-
/// to load — the authoritative CI gate is binding_pins.mjs
744+
/// to load — the authoritative CI gate is binding_pins.mts
745745
/// --check, but a skewed pin must not even ship inside the binary.
746746
#[test]
747747
fn upstream_pin_rejects_lock_step_violation() {
@@ -793,7 +793,7 @@ mod tests {
793793
assert!(
794794
unpinned.is_empty(),
795795
"bindings without an [bindings.<name>.upstream] pin — provision one with \
796-
`node scripts/binding_pins.mjs --set <name>`:\n {}",
796+
`node scripts/binding_pins.mts --set <name>`:\n {}",
797797
unpinned.join("\n ")
798798
);
799799
}

‎docs/po/de.po‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52183,13 +52183,13 @@ msgstr "Korrektheits-Zahlen"
5218352183

5218452184
#: src/cli/fast-math.md:123
5218552185
msgid ""
52186-
"`scripts/fp_fuzz.mjs` — randomly generates TS programs exercising the six "
52186+
"`scripts/fp_fuzz.mts` — randomly generates TS programs exercising the six "
5218752187
"patterns most likely to trip per-instruction FMFs (left-fold, tree-fold, "
5218852188
"right-fold reductions; FMA-shaped chains; algebraic identities like "
5218952189
"`(a/b)*b`; cancellation predicates). Each program is compiled with both Node"
5219052190
" and Perry, and stdout is diffed byte-for-byte."
5219152191
msgstr ""
52192-
"`scripts/fp_fuzz.mjs` — generiert zufällig TS-Programme, die die sechs "
52192+
"`scripts/fp_fuzz.mts` — generiert zufällig TS-Programme, die die sechs "
5219352193
"Muster ausüben, die am ehesten Per-Instruction-FMFs auslösen (Left-Fold-, "
5219452194
"Tree-Fold-, Right-Fold-Reduktionen; FMA-förmige Ketten; algebraische "
5219552195
"Identitäten wie `(a/b)*b`; Cancellation-Prädikate). Jedes Programm wird "

‎docs/po/es.po‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52566,13 +52566,13 @@ msgstr "Números de corrección"
5256652566

5256752567
#: src/cli/fast-math.md:123
5256852568
msgid ""
52569-
"`scripts/fp_fuzz.mjs` — randomly generates TS programs exercising the six "
52569+
"`scripts/fp_fuzz.mts` — randomly generates TS programs exercising the six "
5257052570
"patterns most likely to trip per-instruction FMFs (left-fold, tree-fold, "
5257152571
"right-fold reductions; FMA-shaped chains; algebraic identities like "
5257252572
"`(a/b)*b`; cancellation predicates). Each program is compiled with both Node"
5257352573
" and Perry, and stdout is diffed byte-for-byte."
5257452574
msgstr ""
52575-
"`scripts/fp_fuzz.mjs` — genera aleatoriamente programas TS que ejercitan los"
52575+
"`scripts/fp_fuzz.mts` — genera aleatoriamente programas TS que ejercitan los"
5257652576
" seis patrones con más probabilidad de activar FMFs por instrucción "
5257752577
"(reducciones left-fold, tree-fold, right-fold; cadenas con forma FMA; "
5257852578
"identidades algebraicas como `(a/b)*b`; predicados de cancelación). Cada "

‎docs/po/fr.po‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52693,13 +52693,13 @@ msgstr "Chiffres de correction"
5269352693

5269452694
#: src/cli/fast-math.md:123
5269552695
msgid ""
52696-
"`scripts/fp_fuzz.mjs` — randomly generates TS programs exercising the six "
52696+
"`scripts/fp_fuzz.mts` — randomly generates TS programs exercising the six "
5269752697
"patterns most likely to trip per-instruction FMFs (left-fold, tree-fold, "
5269852698
"right-fold reductions; FMA-shaped chains; algebraic identities like "
5269952699
"`(a/b)*b`; cancellation predicates). Each program is compiled with both Node"
5270052700
" and Perry, and stdout is diffed byte-for-byte."
5270152701
msgstr ""
52702-
"`scripts/fp_fuzz.mjs` — génère aléatoirement des programmes TS exercant les "
52702+
"`scripts/fp_fuzz.mts` — génère aléatoirement des programmes TS exercant les "
5270352703
"six motifs les plus susceptibles de déclencher des FMF par instruction "
5270452704
"(réductions left-fold, tree-fold, right-fold ; chaînes de forme FMA ; "
5270552705
"identités algébriques comme `(a/b)*b` ; prédicats d'annulation). Chaque "

‎docs/po/id.po‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51605,13 +51605,13 @@ msgstr "Angka kebenaran"
5160551605

5160651606
#: src/cli/fast-math.md:123
5160751607
msgid ""
51608-
"`scripts/fp_fuzz.mjs` — randomly generates TS programs exercising the six "
51608+
"`scripts/fp_fuzz.mts` — randomly generates TS programs exercising the six "
5160951609
"patterns most likely to trip per-instruction FMFs (left-fold, tree-fold, "
5161051610
"right-fold reductions; FMA-shaped chains; algebraic identities like "
5161151611
"`(a/b)*b`; cancellation predicates). Each program is compiled with both Node"
5161251612
" and Perry, and stdout is diffed byte-for-byte."
5161351613
msgstr ""
51614-
"`scripts/fp_fuzz.mjs` — secara acak menghasilkan program TS yang menjalankan"
51614+
"`scripts/fp_fuzz.mts` — secara acak menghasilkan program TS yang menjalankan"
5161551615
" enam pola yang paling mungkin memicu FMF per-instruksi (reduksi left-fold, "
5161651616
"tree-fold, right-fold; rantai berbentuk FMA; identitas aljabar seperti "
5161751617
"`(a/b)*b`; predikat pembatalan). Setiap program dikompilasi dengan Node dan "

0 commit comments

Comments
 (0)