From 69c7dfae3710d0e28c75dd533e70c032912c5591 Mon Sep 17 00:00:00 2001 From: Merve Uygun Erdol Date: Wed, 23 Sep 2026 10:45:35 +0300 Subject: [PATCH] Declare NodeRequire and put certify refusals in --report so corpus can name them100 --- runtime/node/commonjs-wrapper.d.ts | 7 +++++++ runtime/node/node-globals.ts | 6 ++++++ scripts/build.mjs | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/runtime/node/commonjs-wrapper.d.ts b/runtime/node/commonjs-wrapper.d.ts index 0009c33..972a5c6 100644 --- a/runtime/node/commonjs-wrapper.d.ts +++ b/runtime/node/commonjs-wrapper.d.ts @@ -20,4 +20,11 @@ declare global { var require: (specifier: string) => any var exports: any var module: { exports: any } + + // `@types/node` spells the callable `require` surface as `NodeRequire`. + // Generated projects set `types: []`, so the alias has to live here or + // tests that annotate `require` with that name fail as `TS2304`. + interface NodeRequire extends NodeJS.Require {} + var __filename: string + var __dirname: string } diff --git a/runtime/node/node-globals.ts b/runtime/node/node-globals.ts index df6dc6b..0ad2593 100644 --- a/runtime/node/node-globals.ts +++ b/runtime/node/node-globals.ts @@ -110,6 +110,12 @@ declare global { var process: NodeJS.Process + // Same alias `@types/node` publishes. A type only: a value binding here + // would claim a host cell the plugin does not define. + interface NodeRequire { + (specifier: string): any + } + // Node's own alias for the object `globalThis` already names -- kept // because library code still spells it this way. `@hono/node-server`'s // `listener.ts`/`request.ts`/`response.ts` read and diff --git a/scripts/build.mjs b/scripts/build.mjs index e820691..6839269 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -562,6 +562,14 @@ if (process.env.GEA_FILE_MAP) { message: row.message })), withheld: result.diagnostics.diagnostics.filter((row) => row.message.startsWith('withheld:')).map((row) => row.message), + // Certify-stage refusals are not diagnostics. Without this column a + // program can fail with certificate=null, missingPredicates=[], roots=[] + // and the corpus ladder reports `certify:unknown` with an empty reason. + refusals: result.refusals + .filter((row) => row.stage === 'certify') + .slice(0, 20) + .map((row) => `${row.key}: ${row.reason}`), + slotDrift: result.slotDrift.slice(0, 10).map((row) => row.reason ?? `${row.source} -> ${row.slot}`), diagnostics: result.diagnostics.diagnostics.slice(0, 40).map((row) => `${row.severity} ${where(row)}: ${row.message}`), sourcePreparations: result.sourcePreparations, emittedLines: result.units.reduce((total, unit) => total + unit.source.split('\n').length, 0),