mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
* build(scripts): type-check the shared verifier run, fixture, cleanup and source loader The five scripts/lib modules join tsconfig.scripts.json (69 errors). Named types come from their existing declaration files. The source loader probes the runtime's TypeScript transform once and refuses a Node.js without transform mode (Node.js 26 removed it) with the pinned-runtime message instead of failing on the first owned source file. * build(scripts): type-check the managed PE and function dossier fixtures (#11611) * build(scripts): type-check the managed PE and function dossier fixtures pe.mjs and function-dossier.mjs join tsconfig.scripts.json (68 errors). Named option types come from pe.d.mts; heap names are paired with their rows instead of read back by index; optional metadata tables are added to the row map directly; a placed body's RVA is computed by bodyRva, which refuses an unplaced body. Fixture bytes are unchanged. * build(scripts): type-check the managed conformance entry point and support (#11612) conformance.mjs, support.mjs and config.mjs join tsconfig.scripts.json (34 errors), completing the managed conformance closure. Result checks narrow with assert.ok, Evidence results are read through their owners' schemas, the native function subject is an EvidenceSubjectTarget, the comparison check no longer dereferences a right-only method's null left side, and the fixture callback returns the report instead of assigning outer variables.
69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
/** @typedef {() => unknown} VerifierCleanupTask */
|
|
|
|
/**
|
|
* @param {Iterable<VerifierCleanupTask>} tasks
|
|
* @returns {Promise<unknown[]>}
|
|
*/
|
|
async function collectCleanupFailures(tasks) {
|
|
/** @type {unknown[]} */
|
|
const failures = [];
|
|
for (const task of tasks) {
|
|
try {
|
|
await task();
|
|
} catch (cause) {
|
|
failures.push(cause);
|
|
}
|
|
}
|
|
|
|
return failures;
|
|
}
|
|
|
|
/**
|
|
* Attempt every independent cleanup and preserve each failure.
|
|
* @param {Iterable<VerifierCleanupTask>} tasks
|
|
*/
|
|
export async function closeVerifierResources(tasks) {
|
|
const failures = await collectCleanupFailures(tasks);
|
|
if (failures.length > 0)
|
|
throw new AggregateError(failures, "Verifier cleanup failed");
|
|
}
|
|
|
|
/**
|
|
* Finish one operation and its cleanup without losing either failure.
|
|
* @template T
|
|
* @param {() => T | Promise<T>} operation
|
|
* @param {Iterable<VerifierCleanupTask>} cleanupTasks
|
|
* @returns {Promise<T>}
|
|
*/
|
|
export async function withVerifierCleanup(operation, cleanupTasks) {
|
|
let value;
|
|
try {
|
|
value = await operation();
|
|
} catch (cause) {
|
|
const failures = await collectCleanupFailures(cleanupTasks);
|
|
if (failures.length > 0)
|
|
throw new AggregateError(
|
|
[cause, ...failures],
|
|
"Verifier cleanup failed",
|
|
{ cause },
|
|
);
|
|
throw cause;
|
|
}
|
|
await closeVerifierResources(cleanupTasks);
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* The leaf reasons of a verifier failure. `withVerifierCleanup` and the
|
|
* fixtures it releases nest `AggregateError`s (verification failure, cleanup
|
|
* failure, retained root), so a reporter that unwraps one level shows only
|
|
* "Verifier cleanup failed" instead of why.
|
|
* @param {unknown} cause
|
|
* @returns {string[]}
|
|
*/
|
|
export function verifierFailureReasons(cause) {
|
|
if (cause instanceof AggregateError)
|
|
return cause.errors.flatMap(verifierFailureReasons);
|
|
return [cause instanceof Error ? cause.message : String(cause)];
|
|
}
|