mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
* build(scripts): type-check the Evidence verification scripts against src Six JavaScript callers kept passing `undefined` as an Evidence subject after `createEvidence` stopped accepting it (#11536); `npm run typecheck` saw only the TypeScript callers. The scripts import built modules by relative `../dist/` paths, which a checker resolves to the built JavaScript (or nothing, before a build) rather than the source types. A package-private `#dist/*` import alias resolves to `./dist/*` at run time, and `tsconfig.scripts.json` maps it to `./src/*` and checks the listed scripts with `checkJs` under the main compiler options. `typecheck`, and so `check:fast`, runs it; turbo's typecheck inputs include the scripts and the new config. First slice: `verify-package-evidence.mjs` (its evidence-bundle import becomes static), `verify/javascript/output.mjs` and `verify/javascript/digests.mjs`, with the JSDoc types the check required. Refs #11545 * build(scripts): type-check the MCP verifier results and Ghidra snapshot lifecycle helpers (#11590) * build(scripts): type-check the managed app manifest verifier (#11592) * build(scripts): type-check the managed oracles and completion report (#11605) oracles.mjs and completion-report.mjs join tsconfig.scripts.json (72 errors). ensureIlspy is an assertion function, the ILSpy import returns the imported Evidence and reads its normalized result through managedReconstructionImportResultSchema, the manifest-rejection controls are named records walked by a checked field lookup, and the completion report names its input.
92 lines
2.7 KiB
JavaScript
92 lines
2.7 KiB
JavaScript
import { readFile, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { createEvidence } from "#dist/domain/evidence.js";
|
|
import {
|
|
createEvidenceBundle,
|
|
serializeEvidenceBundle,
|
|
} from "#dist/domain/evidenceBundle.js";
|
|
import { unknownTarget } from "#dist/domain/targetIdentity.js";
|
|
|
|
/**
|
|
* Round-trip historical reference import and evidence bundles.
|
|
* @param {{
|
|
* readonly commands: {
|
|
* run(
|
|
* command: string,
|
|
* arguments_: readonly string[],
|
|
* environment?: NodeJS.ProcessEnv,
|
|
* ): Promise<string>;
|
|
* };
|
|
* readonly cli: string;
|
|
* readonly evidenceRoot: string;
|
|
* readonly referenceRoot: string;
|
|
* readonly environment: NodeJS.ProcessEnv;
|
|
* }} options
|
|
*/
|
|
export async function verifyPackageEvidence({
|
|
commands,
|
|
cli,
|
|
evidenceRoot,
|
|
referenceRoot,
|
|
environment,
|
|
}) {
|
|
const referenceImport = JSON.parse(
|
|
await commands.run(
|
|
cli,
|
|
["import-reference-source", referenceRoot, "--json"],
|
|
environment,
|
|
),
|
|
);
|
|
if (
|
|
referenceImport.authority !== "historical-reference" ||
|
|
referenceImport.root_alias !== "$REFERENCE_ROOT" ||
|
|
referenceImport.relationships?.[0]?.resolution !== "internal" ||
|
|
JSON.stringify(referenceImport).includes("PACKAGE_SECRET_SENTINEL")
|
|
)
|
|
throw new Error("packaged historical reference import CLI failed");
|
|
const sourceBundle = createEvidenceBundle([
|
|
createEvidence(
|
|
unknownTarget("not-observed"),
|
|
{ id: "package", name: "Package verifier", version: "1" },
|
|
{ operation: "health", parameters: {}, result: true },
|
|
),
|
|
]);
|
|
const sourceBundlePath = join(evidenceRoot, "source.json");
|
|
const canonicalBundlePath = join(evidenceRoot, "canonical.json");
|
|
await writeFile(sourceBundlePath, serializeEvidenceBundle(sourceBundle));
|
|
const importedBundle = JSON.parse(
|
|
await commands.run(
|
|
cli,
|
|
["evidence-import", sourceBundlePath, "--json"],
|
|
environment,
|
|
),
|
|
);
|
|
const exportedBundle = JSON.parse(
|
|
await commands.run(
|
|
cli,
|
|
["evidence-export", sourceBundlePath, canonicalBundlePath, "--json"],
|
|
environment,
|
|
),
|
|
);
|
|
const comparedBundle = JSON.parse(
|
|
await commands.run(
|
|
cli,
|
|
["compare", sourceBundlePath, canonicalBundlePath, "--json"],
|
|
environment,
|
|
),
|
|
);
|
|
if (
|
|
importedBundle.imported !== 1 ||
|
|
importedBundle.total !== 1 ||
|
|
exportedBundle.records !== 1 ||
|
|
(await readFile(canonicalBundlePath, "utf8")) !==
|
|
serializeEvidenceBundle(sourceBundle) ||
|
|
comparedBundle.status !== "unchanged" ||
|
|
comparedBundle.summary?.records_unchanged !== 1
|
|
)
|
|
throw new Error(
|
|
"packaged CLI evidence bundle comparison round trip failed",
|
|
);
|
|
}
|