feat(analysis): add opt-in retained inventory and WASM views (#2122)

Add opt-in retained inventory and WASM Evidence views with exact nested output contracts and a small static WASM descriptor. Preserve old complete CLI/MCP workflows, producer choices, original authenticated Evidence and cleanup ownership.

Validated with real public applications, genuine old Evidence migration, 123 focused assertions, 11 synchronized description checks and 42 installed-package WABT cases. Detailed generated experiment JSON stays outside the final tree; concise findings and reproduction inputs remain. Main-existing completion/package CI failures are separately attributed and left unchanged.

Refs #2016

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
Ysopwnable
2026-10-12 21:17:52 +08:00
committed by GitHub
co-authored by factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent 3159732597
commit 58fb372071
55 changed files with 4322 additions and 235 deletions
+20
View File
@@ -1,4 +1,5 @@
import { z } from "zod";
import { createHash } from "node:crypto";
import { localPathStringSchema } from "../localPath.js";
@@ -83,6 +84,15 @@ export const wasmArtifactSchema = z
limitations: z.array(z.string()),
})
.superRefine((value, context) => {
if (
createHash("sha256").update(value.wat.text, "utf8").digest("hex") !==
value.wat.sha256
)
context.addIssue({
code: "custom",
path: ["wat", "sha256"],
message: "Decoded WAT digest does not match its UTF-8 text.",
});
const selected = value.candidates[0];
if (
selected?.path !== value.artifact.path ||
@@ -125,3 +135,13 @@ export const wasmArtifactSchema = z
export type InspectWasmArtifactInput = z.infer<
typeof inspectWasmArtifactInputSchema
>;
export type WasmArtifact = z.infer<typeof wasmArtifactSchema>;
/** A WASM observation must identify the exact selected path and byte digest. */
export const wasmArtifactMatchesSubject = (
artifact: WasmArtifact["artifact"],
subject: Pick<WasmArtifact["artifact"], "path" | "sha256"> | null | undefined,
): subject is Pick<WasmArtifact["artifact"], "path" | "sha256"> =>
subject != null &&
subject.path === artifact.path &&
subject.sha256 === artifact.sha256;